Setting item and the ItemHeldSlot removes the ability to drop the item

Discussion in 'Plugin Development' started by TomFromCollege, Jul 12, 2013.

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

    TomFromCollege

    Title says all! Here's my code:

    Code:
          p.getInventory().setHelmet(new ItemStack(getFlagHolderMaterial(FlagTeam)));
          p.getInventory().setItem(8, getWool(FlagTeam));
          p.getInventory().setHeldItemSlot(8);
          p.updateInventory();
    Just using that, I am unable to drop the item in the 8th slot, the PlayerDropItemEvent is never called and is just... cancelled I guess? I don't understand it.

    Shameful bump! :(
    I'd like to clarify that the events are definitely registered and that the problem only occurs when I've added the above item, before that, the event is being called perfectly!

    My guess is that it's possibly client side almost acting as if there's no item to remove... I'm so lost!

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 3, 2016
  2. Offline

    Levi2241

    Try taking p.updateInventory(); out. Its a deprecated command that is no longer needed when run on a server.
     
  3. Offline

    TomFromCollege

    It is needed! I've read it in countless posts... It may be deprecated because the bukkit team asked themselves why the player inventory needs updating in the first place, but I can assure you that this isn't causing the issue :)

    More news; If you drop an item via the inventory, the event is called... just not when pressing the button to drop (Q)
     
Thread Status:
Not open for further replies.

Share This Page