@Override protected void onInventoryClick(InventoryClickEvent event, Player player) { event.setCancelled(true); final int slot = event.getRawSlot(); if (slot >= 0 && slot <= 7) { // handle changing sell stack size ItemStack item = event.getCurrentItem(); if (item != null && item.getType() != Material.AIR) { int amount = item.getAmount(); amount = this.getNewAmountAfterEditorClick(event, amount); if (amount <= 0) amount = 1; if (amount > item.getMaxStackSize()) amount = item.getMaxStackSize(); item.setAmount(amount); } } else if ((slot >= 9 && slot <= 16) || (slot >= 18 && slot <= 25)) { if (((TradingPlayerShopkeeper) shopkeeper).clickedItem != null) { // placing item final Inventory inventory = event.getInventory(); Bukkit.getScheduler() .runTaskLater( ShopkeepersPlugin.getInstance(), new Runnable() { public void run() { inventory.setItem(slot, ((TradingPlayerShopkeeper) shopkeeper).clickedItem); ((TradingPlayerShopkeeper) shopkeeper).clickedItem = null; } }, 1); } else { // changing stack size ItemStack item = event.getCurrentItem(); if (item != null && item.getType() != Material.AIR) { int amount = item.getAmount(); amount = this.getNewAmountAfterEditorClick(event, amount); if (amount <= 0) { event.getInventory().setItem(slot, null); } else { if (amount > item.getMaxStackSize()) amount = item.getMaxStackSize(); item.setAmount(amount); } } } } else if (slot >= 27) { // clicking in player inventory if (event.isShiftClick() || !event.isLeftClick()) { return; } ItemStack cursor = event.getCursor(); if (cursor != null && cursor.getType() != Material.AIR) { return; } ItemStack current = event.getCurrentItem(); if (current != null && current.getType() != Material.AIR) { ((TradingPlayerShopkeeper) shopkeeper).clickedItem = current.clone(); ((TradingPlayerShopkeeper) shopkeeper).clickedItem.setAmount(1); } } else { super.onInventoryClick(event, player); } }