Even on the highest priority and with ignoreCancelled = true, some inventory events just don't work.
The one I've tested that don't work: InventoryOpenEvent, InventoryEvent, InventoryPickupItemEvent
The one I've tested that DO work: InventoryClickEvent, InventoryDragEvent, InventoryCloseEvent
I've implemented handlers for all of these events in the same class (which ofc implements Listener). That class is registered to listen to events.
Code:
private void inventoryEvent(Inventory inventory) {
Stronghold.logger.debug(Thread.currentThread().getStackTrace()[2], inventory, inventory.getHolder());
if (inventory.getHolder() instanceof Player) {
Items.registerInventoryCheck(inventory);
}
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onInventoryClick(InventoryClickEvent event) { // works
inventoryEvent(event.getInventory());
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onInventoryPickup(InventoryPickupItemEvent event) { // doesn't work
inventoryEvent(event.getInventory());
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onInventoryEvent(InventoryEvent event) { // doesn't work
inventoryEvent(event.getInventory());
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onInventoryDrag(InventoryDragEvent event) { // works
inventoryEvent(event.getInventory());
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onInventoryOpen(InventoryOpenEvent event) { // doesn't work
inventoryEvent(event.getInventory());
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onInventoryClose(InventoryCloseEvent event) { // works
inventoryEvent(event.getInventory());
}
Thanks for the help in advance.
The one I've tested that don't work: InventoryOpenEvent, InventoryEvent, InventoryPickupItemEvent
The one I've tested that DO work: InventoryClickEvent, InventoryDragEvent, InventoryCloseEvent
I've implemented handlers for all of these events in the same class (which ofc implements Listener). That class is registered to listen to events.
Code:
private void inventoryEvent(Inventory inventory) {
Stronghold.logger.debug(Thread.currentThread().getStackTrace()[2], inventory, inventory.getHolder());
if (inventory.getHolder() instanceof Player) {
Items.registerInventoryCheck(inventory);
}
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onInventoryClick(InventoryClickEvent event) { // works
inventoryEvent(event.getInventory());
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onInventoryPickup(InventoryPickupItemEvent event) { // doesn't work
inventoryEvent(event.getInventory());
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onInventoryEvent(InventoryEvent event) { // doesn't work
inventoryEvent(event.getInventory());
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onInventoryDrag(InventoryDragEvent event) { // works
inventoryEvent(event.getInventory());
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onInventoryOpen(InventoryOpenEvent event) { // doesn't work
inventoryEvent(event.getInventory());
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onInventoryClose(InventoryCloseEvent event) { // works
inventoryEvent(event.getInventory());
}
Thanks for the help in advance.