@Override public MCSlotType getSlotType() { return MCSlotType.valueOf(ic.getSlotType().name()); }
@Override public void clicked(InventoryClickEvent event) { int slot = event.getRawSlot(); event.setCancelled(true); if (event.getSlotType() == InventoryType.SlotType.CONTAINER) { target = entities.get(slot); Entity entity = target != null ? target.get() : null; if (entity != null) { Mage mage = actionContext.getMage(); mage.deactivateGUI(); actionContext.setTargetEntity(entity); actionContext.setTargetLocation(entity.getLocation()); actionContext.playEffects("entity_selected"); } entities.clear(); active = false; } }
@Override public void clicked(InventoryClickEvent event) { int slot = event.getRawSlot(); event.setCancelled(true); if (event.getSlotType() == InventoryType.SlotType.CONTAINER) { target = players.get(slot); Player player = target != null ? target.get() : null; if (player != null) { Mage mage = actionContext.getMage(); mage.deactivateGUI(); actionContext.setTargetEntity(player); actionContext.setTargetLocation(player.getLocation()); actionContext.playEffects("player_selected"); } players.clear(); active = false; } }
@EventHandler(priority=EventPriority.LOW) public void onShiftCrafting(InventoryClickEvent event) { if (event.getSlotType() == SlotType.RESULT && event.getClick().equals(ClickType.SHIFT_LEFT) && event.getWhoClicked() instanceof Player) { Player player = (Player) event.getWhoClicked(); String playerID = PlayerConverter.getID(player); if (containsPlayer(playerID)) { event.setCancelled(true); } } }
@EventHandler public void onInventoryClick(InventoryClickEvent event) { if (!(event.getWhoClicked() instanceof Player)) return; if (event.isCancelled()) return; InventoryType inventoryType = event.getInventory().getType(); SlotType slotType = event.getSlotType(); // Check for wand clicks to prevent grinding them to dust, or whatever. if (slotType == SlotType.CRAFTING && (inventoryType == InventoryType.CRAFTING || inventoryType == InventoryType.WORKBENCH)) { ItemStack cursor = event.getCursor(); if (Wand.isSpecial(cursor)) { event.setCancelled(true); return; } } }
if (BentoBox.getInstance().getSettings().isClosePanelOnClickOutside() && event.getSlotType().equals(SlotType.OUTSIDE)) { event.getWhoClicked().closeInventory(); return;
@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(ignoreCancelled = true) public void onInventoryClick(InventoryClickEvent event) { if (event.isCancelled()) return; if (!(event.getWhoClicked() instanceof Player)) return; InventoryType inventoryType = event.getInventory().getType(); InventoryType.SlotType slotType = event.getSlotType(); ItemStack cursor = event.getCursor(); ItemStack current = event.getCurrentItem(); SettingsManager manager = plugin.getSettingsManager(); if (inventoryType == InventoryType.ANVIL) { // Have to check "current" here as well to avoid shift+clicks if (manager.isMetaFieldType(cursor) || manager.isMetaFieldType(current)) { event.setCancelled(true); } } else if (slotType == InventoryType.SlotType.CRAFTING && (inventoryType == InventoryType.CRAFTING || inventoryType == InventoryType.WORKBENCH)) { if (manager.isMetaFieldType(cursor)) { event.setCancelled(true); } } } }
if (event.getSlotType() == InventoryType.SlotType.CONTAINER)
SlotType slotType = event.getSlotType();
if (event.getSlotType() == InventoryType.SlotType.RESULT) { if (event.getCurrentItem().getType() == null || event.getCurrentItem().getType() == Material.AIR) { return; else if (event.getSlotType() == InventoryType.SlotType.CRAFTING) { PrepareItemCraftEvent e = new PrepareItemCraftEvent(ci, event.getView(), true); Bukkit.getServer().getPluginManager().callEvent(e);
if (event.getSlotType() == InventoryType.SlotType.ARMOR) if (isHotbar && event.getSlotType() == InventoryType.SlotType.ARMOR) if (event.getSlotType() == InventoryType.SlotType.CRAFTING && heldSpell) if (event.getSlotType() == InventoryType.SlotType.ARMOR) { event.setCancelled(true); return;
InventoryType.SlotType slot = event.getSlotType();
numberkey = true; if((e.getSlotType() != SlotType.ARMOR || e.getSlotType() != SlotType.QUICKBAR) && !e.getInventory().getType().equals(InventoryType.CRAFTING)) return;
SlotType slotType = event.getSlotType(); Player player = (Player)event.getWhoClicked(); Mage mage = controller.getMage(player);