Removing a item

Discussion in 'Plugin Development' started by Cooper PluginDev, Dec 25, 2013.

Thread Status:
Not open for further replies.
  1. So I want it when you left click it puts the item on your head but takes the item out of your hand so basically it's like equiping armor.

    The problem is it isn't removing the item from your hand it's basically duping the item.

    Code:
    http://pastebin.com/Y7K02kfc
     
  2. Offline

    KaiPol

    player.getInventory().removeItem(new ItemStack(material, amount))
    then something like this : player.getInventory().setHelmet(new ItemStack(Material.LEATHER_HELMET));
    Cooper PluginDev
     
  3. Offline

    ThunderWaffeMC

    You also have to update the inventory (event.getPlayer().updateInventory();). It is deprecated but it works fine. Try using your code and then updating the inventory to see if it changes.
     
  4. Still doesn't work
     
  5. Offline

    d3v1n302418

    Probably because either:
    A: The item has ItemMeta.
    B: The item has durability.
    Try doing player.getInventory().removeItem(p.getItemInHand());
     
Thread Status:
Not open for further replies.

Share This Page