Custom drop

Discussion in 'Plugin Development' started by unrealdesign, Jun 30, 2014.

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

    unrealdesign

    Hello everyone,

    I was wondering if I could get some help on figuring on how to do what I'm looking to do. I honestly have no idea where to begin and can't figure out how to go forth doing what I need to do.

    What I want to do: Disable dropping items in the slots 1-9

    I haven't found any methods with any means to do this. The reason I want to do this, is because I want to not let players drop or pickup items in the inventory slots 1-9. I am reserving those slots for special features in my plugin. I have already successfully made all pickup events correctly be added to the inventory excluding the slots 1-9, but I can't figure out the way to disable dropping items from the slots 1-9.

    Inevitable work around: I know all of the items that I want to be put in those slots, so I could possibly check if the item being dropped is that item and if so cancel it. But this seems like a cheesy and possible resource heavy work around and I would like to avoid it if at all possible.
     
  2. Offline

    MCForger

    unrealdesign
    Well can you cancel all drop events because the player has to have the item selected in the first row? Then just cancel inventory click events on the first row as well.
    EDIT: I am not sure if the PlayerDropItemEvent is also called when the player drops something out of there inventory.
     
  3. Offline

    Heirteir

    PlayerDropItemEvent save the item they're dropping in a variable then loop through the slots 1 - 9 and see if it equals that ItemStack if it does then cancel
     
  4. Offline

    MCForger

    unrealdesign
    The PlayerDropItemEvent is called also when the player drops an item out of the player's inventory so you can not cancel every event. You might as well be better off checking the display name of the item every time it is dropped.
     
  5. Offline

    unrealdesign

    Like you said, there is no way to check it this way because of this. What I thought of right now is, I'm going to save all players inventory my own way. What I could do is, get the item that is dropped, and if it is equal to any of the items in the inventory slots 1-9, then cancel the event. Any other ideas?
     
  6. Offline

    MCForger

Thread Status:
Not open for further replies.

Share This Page