diff --git a/src/main/java/net/minestom/server/inventory/click/InventoryClickProcessor.java b/src/main/java/net/minestom/server/inventory/click/InventoryClickProcessor.java index 80ce319e2..f5c835010 100644 --- a/src/main/java/net/minestom/server/inventory/click/InventoryClickProcessor.java +++ b/src/main/java/net/minestom/server/inventory/click/InventoryClickProcessor.java @@ -186,7 +186,7 @@ public class InventoryClickProcessor { return null; var pair = TransactionType.ADD.process(targetInventory, clicked, (index, itemStack) -> { - InventoryClickResult result = startCondition(inventory, player, index, ClickType.SHIFT_CLICK, itemStack, cursor); + InventoryClickResult result = startCondition(targetInventory, player, index, ClickType.SHIFT_CLICK, itemStack, cursor); return !result.isCancel(); }); @@ -209,7 +209,7 @@ public class InventoryClickProcessor { var pair = TransactionType.ADD.process(targetInventory, clicked, (index, itemStack) -> { if (index == slot) // Prevent item lose/duplication return false; - InventoryClickResult result = startCondition(null, player, index, ClickType.SHIFT_CLICK, itemStack, cursor); + InventoryClickResult result = startCondition(targetInventory, player, index, ClickType.SHIFT_CLICK, itemStack, cursor); return !result.isCancel(); }, start, end, step); @@ -547,6 +547,13 @@ public class InventoryClickProcessor { return startCondition(clickResult, inventory, player, slot, clickType); } + @NotNull + private InventoryClickResult startCondition(@Nullable AbstractInventory inventory, @NotNull Player player, int slot, + @NotNull ClickType clickType, @NotNull ItemStack clicked, @NotNull ItemStack cursor) { + return startCondition(inventory instanceof Inventory ? (Inventory) inventory : null, + player, slot, clickType, clicked, cursor); + } + private void callClickEvent(@NotNull Player player, @Nullable Inventory inventory, int slot, @NotNull ClickType clickType, @NotNull ItemStack clicked, @NotNull ItemStack cursor) { InventoryClickEvent inventoryClickEvent = new InventoryClickEvent(inventory, player, slot, clickType, clicked, cursor);