org.bukkit.event.inventory.InventoryAction Java Examples
The following examples show how to use
org.bukkit.event.inventory.InventoryAction.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MainListener.java From ArmorStandTools with MIT License | 7 votes |
@EventHandler public void onInventoryClick(InventoryClickEvent event) { if (event.isCancelled() || !(event.getWhoClicked() instanceof Player)) return; final Player p = (Player) event.getWhoClicked(); ItemStack item = event.getCurrentItem(); if(event.getInventory().getHolder() != p && ArmorStandTool.isTool(item)) { event.setCancelled(true); //noinspection deprecation p.updateInventory(); return; } if(event.getAction() == InventoryAction.HOTBAR_SWAP || event.getAction() == InventoryAction.HOTBAR_MOVE_AND_READD) { if(Utils.hasAnyTools(p)) { event.setCancelled(true); //noinspection deprecation p.updateInventory(); } } }
Example #2
Source File: ItemFilter.java From Minepacks with GNU General Public License v3.0 | 6 votes |
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onItemClick(InventoryClickEvent event) { if(!(event.getWhoClicked() instanceof Player)) return; if(event.getInventory().getHolder() instanceof Backpack) { Player player = (Player) event.getWhoClicked(); if(event.getAction() == InventoryAction.MOVE_TO_OTHER_INVENTORY && checkIsBlockedAndShowMessage(player, event.getCurrentItem())) { event.setCancelled(true); } else if((event.getAction() == InventoryAction.HOTBAR_MOVE_AND_READD || event.getAction() == InventoryAction.HOTBAR_SWAP) && event.getHotbarButton() != -1) { ItemStack item = event.getWhoClicked().getInventory().getItem(event.getHotbarButton()); if(checkIsBlockedAndShowMessage(player, item)) { event.setCancelled(true); } } else if(!player.getInventory().equals(event.getClickedInventory()) && checkIsBlockedAndShowMessage(player, event.getCursor())) { event.setCancelled(true); } } }
Example #3
Source File: AnvilGUI.java From AnvilGUI with MIT License | 6 votes |
@EventHandler public void onInventoryClick(InventoryClickEvent event) { if ( ((event.getInventory().equals(inventory)) && (event.getRawSlot() < 3)) || (event.getAction().equals(InventoryAction.MOVE_TO_OTHER_INVENTORY)) || ((event.getRawSlot() < 3) && ((event.getAction().equals(InventoryAction.PLACE_ALL)) || (event.getAction().equals(InventoryAction.PLACE_ONE)) || (event.getAction().equals(InventoryAction.PLACE_SOME)) || (event.getCursor() != null))) ){ event.setCancelled(true); final Player clicker = (Player) event.getWhoClicked(); if (event.getRawSlot() == Slot.OUTPUT) { final ItemStack clicked = inventory.getItem(Slot.OUTPUT); if (clicked == null || clicked.getType() == Material.AIR) return; final Response response = completeFunction.apply(clicker, clicked.hasItemMeta() ? clicked.getItemMeta().getDisplayName() : ""); if(response.getText() != null) { final ItemMeta meta = clicked.getItemMeta(); meta.setDisplayName(response.getText()); clicked.setItemMeta(meta); inventory.setItem(Slot.INPUT_LEFT, clicked); } else { closeInventory(); } } } }
Example #4
Source File: VillagerTradesListener.java From Statz with GNU General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onVillagerTrade(final InventoryClickEvent event) { final PlayerStat stat = PlayerStat.VILLAGER_TRADES; // Thanks to Lolmewn for this code (https://bitbucket // .org/Lolmewn/stats/src/4eae2db1b21038a91b7d39181f27bdd3cd987324/src/main/java/nl/lolmewn/stats/stats/bukkit // /BukkitTrades.java?at=3.0&fileviewer=file-view-default) if (event.getInventory().getType() != InventoryType.MERCHANT) { return; } if (!event.getSlotType().equals(SlotType.RESULT)) { return; } if (!event.getAction().equals(InventoryAction.MOVE_TO_OTHER_INVENTORY) && !event.getAction().equals(InventoryAction.PICKUP_ALL)) { return; } if (!(event.getWhoClicked() instanceof Player)) { return; } Player player = (Player) event.getWhoClicked(); // Do general check if (!plugin.doGeneralCheck(player, stat)) return; ItemStack item = event.getCurrentItem(); // Update value to new stat. plugin.getDataManager().setPlayerInfo(player.getUniqueId(), stat, StatzUtil.makeQuery("uuid", player.getUniqueId().toString(), "value", item.getAmount(), "world", player.getWorld().getName(), "trade", item.getType().toString())); }
Example #5
Source File: InventoryForItemStorage.java From NBTEditor with GNU General Public License v3.0 | 5 votes |
@Override protected void inventoryClick(InventoryClickEvent event) { Inventory inventory = event.getClickedInventory(); if (inventory != null) { InventoryAction action = event.getAction(); if (action == InventoryAction.COLLECT_TO_CURSOR) { event.setCancelled(true); } else if (inventory.getType() == InventoryType.PLAYER) { if (action == InventoryAction.MOVE_TO_OTHER_INVENTORY) { event.setCancelled(true); } } else { event.setCancelled(true); int slot = event.getSlot(); if (slot < ITEMS_PER_PAGE) { if (event.getCursor().getType() == Material.AIR && _originaItems[slot] != null) { event.getView().setCursor(_originaItems[slot]); } } else if (slot == 52) { // previous page changePage(-1); } else if (slot == 53) { // next page changePage(1); } } } }
Example #6
Source File: TestVanillaMachinesListener.java From Slimefun4 with GNU General Public License v3.0 | 5 votes |
private CraftItemEvent mockCraftingEvent(ItemStack item) { Recipe recipe = new ShapedRecipe(new NamespacedKey(plugin, "test_recipe"), new ItemStack(Material.EMERALD)); Player player = server.addPlayer(); CraftingInventory inv = Mockito.mock(CraftingInventory.class); Mockito.when(inv.getContents()).thenReturn(new ItemStack[] { item, null, null, null, null, null, null, null, null }); InventoryView view = player.openInventory(inv); CraftItemEvent event = new CraftItemEvent(recipe, view, SlotType.RESULT, 9, ClickType.LEFT, InventoryAction.PICKUP_ALL); listener.onCraft(event); return event; }
Example #7
Source File: TestVanillaMachinesListener.java From Slimefun4 with GNU General Public License v3.0 | 5 votes |
private InventoryClickEvent mockBrewingEvent(ItemStack item) { Player player = server.addPlayer(); Inventory inv = TestUtilities.mockInventory(InventoryType.BREWING); Mockito.when(inv.getHolder()).thenReturn(Mockito.mock(BrewingStand.class)); Mockito.when(inv.getSize()).thenReturn(5); InventoryView view = player.openInventory(inv); view.setCursor(item); InventoryClickEvent event = new InventoryClickEvent(view, SlotType.CONTAINER, 1, ClickType.LEFT, InventoryAction.PICKUP_ONE); listener.onPreBrew(event); return event; }
Example #8
Source File: TestVanillaMachinesListener.java From Slimefun4 with GNU General Public License v3.0 | 5 votes |
private InventoryClickEvent mockAnvilEvent(ItemStack item) { Player player = server.addPlayer(); Inventory inv = TestUtilities.mockInventory(InventoryType.ANVIL, item, null, new ItemStack(Material.IRON_CHESTPLATE)); InventoryView view = player.openInventory(inv); InventoryClickEvent event = new InventoryClickEvent(view, SlotType.CONTAINER, 2, ClickType.LEFT, InventoryAction.PICKUP_ONE); listener.onAnvil(event); return event; }
Example #9
Source File: TestVanillaMachinesListener.java From Slimefun4 with GNU General Public License v3.0 | 5 votes |
private InventoryClickEvent mockGrindStoneEvent(ItemStack item) { Player player = server.addPlayer(); Inventory inv = TestUtilities.mockInventory(InventoryType.GRINDSTONE, item, null); InventoryView view = player.openInventory(inv); InventoryClickEvent event = new InventoryClickEvent(view, SlotType.CONTAINER, 2, ClickType.LEFT, InventoryAction.PICKUP_ONE); listener.onGrindstone(event); return event; }
Example #10
Source File: TestBackpackListener.java From Slimefun4 with GNU General Public License v3.0 | 5 votes |
@ParameterizedTest @EnumSource(value = Material.class, names = { "AIR", "SHULKER_BOX" }) public void testHotbarKey(Material type) throws InterruptedException { Player player = server.addPlayer(); openMockBackpack(player, "BACKPACK_HOTBAR_" + type.name(), 9); int slot = 7; player.getInventory().setItem(slot, new ItemStack(type)); InventoryClickEvent event = new InventoryClickEvent(player.getOpenInventory(), SlotType.CONTAINER, slot, ClickType.NUMBER_KEY, InventoryAction.PICKUP_ONE, slot); listener.onClick(event); Assertions.assertEquals(type != Material.AIR, event.isCancelled()); }
Example #11
Source File: TestBackpackListener.java From Slimefun4 with GNU General Public License v3.0 | 5 votes |
private boolean isAllowed(String id, ItemStack item) throws InterruptedException { Player player = server.addPlayer(); Inventory inv = openMockBackpack(player, id, 9).getInventory(); int slot = 7; inv.setItem(slot, item); InventoryClickEvent event = new InventoryClickEvent(player.getOpenInventory(), SlotType.CONTAINER, slot, ClickType.LEFT, InventoryAction.PICKUP_ONE); listener.onClick(event); return !event.isCancelled(); }
Example #12
Source File: MenuEventsTest.java From uSkyBlock with GNU General Public License v3.0 | 5 votes |
private InventoryClickEvent getEvent(InventoryHolder holder) { // These values are not checked anywhere. InventoryView inventoryView = mock(InventoryView.class); InventoryType.SlotType slotType = InventoryType.SlotType.QUICKBAR; ClickType clickType = ClickType.LEFT; InventoryAction inventoryAction = InventoryAction.NOTHING; Inventory fakeInventory = mock(Inventory.class); doReturn(holder).when(fakeInventory).getHolder(); doReturn(fakeInventory).when(inventoryView).getTopInventory(); return new InventoryClickEvent(inventoryView, slotType, 1, clickType, inventoryAction); }
Example #13
Source File: CrateControl.java From Crazy-Crates with MIT License | 5 votes |
@EventHandler public void onAdminMenuClick(InventoryClickEvent e) { Inventory inv = e.getInventory(); Player player = (Player) e.getWhoClicked(); if (inv != null && e.getView().getTitle().equals(Methods.sanitizeColor("&4&lAdmin Keys"))) { e.setCancelled(true); if (!Methods.permCheck(player, "admin")) { player.closeInventory(); return; } //Added the >= due to an error about a raw slot set at -999. if (e.getRawSlot() < inv.getSize() && e.getRawSlot() >= 0) {//Clicked in the admin menu. ItemStack item = inv.getItem(e.getRawSlot()); if (cc.isKey(item)) { Crate crate = cc.getCrateFromKey(item); if (e.getAction() == InventoryAction.PICKUP_ALL) { player.getInventory().addItem(crate.getKey()); } else if (e.getAction() == InventoryAction.PICKUP_HALF) { cc.addKeys(1, player, crate, KeyType.VIRTUAL_KEY); String name = null; ItemStack key = crate.getKey(); if (key.hasItemMeta() && key.getItemMeta().hasDisplayName()) { name = key.getItemMeta().getDisplayName(); } player.sendMessage(Methods.getPrefix() + Methods.color("&a&l+1 " + (name != null ? name : crate.getName()))); } } } } }
Example #14
Source File: DuctSettingsInventory.java From Transport-Pipes with MIT License | 5 votes |
@EventHandler public void onInvClick(InventoryClickEvent e) { if (e.getInventory() != null && e.getInventory().equals(inv) && e.getWhoClicked() instanceof Player) { if (itemService.isItemWildcardOrBarrier(e.getCurrentItem())) { e.setCancelled(true); return; } //don't call click method when double clicked, because before a double click, left click was already registered twice if (e.getClick() != ClickType.DOUBLE_CLICK && click((Player) e.getWhoClicked(), e.getRawSlot(), e.getClick())) { e.setCancelled(true); } else if (e.getClick() == ClickType.DOUBLE_CLICK && e.getAction() == InventoryAction.COLLECT_TO_CURSOR && collect_to_cursor((Player) e.getWhoClicked(), e.getCursor(), e.getRawSlot())) { e.setCancelled(true); } } }
Example #15
Source File: ItemTransferListener.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void collectToCursor(InventoryClickEvent event) { // If this hasn't been cancelled yet, cancel it so our implementation can take over if(event.getAction() == InventoryAction.COLLECT_TO_CURSOR) { event.setCancelled(true); this.collectToCursor = true; } }
Example #16
Source File: ListenerMenuAction.java From TrMenu with MIT License | 4 votes |
@EventHandler(priority = EventPriority.HIGHEST) public void onClick(InventoryClickEvent e) { Player p = (Player) e.getWhoClicked(); Notifys.debug(p, "Clicked raw slot §f{0}", e.getRawSlot()); long start = System.currentTimeMillis(); if (e.isCancelled() && TrMenu.SETTINGS.getBoolean("OPTIONS.IGNORE-CANCELLED")) { Notifys.debug(p, "Ignored cancelled"); return; } if (!(e.getInventory().getHolder() instanceof MenuHolder)) { Notifys.debug(p, "Not a MenuHolder"); return; } Menu menu = ((MenuHolder) e.getInventory().getHolder()).getMenu(); Button button = menu.getButton(p, e.getRawSlot()); // Anti ClickSpam clickTimes.putIfAbsent(p.getUniqueId(), 0L); if (System.currentTimeMillis() - clickTimes.get(p.getUniqueId()) < TrMenu.SETTINGS.getLong("OPTIONS.ANTI-CLICK-SPAM")) { e.setCancelled(true); Notifys.debug(p, "Anti-Spam, event cancelled."); return; } else { clickTimes.put(p.getUniqueId(), System.currentTimeMillis()); } if (e.getAction() == InventoryAction.MOVE_TO_OTHER_INVENTORY || e.getAction() == InventoryAction.HOTBAR_SWAP) { e.setCancelled(true); } // Lock PLayer's Inventory if (button == null) { if (e.getClickedInventory() == p.getInventory() && menu.isLockPlayerInv()) { e.setCancelled(true); } Notifys.debug(p, "Null button"); return; } else { e.setCancelled(true); } button.getIcon(p).onClick(p, button, e.getClick(), e); Notifys.debug(p, "§6InventoryClickEvent Took §e{0}ms§6.", System.currentTimeMillis() - start); }
Example #17
Source File: InventoryActions.java From Skript with GNU General Public License v3.0 | 4 votes |
public static String toString(final InventoryAction action, final int flags) { return util.toString(action, flags); }
Example #18
Source File: InventoryActions.java From Skript with GNU General Public License v3.0 | 4 votes |
public static @Nullable InventoryAction parse(String s) { return util.parse(s); }
Example #19
Source File: ExprInventoryAction.java From Skript with GNU General Public License v3.0 | 4 votes |
public ExprInventoryAction() { super(InventoryAction.class); }
Example #20
Source File: Recipes.java From ProRecipes with GNU General Public License v2.0 | 4 votes |
public void callClick(int slot, InventoryView i){ InventoryClickEvent event = new InventoryClickEvent(i, InventoryType.SlotType.CONTAINER, slot, ClickType.RIGHT, InventoryAction.UNKNOWN); ProRecipes.getPlugin().getServer().getPluginManager().callEvent(event); }
Example #21
Source File: Recipes.java From ProRecipes with GNU General Public License v2.0 | 4 votes |
public void fixCancel(final InventoryClickEvent event){ //First try right here event.setCancelled(true); //System.out.println("BEING CANCELLED"); //Need to know if picking up item switch(event.getAction()){ case COLLECT_TO_CURSOR: case PICKUP_ALL: case PICKUP_HALF: case PICKUP_ONE: case PICKUP_SOME: case HOTBAR_SWAP: case HOTBAR_MOVE_AND_READD: final ItemStack pickedup = event.getCursor().clone(); final int slot = event.getSlot(); //Need to know what item picked up, where it was picked up from //Reset item, take off of cursor ProRecipes.getPlugin().getServer().getScheduler().runTaskLater(ProRecipes.getPlugin(), new Runnable(){ @Override public void run() { event.getWhoClicked().setItemOnCursor(null); event.getInventory().setItem(slot, pickedup); resetBorders(event.getInventory()); } }, 0); return; case PLACE_ONE: case PLACE_SOME: case PLACE_ALL: case UNKNOWN: case DROP_ALL_CURSOR: case DROP_ALL_SLOT: case DROP_ONE_CURSOR: case DROP_ONE_SLOT: case MOVE_TO_OTHER_INVENTORY: case SWAP_WITH_CURSOR: //System.out.println("SOMETHING DROPPED"); final ItemStack dropped = event.getCurrentItem().clone(); //System.out.println(dropped.getType()); final ItemStack swapped = event.getCursor().clone(); final int s = event.getSlot(); ProRecipes.getPlugin().getServer().getScheduler().runTaskLater(ProRecipes.getPlugin(), new Runnable(){ @Override public void run() { if(swapped != null && event.getAction().equals(InventoryAction.SWAP_WITH_CURSOR)){ //there was a swap event.getWhoClicked().setItemOnCursor(dropped); event.getInventory().setItem(s, swapped); }else if(swapped != null && dropped != null && !swapped.getType().equals(Material.AIR)){ if(swapped.isSimilar(dropped)){ // System.out.println("Is similar"); event.getInventory().setItem(s, null); ItemStack t = dropped.clone(); t.setAmount(dropped.getAmount() + swapped.getAmount()); event.getWhoClicked().setItemOnCursor(t); } }else{ //System.out.println("else"); event.getInventory().setItem(s, null); event.getWhoClicked().setItemOnCursor(dropped); } } }, 0); return; } //Need to know if dropping item(s) //This isn't as much of a problem (Come back later if it is) }
Example #22
Source File: StoreListener.java From skRayFall with GNU General Public License v3.0 | 4 votes |
/** * See if a store/unstore event is possible through items being moved into an inventory. Then * Storing the value in a array list while the inventory is open. * * @param evt The InventoryClickEvent used to check item movement */ @EventHandler public void onStoringFilter(InventoryClickEvent evt) { if (evt.getAction() == InventoryAction.SWAP_WITH_CURSOR || evt.getAction() == InventoryAction.COLLECT_TO_CURSOR || evt.getAction() == InventoryAction.PICKUP_SOME || evt.getAction() == InventoryAction.PICKUP_HALF || evt.getAction() == InventoryAction.PICKUP_ALL || evt.getAction() == InventoryAction.PICKUP_ONE) { if (evt.getClickedInventory().getType() != null && evt.getView().getBottomInventory().getType() == InventoryType.PLAYER && (evt.getView().getTopInventory().getType() == InventoryType.CHEST || evt.getView().getTopInventory().getType() == InventoryType.ENDER_CHEST || evt.getView().getTopInventory().getType() == InventoryType.HOPPER || evt.getView().getTopInventory().getType() == InventoryType.DISPENSER || evt.getView().getTopInventory().getType() == InventoryType.DROPPER) && evt.getClickedInventory().getType() == InventoryType.PLAYER && (!(storePossible.contains(evt.getWhoClicked())))) { storePossible.add((Player) evt.getWhoClicked()); if (unstorePossible.contains(evt.getWhoClicked())) { unstorePossible.remove(evt.getWhoClicked()); } } if (evt.getClickedInventory().getType() != null && evt.getView().getBottomInventory().getType() == InventoryType.PLAYER && (evt.getView().getTopInventory().getType() == InventoryType.CHEST || evt.getView().getTopInventory().getType() == InventoryType.ENDER_CHEST || evt.getView().getTopInventory().getType() == InventoryType.HOPPER || evt.getView().getTopInventory().getType() == InventoryType.DISPENSER || evt.getView().getTopInventory().getType() == InventoryType.DROPPER) && (evt.getClickedInventory().getType() == InventoryType.CHEST || evt.getClickedInventory().getType() == InventoryType.ENDER_CHEST || evt.getClickedInventory().getType() == InventoryType.HOPPER || evt.getClickedInventory().getType() == InventoryType.DISPENSER || evt.getClickedInventory().getType() == InventoryType.DROPPER) && (!(unstorePossible.contains(evt.getWhoClicked())))) { unstorePossible.add((Player) evt.getWhoClicked()); if (storePossible.contains(evt.getWhoClicked())) { storePossible.remove(evt.getWhoClicked()); } } } }
Example #23
Source File: InventoryGui.java From InventoryGui with MIT License | 4 votes |
@EventHandler private void onInventoryClick(InventoryClickEvent event) { if (event.getInventory().equals(getInventory(event.getWhoClicked()))) { int slot = -1; if (event.getRawSlot() < event.getView().getTopInventory().getSize()) { slot = event.getRawSlot(); } else if (event.getAction() == InventoryAction.MOVE_TO_OTHER_INVENTORY) { slot = event.getInventory().firstEmpty(); } GuiElement.Action action = null; GuiElement element = null; if (slot >= 0) { element = getElement(slot); if (element != null) { action = element.getAction(event.getWhoClicked()); } } else if (slot == -999) { action = outsideAction; } else { // Click was neither for the top inventory or outside // E.g. click is in the bottom inventory if (event.getAction() == InventoryAction.COLLECT_TO_CURSOR) { simulateCollectToCursor(new GuiElement.Click(gui, slot, null, event.getClick(), event)); } return; } try { if (action == null || action.onClick(new GuiElement.Click(gui, slot, element, event.getClick(), event))) { event.setCancelled(true); if (event.getWhoClicked() instanceof Player) { ((Player) event.getWhoClicked()).updateInventory(); } } if (action != null) { // Let's assume something changed and re-draw all currently shown inventories for (UUID playerId : inventories.keySet()) { if (!event.getWhoClicked().getUniqueId().equals(playerId)) { Player player = plugin.getServer().getPlayer(playerId); if (player != null) { draw(player); } } } } } catch (Throwable t) { event.setCancelled(true); if (event.getWhoClicked() instanceof Player) { ((Player) event.getWhoClicked()).updateInventory(); } plugin.getLogger().log(Level.SEVERE, "Exception while trying to run action for click on " + (element != null ? element.getClass().getSimpleName() : "empty element") + " in slot " + event.getRawSlot() + " of " + gui.getTitle() + " GUI!"); t.printStackTrace(); } } else if (hasRealOwner() && owner.equals(event.getInventory().getHolder())) { // Click into inventory by same owner but not the inventory of the GUI // Assume that the underlying inventory changed and redraw the GUI plugin.getServer().getScheduler().runTask(plugin, (Runnable) gui::draw); } }
Example #24
Source File: MenuStored.java From TabooLib with MIT License | 4 votes |
public void onClick(ClickEvent e) { if (e.getClickType() == ClickType.CLICK) { // 自动装填 if (e.castClick().getClick().isShiftClick() && e.getRawSlot() >= e.getInventory().getSize() && Items.nonNull(e.getCurrentItem())) { e.setCancelled(true); // 获取有效位置 int validSlot = getIntoSlot(e.getInventory(), e.getCurrentItem()); if (validSlot >= 0) { // 设置物品 intoItem(e.getInventory(), e.getCurrentItem(), validSlot); // 移除物品 e.setCurrentItem(null); onClicked(); } } // 手动装填 else { // todo 合并物品 if (e.castClick().getAction() == InventoryAction.COLLECT_TO_CURSOR) { e.setCancelled(true); return; } Action action; if (e.castClick().getClick().isShiftClick() && e.getRawSlot() >= 0 && e.getRawSlot() < e.getInventory().getSize()) { action = new ActionQuickTake(); } else if (e.castClick().getClick() == org.bukkit.event.inventory.ClickType.NUMBER_KEY) { action = new ActionKeyboard(); } else { action = new ActionClick(); } // 点击有效位置 if (isIntoSlot(e.getInventory(), action.getCurrent(e), action.getCurrentSlot(e))) { e.setCancelled(true); // 提取动作 if (Items.isNull(action.getCurrent(e)) && existsItem(e.getInventory(), action.getCurrentSlot(e))) { // 提取物品 action.setCurrent(e, getItem(e.getInventory(), action.getCurrentSlot(e))); // 删除物品 intoItem(e.getInventory(), null, action.getCurrentSlot(e)); onClicked(); } // 合法的位置 else if (shouldIntoSlot(e.getInventory(), action.getCurrent(e), action.getCurrentSlot(e))) { ItemStack current = action.getCurrent(e); // 提取物品 action.setCurrent(e, getItem(e.getInventory(), action.getCurrentSlot(e))); // 写入物品 intoItem(e.getInventory(), current, action.getCurrentSlot(e)); onClicked(); } } } } }