Remove one item from PlayerInventory doesn't work

Discussion in 'Plugin Development' started by MisterErwin, Oct 12, 2012.

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

    MisterErwin

    Hello together,

    how can I remove one Item from PlayerInventory.
    Code:
    p.getInventory().removeItem(new ItemStack(364,    1));
    Works fine until the players has one or more Steaks (364).
    But when he has only one Steak, it won't disappear. Why?

    Thanks,
    MisterErwin
     
  2. Offline

    sd5

    Hmm, I have this line in an event of my NoStarvation plugin (http://dev.bukkit.org/server-mods/nostarvation/) and it works fine:
    paramEvent.getPlayer().getInventory().removeItem(new ItemStack(paramEvent.getItem().getTypeId(), 1));
     
  3. Offline

    p000ison

  4. Offline

    MisterErwin

    Nope... If the player has only one Steak, it didn't disapper :(

    Looks nice :rolleyes:, I'll try it now...
    €: It works until I have one item in my hand... Im now searching in my code...
     
  5. Offline

    travja

    I've had this problem, the only fix I could find was to update the inventory.
     
  6. Offline

    MisterErwin

    Is this method not depraced deleted?
     
  7. Offline

    CevinWa

    Just define the itemstack first in this case i use Sulphur.


    ItemStack m = new ItemStack(Material.SULPHUR, 1);
    if(player.getInventory().contains(Material.SULPHUR)){
    player.getInventory().removeItem(m);
    player.updateInventory();
     
Thread Status:
Not open for further replies.

Share This Page