user3862685 user3862685 - 1 year ago 59
Java Question

getItemInHand() and setHelmet() not working with bukkit, Java

So basically, my problem is that when I use getItemInHand() and setHelmet(), it returns an error "Change type of item to 'ItemStack'" for both lines. Here is the code where the errors appear:

//Do stuff here when enabled.
player.sendMessage(ChatColor.GREEN + "Enabled!");
ItemStack item = player.getItemInHand();

Please help me, I'd be very grateful.

~ Jack

Answer Source

My best guess is that you are importing CraftBukkit and that the ItemStack you import is the net.minecraft.server.ItemStack, not org.bukkit.inventory.ItemStack. If this is the case, change your import and you should be fine.