Items added with setItem() or addItem disappear on right click

Discussion in 'Plugin Development' started by martin8, Aug 30, 2011.

Thread Status:
Not open for further replies.
  1. Hello, I just joined the forums and hopefully I'm not doing this wrong.

    I made a really simple plugin that adds an item to the players inventory after a respawn. The item gets there, but if you right click while holding the item, it disappears into thin air. It doesn't really matter which item.

    This happens with both setItem and addItem.

    Here are the relevant 2 lines of code
    Code:
    if (!inventory.contains(item))
        inventory.setItem(inventory.firstEmpty(), item);
    Well hopefully it's something really stupid.

    Thanks for the help!
     
  2. Offline

    nisovin

    When creating an ItemStack, be sure to specify a quantity.
     
  3. Offline

    68x

    I had the same problem ..
    Use this:
    Code:
    Player.getInventory().addItem(new ItemStack (itemID, itemAmount));
     
  4. Oh right I didn't specify it, thanks for the super fast reply.
     
Thread Status:
Not open for further replies.

Share This Page