Java Code Examples for org.bukkit.event.inventory.InventoryClickEvent#setCancelled()
The following examples show how to use
org.bukkit.event.inventory.InventoryClickEvent#setCancelled() .
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: BackpackListener.java From Slimefun4 with GNU General Public License v3.0 | 6 votes |
@EventHandler(ignoreCancelled = true) public void onClick(InventoryClickEvent e) { ItemStack item = backpacks.get(e.getWhoClicked().getUniqueId()); if (item != null) { SlimefunItem backpack = SlimefunItem.getByItem(item); if (backpack instanceof SlimefunBackpack) { if (e.getClick() == ClickType.NUMBER_KEY) { if (e.getClickedInventory().getType() != InventoryType.PLAYER) { ItemStack hotbarItem = e.getWhoClicked().getInventory().getItem(e.getHotbarButton()); if (!isAllowed((SlimefunBackpack) backpack, hotbarItem)) { e.setCancelled(true); } } } else if (!isAllowed((SlimefunBackpack) backpack, e.getCurrentItem())) { e.setCancelled(true); } } } }
Example 2
Source File: BuyingPlayerShopkeeper.java From Shopkeepers with GNU General Public License v3.0 | 6 votes |
@Override protected void onInventoryClick(InventoryClickEvent event, Player player) { event.setCancelled(true); int slot = event.getRawSlot(); if (slot >= 0 && slot <= 7) { // modifying cost: ItemStack tradedItem = event.getInventory().getItem(slot + 18); if (Utils.isEmpty(tradedItem)) return; this.handleUpdateTradeCostItemOnClick(event, Settings.createCurrencyItem(1), Settings.createZeroCurrencyItem()); } else if (slot >= 18 && slot <= 25) { // modifying bought item quantity: this.handleUpdateItemAmountOnClick(event, 1); } else if (slot >= 9 && slot <= 16) { } else { super.onInventoryClick(event, player); } }
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: Carried.java From PGM with GNU Affero General Public License v3.0 | 6 votes |
@Override public void onEvent(InventoryClickEvent event) { super.onEvent(event); if (this.isCarrier(event.getWhoClicked()) && event.getSlot() == ArmorType.HELMET.inventorySlot()) { event.setCancelled(true); event.getView().setCursor(null); event.setCurrentItem(null); this.flag .getMatch() .getExecutor(MatchScope.RUNNING) .execute( () -> { if (isCurrent()) dropFlag(); }); } }
Example 5
Source File: BorderColorGUI.java From IridiumSkyblock with GNU General Public License v2.0 | 6 votes |
@EventHandler public void onInventoryClick(InventoryClickEvent e) { if (e.getInventory().equals(getInventory())) { e.setCancelled(true); if (e.getClickedInventory() == null || !e.getClickedInventory().equals(getInventory())) return; if (e.getCurrentItem() != null) { if (e.getCurrentItem().equals(blue)) IridiumSkyblock.getIslandManager().getIslandViaId(islandID).setBorderColor(Color.Blue); if (e.getCurrentItem().equals(red)) IridiumSkyblock.getIslandManager().getIslandViaId(islandID).setBorderColor(Color.Red); if (e.getCurrentItem().equals(green)) IridiumSkyblock.getIslandManager().getIslandViaId(islandID).setBorderColor(Color.Green); if (e.getCurrentItem().equals(off)) IridiumSkyblock.getIslandManager().getIslandViaId(islandID).setBorderColor(Color.Off); IridiumSkyblock.getIslandManager().getIslandViaId(islandID).sendBorder(); } } }
Example 6
Source File: InventoryForVillagerOffers.java From NBTEditor with GNU General Public License v3.0 | 6 votes |
@Override protected void inventoryClick(InventoryClickEvent event) { super.inventoryClick(event); int slot = event.getRawSlot(); if (slot >= 27 && slot < getInventory().getSize()) { event.setCancelled(true); } if (slot >= 27 && slot < 36) { changeSelected(slot - 27); } else if (slot == 43) { // xp reward _rewardExp[_selected] = !_rewardExp[_selected]; updateBottleButton(); updateWoolButton(); } else if (slot == 44) { // previous page changeIndex(event.getWhoClicked(), -9); } else if (slot == 53) { // next page changeIndex(event.getWhoClicked(), +9); } else { handlePaperButtons(_uses, 36, slot); handlePaperButtons(_maxUses, 45, slot); } }
Example 7
Source File: ExhibitionListener.java From NyaaUtils with MIT License | 6 votes |
@EventHandler(priority = HIGHEST, ignoreCancelled = true) public void onPlayerFetchItem(InventoryClickEvent ev) { if (!(ev.getWhoClicked() instanceof Player)) return; if (ExhibitionFrame.isFrameInnerItem(ev.getCursor())) { plugin.getLogger().warning( String.format("Illegal Exhibition Item use: {player: %s, location: %s, item: %s}", ev.getWhoClicked().getName(), ev.getWhoClicked().getLocation().toString(), ev.getCursor().toString())); ev.setCancelled(true); ev.getView().setCursor(new ItemStack(Material.AIR)); } if (ExhibitionFrame.isFrameInnerItem(ev.getCurrentItem())) { plugin.getLogger().warning( String.format("Illegal Exhibition Item use: {player: %s, location: %s, item: %s}", ev.getWhoClicked().getName(), ev.getWhoClicked().getLocation().toString(), ev.getCursor().toString())); ev.setCancelled(true); ev.setCurrentItem(new ItemStack(Material.AIR)); } }
Example 8
Source File: MenuHandler.java From EnchantmentsEnhance with GNU General Public License v3.0 | 5 votes |
@EventHandler(ignoreCancelled = false, priority = EventPriority.HIGHEST) public void onClick(InventoryClickEvent e) { // Handles invalid clicks. if (e.getSlot() < 0) { return; } // Handles invalid entity. if (!(e.getWhoClicked() instanceof Player)) { return; } // Handles empty slot. if (e.getCurrentItem() != null && e.getCurrentItem().getType() == (Material.AIR)) { return; } Player player = (Player) e.getWhoClicked(); String playerName = player.getName(); GUIAbstract gui = GUIManager.getMap().get(playerName); if (gui != null && gui.getInventory().equals(e.getInventory())) { e.setCancelled(true); if (!MainMenu.itemOnEnhancingSlot.containsKey(playerName) && MainMenu.enhancingMode.containsKey(playerName)) { if (MainMenu.enhancingMode.get(playerName).equals(MainMenu.gear)) { if (Enhance.getValidationOfItem(e.getCurrentItem()) && e.getRawSlot() >= 54) { MainMenu.itemOnEnhancingSlot.put(playerName, e.getCurrentItem()); gui.update(); } } else if (MainMenu.enhancingMode.get(playerName).equals(MainMenu.tool)) { if (Enhance.getValidationOfToolItem(e.getCurrentItem()) && e.getRawSlot() >= 54) { MainMenu.itemOnEnhancingSlot.put(playerName, e.getCurrentItem()); gui.update(); } } } } }
Example 9
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 10
Source File: Label.java From IF with The Unlicense | 5 votes |
@Override public boolean click(@NotNull Gui gui, @NotNull InventoryClickEvent event, int paneOffsetX, int paneOffsetY, int maxLength, int maxHeight) { event.setCancelled(true); return super.click(gui, event, paneOffsetX, paneOffsetY, maxLength, maxHeight); }
Example 11
Source File: MissionsGUI.java From IridiumSkyblock with GNU General Public License v2.0 | 5 votes |
@EventHandler @Override public void onInventoryClick(InventoryClickEvent e) { if (e.getInventory().equals(getInventory())) { e.setCancelled(true); } }
Example 12
Source File: ItemSharingAndLockingListener.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onInventoryClick(final InventoryClickEvent event) { if(event instanceof InventoryCreativeEvent) return;; // Ensure the player is clicking in their own inventory // TODO: should we allow items to be locked into other types of inventories? if(!Objects.equals(event.getWhoClicked(), event.getInventory().getHolder())) return; // Break out of the switch if the action will move a locked item, otherwise return switch(event.getAction()) { case HOTBAR_SWAP: case HOTBAR_MOVE_AND_READD: // These actions can move up to two stacks. Check the hotbar stack, // and then fall through to check the stack under the cursor. if(isLocked(Slot.Hotbar.forPosition(event.getHotbarButton()) .getItem(event.getWhoClicked().getInventory()))) break; // fall through case PICKUP_ALL: case PICKUP_HALF: case PICKUP_SOME: case PICKUP_ONE: case SWAP_WITH_CURSOR: case MOVE_TO_OTHER_INVENTORY: case DROP_ONE_SLOT: case DROP_ALL_SLOT: case COLLECT_TO_CURSOR: // All these actions move only a single stack, except COLLECT_TO_CURSOR, // which can only move items that are stackable with the one under the cursor, // and locked items are only stackable with other locked items. if(isLocked(event.getCurrentItem())) break; // fall through default: return; } event.setCancelled(true); sendLockWarning(event.getWhoClicked()); }
Example 13
Source File: MenuListener.java From AmpMenus with GNU Lesser General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onInventoryClick(InventoryClickEvent event) { if (event.getWhoClicked() instanceof Player && event.getInventory().getHolder() instanceof MenuHolder) { event.setCancelled(true); ((MenuHolder) event.getInventory().getHolder()).getMenu().onInventoryClick(event); } }
Example 14
Source File: FlagObjective.java From CardinalPGM with MIT License | 5 votes |
@EventHandler public void onInventoryClick(InventoryClickEvent event) { if (isPicker(event.getWhoClicked()) && event.getSlot() == ArmorType.HELMET.getSlot()) { event.setCancelled(true); event.setCurrentItem(null); spawnFlag(); } }
Example 15
Source File: GUIListener.java From EnchantmentsEnhance with GNU General Public License v3.0 | 5 votes |
/** * Prevents item glitched into menu. * * @param e */ @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH) public void onInventoryClick(InventoryClickEvent e) { if ((e.getInventory().getType() != InventoryType.CRAFTING) && (e.getInventory().getType() != InventoryType.PLAYER)) { if ((e.getClick().equals(ClickType.NUMBER_KEY)) && (e.getWhoClicked().getInventory().getItem(e.getHotbarButton()) != null)) { Player player = (Player) e.getWhoClicked(); String playerName = player.getName(); GUIAbstract gui = GUIManager.getMap().get(playerName); if (gui != null && gui.getInventory().equals(e.getInventory())) { e.setCancelled(true); } } } }
Example 16
Source File: BiomesPanel.java From askyblock with GNU General Public License v2.0 | 4 votes |
@EventHandler(priority = EventPriority.LOWEST) public void onInventoryClick(InventoryClickEvent event) { Player player = (Player) event.getWhoClicked(); // The player that // clicked the item UUID playerUUID = player.getUniqueId(); Inventory inventory = event.getInventory(); // The inventory that was // clicked in int slot = event.getRawSlot(); // Check this is the right panel if (inventory.getName() == null || !inventory.getName().equals(plugin.myLocale().biomePanelTitle)) { return; } if (slot == -999) { inventory.clear(); player.closeInventory(); event.setCancelled(true); return; } if (event.getClick().equals(ClickType.SHIFT_RIGHT)) { event.setCancelled(true); inventory.clear(); player.closeInventory(); player.updateInventory(); return; } // Get the list of items for this player List<BiomeItem> thisPanel = biomeItems.get(player.getUniqueId()); if (thisPanel == null) { inventory.clear(); player.closeInventory(); event.setCancelled(true); return; } if (slot >= 0 && slot < thisPanel.size()) { event.setCancelled(true); // plugin.getLogger().info("DEBUG: slot is " + slot); // Do something // Check this player has an island Island island = plugin.getGrid().getIsland(playerUUID); if (island == null) { Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoIsland); return; } // Check ownership if (!island.getOwner().equals(playerUUID)) { Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).levelerrornotYourIsland); return; } if (!plugin.getGrid().playerIsOnIsland(player)) { Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).challengeserrorNotOnIsland); return; } Biome biome = thisPanel.get(slot).getBiome(); if (biome != null) { event.setCancelled(true); if (Settings.useEconomy) { // Check cost double cost = thisPanel.get(slot).getPrice(); if (cost > 0D) { if (!VaultHelper.econ.has(player, Settings.worldName, cost)) { Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).minishopYouCannotAfford.replace("[description]", VaultHelper.econ.format(cost))); return; } else { VaultHelper.econ.withdrawPlayer(player, Settings.worldName, cost); Util.sendMessage(player, ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).biomeYouBought.replace("[cost]", VaultHelper.econ.format(cost))); } } } } inventory.clear(); player.closeInventory(); // Closes the inventory // Actually set the biome Util.sendMessage(player, ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).biomePleaseWait); new SetBiome(plugin, island, biome, player); } return; }
Example 17
Source File: VaultBlacklistListener.java From Guilds with MIT License | 4 votes |
/** * Check if their item is on the vault blacklist * * @param event the click event */ @EventHandler public void onItemClick(InventoryClickEvent event) { // Check if the event was already cancelled before going through this all if (event.isCancelled()) { return; } // get the player who is clicking Player player = (Player) event.getWhoClicked(); // check if they are in the list of open vaults if (!guildHandler.getOpened().contains(player)) return; // get the item clicked ItemStack item = event.getCurrentItem(); // check if null if (item == null) return; // set cancelled if it contains material name event.setCancelled(settingsManager.getProperty(GuildVaultSettings.BLACKLIST_MATERIALS).stream().anyMatch(m -> m.equalsIgnoreCase(item.getType().name()))); // check if event is cancelled, if not, check name if (event.isCancelled()) { guilds.getCommandManager().getCommandIssuer(player).sendInfo(Messages.VAULTS__BLACKLISTED); return; } // Make sure item has item meta if (!item.hasItemMeta()) return; // Check if it has a display name if (item.getItemMeta().hasDisplayName()) { // set cancelled if contains name event.setCancelled(settingsManager.getProperty(GuildVaultSettings.BLACKLIST_NAMES).stream().anyMatch(m -> m.equalsIgnoreCase(ACFBukkitUtil.removeColors(item.getItemMeta().getDisplayName())))); } // check if event is cancelled if (event.isCancelled()) { guilds.getCommandManager().getCommandIssuer(player).sendInfo(Messages.VAULTS__BLACKLISTED); return; } // check if item has lore if (!item.getItemMeta().hasLore()) return; // set cancelled if contains lore List<String> lore = item.getItemMeta().getLore().stream() .map(ACFBukkitUtil::removeColors).collect(Collectors.toList()); // loop through string list for (String check : settingsManager.getProperty(GuildVaultSettings.BLACKLIST_LORES)) { // check if the lore contains it if (!check.equalsIgnoreCase("")) { if (lore.stream().anyMatch(l -> l.contains(check))) { // cancel the event event.setCancelled(true); break; } } } // check if event is cancelled, if not, check name if (event.isCancelled()) { guilds.getCommandManager().getCommandIssuer(player).sendInfo(Messages.VAULTS__BLACKLISTED); } }
Example 18
Source File: BoosterGUI.java From IridiumSkyblock with GNU General Public License v2.0 | 4 votes |
@EventHandler @Override public void onInventoryClick(InventoryClickEvent e) { if (e.getInventory().equals(getInventory())) { Player p = (Player) e.getWhoClicked(); Island island = IridiumSkyblock.getIslandManager().islands.get(islandID); e.setCancelled(true); if (e.getClickedInventory() == null || !e.getClickedInventory().equals(getInventory())) return; if (e.getSlot() == IridiumSkyblock.getBoosters().spawnerBooster.slot && IridiumSkyblock.getBoosters().spawnerBooster.enabled) { if (getIsland().getSpawnerBooster() == 0) { if (Utils.canBuy(p, IridiumSkyblock.getBoosters().spawnerBooster.vaultCost, IridiumSkyblock.getBoosters().spawnerBooster.crystalsCost)) { getIsland().setSpawnerBooster(IridiumSkyblock.getBoosters().spawnerBooster.time); } else { e.getWhoClicked().sendMessage(Utils.color(IridiumSkyblock.getMessages().notEnoughCrystals.replace("%prefix%", IridiumSkyblock.getConfiguration().prefix))); } } else { e.getWhoClicked().sendMessage(Utils.color(IridiumSkyblock.getMessages().spawnerBoosterActive.replace("%prefix%", IridiumSkyblock.getConfiguration().prefix))); } } if (e.getSlot() == IridiumSkyblock.getBoosters().farmingBooster.slot && IridiumSkyblock.getBoosters().farmingBooster.enabled) { if (getIsland().getFarmingBooster() == 0) { if (Utils.canBuy(p, IridiumSkyblock.getBoosters().farmingBooster.vaultCost, IridiumSkyblock.getBoosters().farmingBooster.crystalsCost)) { getIsland().setFarmingBooster(IridiumSkyblock.getBoosters().farmingBooster.time); } else { e.getWhoClicked().sendMessage(Utils.color(IridiumSkyblock.getMessages().notEnoughCrystals.replace("%prefix%", IridiumSkyblock.getConfiguration().prefix))); } } else { e.getWhoClicked().sendMessage(Utils.color(IridiumSkyblock.getMessages().farmingBoosterActive.replace("%prefix%", IridiumSkyblock.getConfiguration().prefix))); } } if (e.getSlot() == IridiumSkyblock.getBoosters().experianceBooster.slot && IridiumSkyblock.getBoosters().experianceBooster.enabled) { if (getIsland().getExpBooster() == 0) { if (Utils.canBuy(p, IridiumSkyblock.getBoosters().experianceBooster.vaultCost, IridiumSkyblock.getBoosters().experianceBooster.crystalsCost)) { getIsland().setExpBooster(IridiumSkyblock.getBoosters().experianceBooster.time); } else { e.getWhoClicked().sendMessage(Utils.color(IridiumSkyblock.getMessages().notEnoughCrystals.replace("%prefix%", IridiumSkyblock.getConfiguration().prefix))); } } else { e.getWhoClicked().sendMessage(Utils.color(IridiumSkyblock.getMessages().expBoosterActive.replace("%prefix%", IridiumSkyblock.getConfiguration().prefix))); } } if (e.getSlot() == IridiumSkyblock.getBoosters().flightBooster.slot && IridiumSkyblock.getBoosters().flightBooster.enabled) { if (getIsland().getFlightBooster() == 0) { if (Utils.canBuy(p, IridiumSkyblock.getBoosters().flightBooster.vaultCost, IridiumSkyblock.getBoosters().flightBooster.crystalsCost)) { getIsland().setFlightBooster(IridiumSkyblock.getBoosters().flightBooster.time); } else { e.getWhoClicked().sendMessage(Utils.color(IridiumSkyblock.getMessages().notEnoughCrystals.replace("%prefix%", IridiumSkyblock.getConfiguration().prefix))); } } else { e.getWhoClicked().sendMessage(Utils.color(IridiumSkyblock.getMessages().flightBoosterActive.replace("%prefix%", IridiumSkyblock.getConfiguration().prefix))); } } } }
Example 19
Source File: NewItemShop.java From BedwarsRel with GNU General Public License v3.0 | 4 votes |
private void handleCategoryInventoryClick(InventoryClickEvent ice, Game game, Player player) { int catSize = this.getCategoriesSize(player); int sizeCategories = this.getInventorySize(catSize) + 9; int rawSlot = ice.getRawSlot(); if (rawSlot >= this.getInventorySize(catSize) && rawSlot < sizeCategories) { ice.setCancelled(true); if (ice.getCurrentItem().getType() == Material.SLIME_BALL) { this.changeToOldShop(game, player); return; } if (ice.getCurrentItem().getType() == Material.BUCKET) { game.getPlayerSettings(player).setOneStackPerShift(false); player.playSound(player.getLocation(), SoundMachine.get("CLICK", "UI_BUTTON_CLICK"), Float.valueOf("1.0"), Float.valueOf("1.0")); this.openCategoryInventory(player); return; } else if (ice.getCurrentItem().getType() == Material.LAVA_BUCKET) { game.getPlayerSettings(player).setOneStackPerShift(true); player.playSound(player.getLocation(), SoundMachine.get("CLICK", "UI_BUTTON_CLICK"), Float.valueOf("1.0"), Float.valueOf("1.0")); this.openCategoryInventory(player); return; } } if (rawSlot >= sizeCategories) { if (ice.isShiftClick()) { ice.setCancelled(true); return; } ice.setCancelled(false); return; } MerchantCategory clickedCategory = this.getCategoryByMaterial(ice.getCurrentItem().getType()); if (clickedCategory == null) { if (ice.isShiftClick()) { ice.setCancelled(true); return; } ice.setCancelled(false); return; } this.openBuyInventory(clickedCategory, player, game); }
Example 20
Source File: LootGUI.java From EliteMobs with GNU General Public License v3.0 | 2 votes |
@EventHandler public void onClick(InventoryClickEvent event) { if (event.getInventory().getName().equalsIgnoreCase(shopName)) { if (event.getCurrentItem() == null || event.getCurrentItem().getType().equals(Material.AIR)) { event.setCancelled(true); return; } String itemDisplayName = event.getCurrentItem().getItemMeta().getDisplayName(); Player player = (Player) event.getWhoClicked(); if (itemDisplayName != null) { if (itemDisplayName.equals("Next Loot Page")) { currentLootPage++; lootGUI(player); } else if (itemDisplayName.equals("Previous Loot Page")) { if (currentLootPage > 1) { currentLootPage--; lootGUI(player); } } else if (itemDisplayName.equals("Next Item Ranks")) { currentHeaderPage++; lootGUI(player); } else if (itemDisplayName.equals("Previous Item Ranks")) { if (currentHeaderPage > 1) { currentHeaderPage--; lootGUI(player); } } else if (itemDisplayName.equals("EliteMobs by MagmaGuy")) { filter = false; currentLootPage = 1; lootGUI(player); } else if (event.getCurrentItem().getItemMeta().getLore().get(0).equals("Filter by items of this rank.")) { filter = true; String[] lore = itemDisplayName.split("\\s"); filterRank = Integer.valueOf(lore[1]); currentLootPage = 1; lootGUI(player); } } if (lootSlots.contains(event.getSlot())) { player.getInventory().addItem(event.getCurrentItem()); } event.setCancelled(true); } }