Solved ItemStack wood = new ItemStack(Material.WOOD, 64) error?

Discussion in 'Plugin Development' started by Prophettt, May 22, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    Prophettt

    Code:
    if(commandLabel.equalsIgnoreCase("BuildItems"))
                   
                {
                    ItemStack wood = new ItemStack(Material.WOOD, 64);
                    Inventory Build = Bukkit.createInventory(null, 9, ChatColor.RED + "Build Item/Blocks");
                    Build.addItem(wood);
                    player.openInventory(Build);
                }
    Gives an error on "new ItemStack(Material.WOOD, 64);"
    Error Message: The constructor "ItemStack(Material, int) is undefined"

    Anyone know how to fix?
     
  2. Offline

    itzrobotix

    It shouldn't .-.
     
  3. Offline

    Prophettt

  4. Offline

    itzrobotix

    It shouldn't have a constructer error. I pasted your code into my IDE, no errors. Do you have the correct Bukkit version etc?
     
  5. Offline

    Trevor1134

    itzrobotix I am not sure, I just skimmed over this, but from I can see, I have experieneced the same error with the latest 1.7.9 build. I assume it is a transition from Material itemstacks or something a long the lines, but haven't found anything solid on that.

    I have experienced the error with item ID's as well, and am currently using a deprecated way of spawning items, which I don't prefer :p
     
  6. Offline

    Prophettt

    Trevor1134 I'm using 1.7.2, not 1.7.9, so I don't know what's going on

    itzrobotix I use 1.7.2 as my server is 1.7.2 as well. I'll paste my entire code in here since it's not much of a plugin anyway.

    Maybe I did something wrong elsewhere;

    Code:
    package com.prophettt.test;
     
    import java.util.logging.Logger;
     
     
    import net.minecraft.server.v1_7_R1.Material;
     
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.GameMode;
    import org.bukkit.Location;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.inventory.Inventory;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.plugin.java.JavaPlugin;
     
    public class plugin extends JavaPlugin {
        Logger myPluginLogger = Bukkit.getLogger();
     
            @Override
        public void onEnable()
        {
            myPluginLogger.info("Plugin has started.");
        }
         
            @Override
        public void onDisable(){
             
            myPluginLogger.info("The plugin has stopped!");
        }
     
            public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
                Player player = (Player) sender;
     
                if(commandLabel.equalsIgnoreCase("BlackOut")){
                 
                 
                 
                    if(args.length == 1){
                    if(args[0].equalsIgnoreCase("Prophettt")){                 
                     
                        player.sendMessage(ChatColor.BOLD + "BlackOut");
                    }
                    if(args[0].equalsIgnoreCase("MinecraftMatan")){
                        player.sendMessage(ChatColor.BOLD + "BlackOut");
                    }
                    if(args[0].equalsIgnoreCase("ROFL")){
                        player.sendMessage(ChatColor.BOLD + "BlackOut");
                    }
                    if(args[0].equalsIgnoreCase("srslyHaily")){
                        player.sendMessage(ChatColor.ITALIC + "BlackOut");
                    }
                    if(args[0].equalsIgnoreCase("superadvance")){
                        player.sendMessage(ChatColor.BOLD + "BlackOut");
                    }
                    if(args[0].equalsIgnoreCase("Hellionx2")){
                        player.sendMessage(ChatColor.BOLD + "BlackOut");
                    }
                    if(args[0].equalsIgnoreCase("Kiaa")){
                        player.sendMessage(ChatColor.BOLD + "BlackOut");
             
                }
                 
                 
                 
                     
                }
                 
                    if(args.length == 0){
                        player.sendMessage(ChatColor.DARK_RED + "You fucking idiot! You have to type the In-game name of the person to check their size.");
                    }
                    }
             
             
                if(commandLabel.equalsIgnoreCase("sethealth")){
                    if(args.length == 2)
                    {
                    Player getThePlayer = Bukkit.getPlayer(args[0]);
                    double setScale = Double.parseDouble(args[1]) * 2;
                    getThePlayer.setHealthScale(setScale);
                 
                    }
                }
                if(commandLabel.equalsIgnoreCase("troll")){
                    Player player1 = (Player) sender;
                    if(args.length == 1){
                    int X = 428;
                    int Y = 90;
                    int Z = -462;
                 
                    Location Troll = new Location(player1.getWorld(), X, Y, Z);
                         
                    Player Troll2 = Bukkit.getPlayer(args[0]);
                        Troll2.teleport(Troll);
                     
                        Troll2.setGameMode(GameMode.SURVIVAL);
                    }
                    else player1.sendMessage(ChatColor.RED + "Use '/troll <Player> for the command to work, idiot.");
             
                }
                if(commandLabel.equalsIgnoreCase("BuildItems"))
                 
                {
                    ItemStack wood = new ItemStack(Material.WOOD, 64);
                    Inventory Build = Bukkit.createInventory(null, 9, ChatColor.RED + "Build Item/Blocks");
                    Build.addItem(wood);
                    player.openInventory(Build);
                }
             
                return true;
        } }
     
    
     
  7. Offline

    rsod

    Prophettt you imported wrong Material enum. You using
    import net.minecraft.server.v1_7_R1.Material;
    it should be
    org.bukkit.Material
     
    itzrobotix and Prophettt like this.
  8. Offline

    Prophettt

    rsod Thanks, completely overlooked that.

    / Solved
     
Thread Status:
Not open for further replies.

Share This Page