Search code examples
javaminecraftbukkit

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:

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

Please help me, I'd be very grateful.

~ Jack


Solution

  • 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.