Cancelling the InventoryClickEvent

Discussion in 'Plugin Development' started by bobacadodl, Feb 6, 2013.

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


    So in my plugin, I'm opening up a virtual chest inventory for the player. I want the player to be able to move around items in the top inventory, but not in the bottom inventory(the player's inventory). I also don't want them to be able to take items from the top inventory and put them into their inventory.

    So, in my plugin I detect which inventory they click in, and if it is the bottom inventory, cancel it.
    @EventHandler(priority=EventPriority.HIGHEST, ignoreCancelled=false)
        public void onInventoryClick(InventoryClickEvent e){
    (I'm normally canceling ALL inventoryClickEvents in a different listener class. That's why I am only UNCANCELLING if it is in the top inventory.)

    When players close this inventory, I'm unregistering this listener.

    The problem that is occurring is that players are able to drag items from the top inventory into their bottom inventory. Also, when the inventory is closed, the OTHER inventoryInteractListener which cancels all inventory interact events seems to stop working.
  2. Offline


    bobacadodl i thoutgh maybe check if th invslot is MORE. Than 54
  3. Offline


    Try using a single listener, but before it decides whether or not to cancel the event, check if your custom inventory is open.

    Not 100% sure, but it sounds like it would be much more efficient and less complicated.
  4. Offline


    I was thinking about trying this, it might work..

    DJSanderrr No....
  5. Offline


    Okay sorry then i guess i dont understand what you mean.
Thread Status:
Not open for further replies.

Share This Page