@Override public MCInventoryAction getAction() { return BukkitMCInventoryAction.getConvertor().getAbstractedEnum(ic.getAction()); }
@EventHandler public void onOffhandInventoryClick(InventoryClickEvent e) { if (e.getInventory().getType() != InventoryType.CRAFTING || e.getSlotType() != InventoryType.SlotType.QUICKBAR || e.getSlot() != 40) return; if (!(e.getWhoClicked() instanceof Player)) return; Player player = (Player) e.getWhoClicked(); ItemStack currentIs = e.getCurrentItem(); ItemStack cursorIs = e.getCursor(); RPGItem currentItem = ItemManager.toRPGItem(currentIs).orElse(null); RPGItem cursorItem = ItemManager.toRPGItem(cursorIs).orElse(null); if (currentItem != null && (e.getAction() == InventoryAction.PICKUP_SOME || e.getAction() == InventoryAction.PICKUP_ALL || e.getAction() == InventoryAction.PICKUP_ONE || e.getAction() == InventoryAction.PICKUP_HALF || e.getAction() == InventoryAction.DROP_ALL_SLOT || e.getAction() == InventoryAction.DROP_ONE_CURSOR)) { Boolean cont = currentItem.power(player, currentIs, e, Trigger.PICKUP_OFF_HAND); if (!cont) e.setCancelled(true); } if (cursorItem != null && (e.getAction() == InventoryAction.PLACE_SOME || e.getAction() == InventoryAction.PLACE_ONE || e.getAction() == InventoryAction.PLACE_ALL)) { Boolean cont = cursorItem.power(player, cursorIs, e, Trigger.PLACE_OFF_HAND); if (!cont) e.setCancelled(true); } }
@EventHandler public void onPlayerInventoryPlace(InventoryClickEvent event) { switch(event.getAction()) { case PLACE_ALL: case PLACE_ONE: case PLACE_SOME: case SWAP_WITH_CURSOR: initMap(event.getCursor()); } }
@EventHandler(priority = EventPriority.LOW) public void onInventoryClick(InventoryClickEvent e) { Player p = (Player) e.getWhoClicked(); if(!inventories.containsKey(p)) return; if(e.getAction() == InventoryAction.COLLECT_TO_CURSOR || e.getAction() == InventoryAction.MOVE_TO_OTHER_INVENTORY || e.getAction() == InventoryAction.NOTHING) { e.setCancelled(true); return; } if(e.getClickedInventory() == p.getOpenInventory().getTopInventory()) { e.setCancelled(true); int row = e.getSlot() / 9; int column = e.getSlot() % 9; if(row < 0 || column < 0) return; SmartInventory inv = inventories.get(p); if(row >= inv.getRows() || column >= inv.getColumns()) return; inv.getListeners().stream() .filter(listener -> listener.getType() == InventoryClickEvent.class) .forEach(listener -> ((InventoryListener<InventoryClickEvent>) listener).accept(e)); contents.get(p).get(row, column).ifPresent(item -> item.run(e)); p.updateInventory(); } }
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onInventoryClickEvent(InventoryClickEvent event) { SkillUtils.removeAbilityBuff(event.getCurrentItem()); if (event.getAction() == InventoryAction.HOTBAR_SWAP) { SkillUtils.removeAbilityBuff(event.getWhoClicked().getInventory().getItem(event.getHotbarButton())); } }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onClick(InventoryClickEvent e) { if (!(e.getInventory().getHolder() instanceof MenuBuilderHolder)) { return; } MenuBuilderHolder holder = (MenuBuilderHolder) e.getInventory().getHolder(); if (holder.isLock() || e.getAction() == InventoryAction.COLLECT_TO_CURSOR) { e.setCancelled(true); } Optional.ofNullable(holder.getItems().get(e.getRawSlot())).ifPresent(item -> { if (item.getCallable() != null) { item.getCallable().call(new MenuBuilderEvent(e, (Player) e.getWhoClicked(), e.getCurrentItem(), e.getRawSlot())); } }); }
@EventHandler(ignoreCancelled = true) public void onPerceptionFilterRemove(InventoryClickEvent event) { if (event.getInventory().getType().equals(InventoryType.CRAFTING)) { int slot = event.getRawSlot(); if (slot >= 0 && slot == 6) { ItemStack is = event.getCurrentItem(); if (is != null) { if (is.hasItemMeta()) { ItemMeta im = is.getItemMeta(); if (im.hasDisplayName() && im.getDisplayName().equals("Perception Filter")) { if (event.getAction().equals(InventoryAction.PICKUP_ALL)) { plugin.getFilter().removePerceptionFilter((Player) event.getWhoClicked()); } } } } } } } }
InventoryAction action = event.getAction(); if (context != null)
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onInventoryClick(InventoryClickEvent event) { if (event.getRawSlot() < 0 || event.getRawSlot() > 2 || event.getCurrentItem() == null || event.getCurrentItem().getType() == Material.AIR || event.getAction() == InventoryAction.NOTHING || event.getClick() == ClickType.NUMBER_KEY && event.getAction() == InventoryAction.HOTBAR_MOVE_AND_READD) { return;
Inventory inv = event.getInventory(); int slot = event.getRawSlot(); if (inv.getType().equals(InventoryType.WORKBENCH) && slot < 10 && actions.contains(event.getAction())) { plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> { if (checkSlots(inv)) {
inv.setItem(i, null); if (!event.getAction().equals(InventoryAction.MOVE_TO_OTHER_INVENTORY)) { player.setItemOnCursor(is); crafters.remove(uuid);
@Override public void clicked(InventoryClickEvent event) { InventoryAction action = event.getAction(); if (action == InventoryAction.NOTHING) { int direction = event.getClick() == ClickType.LEFT ? 1 : -1; boolean isHotbar = event.getAction() == InventoryAction.HOTBAR_SWAP || event.getAction() == InventoryAction.HOTBAR_MOVE_AND_READD; if (isHotbar) { ItemStack destinationItem = inventory.getItem(event.getHotbarButton());
final InventoryData data = pData.getGenericInstance(InventoryData.class); final int slot = event.getSlot(); final String inventoryAction = hasInventoryAction ? event.getAction().name() : null; if (pData.isDebugActive(checkType)) { outputDebugInventoryClick(player, slot, event, inventoryAction, data);
switch (event.getAction()) { case MOVE_TO_OTHER_INVENTORY: item = event.getCurrentItem();
InventoryAction action = event.getAction(); InventoryType inventoryType = event.getInventory().getType(); boolean isPlayerInventory = inventoryType == InventoryType.CRAFTING || inventoryType == InventoryType.PLAYER; if (event.getAction() == InventoryAction.MOVE_TO_OTHER_INVENTORY && clickedSpell && clickedWearable) boolean isHotbar = event.getAction() == InventoryAction.HOTBAR_SWAP || event.getAction() == InventoryAction.HOTBAR_MOVE_AND_READD; if (isHotbar && event.getSlotType() == InventoryType.SlotType.ARMOR) if (event.getAction() == InventoryAction.MOVE_TO_OTHER_INVENTORY && clickedItem != null) || (isChestInventory && inventoryType == InventoryType.CHEST)) { if (activeWand.isInventoryOpen()) { if (event.getAction() == InventoryAction.NOTHING) { int direction = event.getClick() == ClickType.LEFT ? 1 : -1; activeWand.cycleInventory(direction);
ItemStack current = event.getCurrentItem(); Inventory anvilInventory = event.getInventory(); InventoryAction action = event.getAction(); ItemStack firstItem = anvilInventory.getItem(0); ItemStack secondItem = anvilInventory.getItem(1);
if(e.getAction().equals(InventoryAction.HOTBAR_SWAP) || numberkey) method = EquipMethod.HOTBAR_SWAP;