Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-3552

InventoryDragEvent's inventory returns CraftingInventory not PlayerInventory

XMLWordPrintable

      I was attempting to prevent players from dragging items across their inventory when I came across an issue. Simply listening to InventoryDragEvent, checking if event.getInventory() is an instance of PlayerInventory (or getType() is InventoryType.PLAYER) then cancelling the event does not work. I printed out the class name of getInventory() along with the enum name of getType() and to my surprise, it printed out 'CraftingInventory' and 'CRAFTING'. Is there a reason why the inventory type is crafting rather than the player's inventory? If this is a bug, a fix of this may break old plugins that thought CraftingInventory was the correct type and do things based on that event, so I'd recommend a new method (e.g. getDraggedInventory()) and deprecating getInventory() if this was to be fixed.

            Unassigned Unassigned
            KingFaris10 Faris Rehman
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: