@EventHandler(priority = EventPriority.LOWEST) public void onInventoryClickEvent(final InventoryClickEvent event) { if (event.getView().getTopInventory().getType() == InventoryType.PLAYER) { final IUser user = userMap.getUser((Player)event.getWhoClicked()); final InventoryHolder invHolder = event.getView().getTopInventory().getHolder(); if (invHolder != null && invHolder instanceof Player) { final IUser invOwner = userMap.getUser((Player)invHolder); if (user.isInvSee() && (!Permissions.INVSEE_MODIFY.isAuthorized(user) || Permissions.INVSEE_PREVENT_MODIFY.isAuthorized( invOwner) || !invOwner.isOnline())) { event.setCancelled(true); } } } if (event.getView().getTopInventory().getType() == InventoryType.WORKBENCH) { final IUser user = userMap.getUser((Player)event.getWhoClicked()); if (user.isRecipeSee()) { event.setCancelled(true); } } }
public static void debug(InventoryClickEvent event) { System.out.println("===== DEBUG START ====="); System.out.println("event.getAction() " + event.getAction()); System.out.println("event.isLeftClick() " + event.isLeftClick()); System.out.println("event.isRightClick() " + event.isRightClick()); System.out.println("event.isShiftClick() " + event.isShiftClick()); System.out.println("event.getClick() " + event.getClick()); System.out.println("event.getCurrentItem() " + event.getCurrentItem()); System.out.println("event.getCursor() " + event.getCursor()); System.out.println("event.getHotbarButton() " + event.getHotbarButton()); System.out.println("getInventory().getType() " + event.getInventory().getType()); System.out.println("event.getRawSlot() " + event.getRawSlot()); System.out.println("event.getResult() " + event.getResult()); System.out.println("event.getSlot() " + event.getSlot()); System.out.println("event.getSlotType() " + event.getSlotType()); System.out.println( "getView().getTopInventory().getType() " + event.getView().getTopInventory().getType()); System.out.println("getView().getType() " + event.getView().getType()); System.out.println( "getView().getBottomInventory().getType() " + event.getView().getBottomInventory().getType()); System.out.println("event.getWhoClicked() " + event.getWhoClicked()); System.out.println("-----"); System.out.println("isOutside(event) " + isOutside(event)); System.out.println("isTopInventory(event) " + isTopInventory(event)); System.out.println("isBottomInventory(event) " + isBottomInventory(event)); System.out.println("getAlter(event) " + getAlter(event)); System.out.println("isAltering(event) " + isAltering(event)); System.out.println("isEquipping(event) " + isEquipping(event)); System.out.println("===== DEBUG END ====="); }
@SuppressWarnings("deprecation") @EventHandler public void click(InventoryClickEvent event) { Player player = (Player) event.getView().getPlayer(); OpenQuestLog oql = getOpenQuestLog(player); if (oql == null) return; event.setCancelled(true); if (event.getView() != oql.getInventoryView()) { player.updateInventory(); return; } if (event.getCurrentItem() == null) { player.updateInventory(); return; } Quest sel = oql.getSelected(); if (sel == null) { if (event.getSlot() == 27) { oql.setViewingCompleted(!oql.isViewingCompleted()); oql.update(); } else { int index = (oql.getPage() - 1) * 27 + event.getSlot(); Quest[] q = oql.isViewingCompleted() ? oql.getCurrentCompletedList() : oql.getCurrentQuestList(); if (index < q.length) { oql.setSelected(q[index]); oql.update(); } } } else if (event.getSlot() == 27) { oql.setSelected(null); oql.update(); } player.updateInventory(); }
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST) public void onInventoryClick(InventoryClickEvent e) { if (useLocaleInv && e.getView() instanceof LocaleInventory) { LocaleInventory inv = (LocaleInventory) e.getView(); InventoryClickEvent clickEvent = new InventoryClickEvent( inv.getView(), e.getSlotType(), e.getRawSlot(), e.isRightClick(), e.isShiftClick()); Bukkit.getServer().getPluginManager().callEvent(clickEvent); if (clickEvent.isCancelled()) { e.setCancelled(true); } else { switch (clickEvent.getResult()) { case DEFAULT: // Can't really do this with current events case ALLOW: System.out.println("ok..."); System.out.println(inv.getView().getItem(e.getRawSlot())); inv.getView().setItem(e.getRawSlot(), clickEvent.getCursor()); System.out.println(inv.getView().getItem(e.getRawSlot())); break; case DENY: break; } } for (LocaleInventory localeInv : localeInventories) { if (localeInv != inv) localeInv.reload(); } } }
/** * Handles attribute menu interaction * * @param event event details */ @EventHandler public void onClick(InventoryClickEvent event) { // Class selection if (InventoryManager.isMatching(event.getInventory(), MENU_KEY)) { // Do nothing when clicking outside the inventory if (event.getSlot() == -999) { return; } boolean top = event.getRawSlot() < event.getView().getTopInventory().getSize(); AttributeManager manager = SkillAPI.getAttributeManager(); // Interact with the skill tree when clicking in the top region if (top) { if (event.getSlot() < manager.getKeys().size() || event.getCursor() != null) { event.setCancelled(true); PlayerData data = SkillAPI.getPlayerData((Player) event.getWhoClicked()); if (event.isRightClick() && SkillAPI.getSettings().isAttributesDowngrade()) { data.refundAttribute(manager.getKeys().toArray()[event.getSlot()].toString()); } else if (event.isLeftClick()) { Object[] keys = manager.getKeys().toArray(); data.upAttribute(keys[event.getSlot()].toString()); } data.openAttributeMenu(); } } // Do not allow shift clicking items into the inventory else if (event.isShiftClick()) { event.setCancelled(true); } } }
@Override @SuppressWarnings( "deprecation") // Player.updateInventory has been deprecated for a while with no alternative // available yet public void onClick(final InventoryClickEvent click) { final int last = click.getView().getTopInventory().getSize() - 1; // cancel shift clicks on items outside of delivery inventory to prevent indirect moving of // items into delivery inventory if (click.isShiftClick() && (click.getCurrentItem().getTypeId() != Material.AIR.getId()) && (click.getRawSlot() > last)) click.setCancelled(true); // cancel clicks with item on cursor in delivery inventory to prevent direct placement of items // into delivery inventory if ((click.getCursor().getTypeId() != Material.AIR.getId()) && (click.getRawSlot() >= 0) && (click.getRawSlot() <= last)) click.setCancelled(true); if (click.isCancelled()) { click.setCursor(click.getCursor()); ((Player) click.getWhoClicked()).updateInventory(); this.courier.send((Player) click.getWhoClicked(), "withdraw-only"); } }
@EventHandler(priority = EventPriority.NORMAL) public void onInventoryClick(InventoryClickEvent event) { if (!isItemInfoBook(event.getCursor())) { return; } if (!isPlace(event.getAction())) { return; } if (isInventory(event.getInventory())) { return; } if ((event.getRawSlot() - event.getView().getTopInventory().getSize()) >= 0) { return; } Module.sendMessage( "bInfoBooks", (Player) event.getWhoClicked(), "You can't store InfoBooks. Please drop the InfoBook to remove it from your inventory."); Module.sendMessage( "bInfoBooks", (Player) event.getWhoClicked(), "You can get another copy of the book via the '/book' command."); event.setResult(Result.DENY); }
@EventHandler public void onInterfaceInteract(InventoryClickEvent event) { if (event.getView() != this) return; ItemStack itemClicked = event.getCurrentItem(); if (itemClicked == null || itemClicked.getType() == Material.AIR) return; event.setCancelled(true); // If not right or left-click. if (!(event.getClick() == ClickType.RIGHT || event.getClick() == ClickType.LEFT)) return; if (this.ACCEPT_OBJECT.equals(itemClicked)) { onAcceptPressed(); return; } if (this.BACK_OBJECT.equals(itemClicked)) { if (onBackPressed()) scheduleCloseOfInventory(); return; } int rawSlot = event.getRawSlot(); int slotNumber = event.getSlot(); boolean usedTopInv = rawSlot < getTopInventory().getSize(); if (usedTopInv) onSelectionItemPressed(slotNumber, itemClicked); else onControlItemPressed(slotNumber, itemClicked); }
protected static List<Entry<ItemStack, Integer>> getChangesClick(InventoryClickEvent event) { // Create List<Entry<ItemStack, Integer>> ret = new MassiveList<>(); // Fill final InventoryAlter alter = InventoryUtil.getAlter(event); final InventoryAction action = event.getAction(); ItemStack item; int amount; // Give if (alter.isGiving()) { // Special > MOVE_TO_OTHER_INVENTORY if (action == InventoryAction.MOVE_TO_OTHER_INVENTORY) { item = event.getCurrentItem(); ItemStack compare = item.clone(); compare.setAmount(1); amount = InventoryUtil.roomLeft(event.getInventory(), compare, item.getAmount()); } // Special > HOTBAR_SWAP else if (action == InventoryAction.HOTBAR_SWAP) { item = event.getView().getBottomInventory().getItem(event.getHotbarButton()); amount = item.getAmount(); } // Normal else { item = event.getCursor(); amount = item.getAmount(); if (action == InventoryAction.PLACE_ONE) { amount = 1; } else if (action == InventoryAction.PLACE_SOME) { int max = event.getCurrentItem().getType().getMaxStackSize(); amount = max - event.getCurrentItem().getAmount(); } } amount *= -1; ret.add(new SimpleEntry<ItemStack, Integer>(item, amount)); } // Take if (alter.isTaking()) { item = event.getCurrentItem(); amount = item.getAmount(); if (action == InventoryAction.PICKUP_ONE) amount = 1; if (action == InventoryAction.PICKUP_HALF) amount = (int) Math.ceil(amount / 2.0); ret.add(new SimpleEntry<ItemStack, Integer>(item, amount)); } // Return return ret; }
@EventHandler public void onInventoryClickEvent(InventoryClickEvent event) { if ((isEnabled()) && (event.getInventory().getType().equals(InventoryType.BREWING))) { boolean disableSplash = UHCutils.getMainConfig().getBoolean("features.potionNerfs.disableSplash"); boolean disableGlowstone = UHCutils.getMainConfig().getBoolean("features.potionNerfs.disableGlowstone"); if (event.isShiftClick()) { if ((disableSplash) && (event.getCurrentItem().getType().equals(Material.SULPHUR))) cancel(event); if ((disableGlowstone) && (event.getCurrentItem().getType().equals(Material.GLOWSTONE_DUST))) cancel(event); } else if (event.getSlotType().equals(InventoryType.SlotType.FUEL)) { if ((disableSplash) && (event.getView().getCursor().getType().equals(Material.SULPHUR))) cancel(event); if ((disableGlowstone) && (event.getView().getCursor().getType().equals(Material.GLOWSTONE_DUST))) cancel(event); } } }
@EventHandler(priority = EventPriority.HIGHEST) private void preventArmor(InventoryClickEvent evt) { // plugin.getLogger().info(evt.getView().getType().getDefaultTitle()); if (evt.getView().getType() == InventoryType.CRAFTING) { // plugin.getLogger().info("inventory click " + evt.getSlot()); if (evt.getSlot() == 39 || evt.getSlot() == 38 || evt.getSlot() == 37 || evt.getSlot() == 36) { evt.setCancelled(true); } } }
@EventHandler(ignoreCancelled = true) public void onFurnaceInsert(final InventoryClickEvent event) { if (event.getInventory().getType() != InventoryType.FURNACE) { return; } if (event.getRawSlot() == 0 && event.getCursor().getType() != Material.AIR) { if (!validateSmeltingIngredient(event.getCursor())) { event.setCancelled(true); } } else if (event.getRawSlot() >= event.getView().getTopInventory().getSize()) { if (event.getAction() == InventoryAction.MOVE_TO_OTHER_INVENTORY) { if (!validateSmeltingIngredient(event.getCurrentItem()) && !STBUtil.isFuel(event.getCurrentItem().getType())) { event.setCancelled(true); int newSlot = findNewSlot(event); if (newSlot >= 0) { event.getWhoClicked().getInventory().setItem(newSlot, event.getCurrentItem()); event.setCurrentItem(null); } } } } else if (event.getRawSlot() == 2 && SensibleToolbox.getItemRegistry().isSTBItem(event.getCurrentItem())) { // work around CB bug where shift-clicking custom items out of furnace seems // to cause a de-sync, leaving phantom items in the furnace Bukkit.getScheduler() .runTask( plugin, new Runnable() { @Override public void run() { STBUtil.forceInventoryRefresh(event.getInventory()); } }); } }
public static InventoryAlter getAlter(InventoryClickEvent event) { if (isOutside(event)) return InventoryAlter.NONE; boolean topClicked = isTopInventory(event); InventoryAction action = event.getAction(); if (topClicked) { switch (action) { // What is the best thing to do? case UNKNOWN: return InventoryAlter.BOTH; // Possibly both case HOTBAR_SWAP: ItemStack hotbar = event.getView().getBottomInventory().getItem(event.getHotbarButton()); ItemStack current = event.getCurrentItem(); boolean give = isSomething(hotbar); boolean take = isSomething(current); return getAlter(give, take); // Neither give nor take case NOTHING: return InventoryAlter.NONE; case CLONE_STACK: return InventoryAlter.NONE; case DROP_ALL_CURSOR: return InventoryAlter.NONE; case DROP_ONE_CURSOR: return InventoryAlter.NONE; // Take case PICKUP_ALL: return InventoryAlter.TAKE; case PICKUP_HALF: return InventoryAlter.TAKE; case PICKUP_ONE: return InventoryAlter.TAKE; case PICKUP_SOME: return InventoryAlter.TAKE; case MOVE_TO_OTHER_INVENTORY: return InventoryAlter.TAKE; case COLLECT_TO_CURSOR: return InventoryAlter.TAKE; case HOTBAR_MOVE_AND_READD: return InventoryAlter.TAKE; case DROP_ONE_SLOT: return InventoryAlter.TAKE; case DROP_ALL_SLOT: return InventoryAlter.TAKE; // Give case PLACE_ALL: return InventoryAlter.GIVE; case PLACE_ONE: return InventoryAlter.GIVE; case PLACE_SOME: return InventoryAlter.GIVE; case SWAP_WITH_CURSOR: return InventoryAlter.BOTH; } throw new RuntimeException("Unsupported action: " + action); } else { // What is the best thing to do? if (action == InventoryAction.UNKNOWN) return InventoryAlter.BOTH; if (action == InventoryAction.MOVE_TO_OTHER_INVENTORY) return InventoryAlter.GIVE; // This one will possibly take, but we cannot be 100% sure. // We will return TAKE for security reasons. if (action == InventoryAction.COLLECT_TO_CURSOR) return InventoryAlter.TAKE; return InventoryAlter.NONE; } }
// Handles player interaction with anvil while in or out of creative. @SuppressWarnings("deprecation") @EventHandler(priority = EventPriority.NORMAL) public void anvilFix(final InventoryClickEvent e) { if (!e.isCancelled()) { HumanEntity ent = e.getWhoClicked(); // Anvil used with survival if (ent instanceof Player) { final Player player = (Player) ent; Inventory inv = e.getInventory(); // Anvil used with creative: if (player.getGameMode() == GameMode.CREATIVE) { if (inv instanceof AnvilInventory) { AnvilInventory anvil = (AnvilInventory) inv; InventoryView view = e.getView(); int rawSlot = e.getRawSlot(); if (rawSlot == view.convertSlot(rawSlot)) { if (rawSlot == 2) { ItemStack[] items = anvil.getContents(); ItemStack item1 = items[0]; ItemStack item2 = items[1]; if (item1 != null && item2 != null) { int id1 = item1.getTypeId(); int id2 = item2.getTypeId(); if (id1 != 0 && id2 != 0) { ItemStack item3 = e.getCurrentItem(); if (item3 != null) { ItemMeta meta = item3.getItemMeta(); if (meta != null) { // Player has to have 60 or more levels to use the creative combine. if (player.getLevel() >= 60) { player.setLevel(player.getLevel() - 60); player.sendMessage(ChatColor.GREEN + "Repair/Combine Successful!"); Bukkit.getServer() .getScheduler() .scheduleSyncDelayedTask( mobfighter, new Runnable() { public void run() { // Bypass being set to survival after using anvil if the // player has creative immunity. if (mobfighter .getConfig() .getList("Creative Immunity") .contains(player.getDisplayName())) return; // Sets the player back to survival once the anvil is used. e.getWhoClicked().getOpenInventory().close(); player.setGameMode(GameMode.SURVIVAL); } }, 20 * 2); } // End of creative combine. } // Didn't have enough levels to combine/finishing. } // Item 3 was/wasn't null. } // Item 1 & 2 id's were/weren't null. } // Item 1 & 2 was/wasn't null. } // End of (rawSlot == 2) } // End of convert view } // End of anvil inventory else { // Bypass having the player's inventory closed if they have creative immunity. if (mobfighter .getConfig() .getList("Creative Immunity") .contains(player.getDisplayName())) e.setCancelled(false); // Closes the player's inventory after the anvil is used. else { e.setCancelled(true); player.closeInventory(); } } } // End of anvil with creative } // End of anvil with survival } // End of !isCancelled } // End of anvilFix
@EventHandler(priority = EventPriority.HIGHEST) public void inventoryMenu(final InventoryClickEvent event) { // -------Armor wear handling-------- if (event.getSlotType() == SlotType.ARMOR && event.getClick() != ClickType.DOUBLE_CLICK) { CEventHandler.handleArmor( (Player) event.getWhoClicked(), event.getCurrentItem(), true, event); CEventHandler.handleArmor((Player) event.getWhoClicked(), event.getCursor(), false, event); if (event.getCursor() == null) CEventHandler.handleArmor( (Player) event.getWhoClicked(), event.getCurrentItem(), false, event); } else if (event.getClick() == ClickType.SHIFT_LEFT) { ItemStack current = event.getCurrentItem(); String typeS = current.getType().toString(); PlayerInventory inv = event.getWhoClicked().getInventory(); if ((typeS.endsWith("HELMET") && inv.getHelmet() == null) || (typeS.endsWith("CHESTPLATE") && inv.getChestplate() == null) || (typeS.endsWith("LEGGINGS") && inv.getLeggings() == null) || (typeS.endsWith("BOOTS") && inv.getBoots() == null)) CEventHandler.handleArmor( (Player) event.getWhoClicked(), event.getCurrentItem(), false, event); } // --------------------------------- if (event.getCurrentItem() == null || event.getCurrentItem().getType() == Material.AIR || event.getRawSlot() < -1) { return; } if (event.getView().getTopInventory().getTitle().startsWith("CE")) { Inventory topInv = event.getView().getTopInventory(); final Player p = (Player) event.getWhoClicked(); ItemStack clickedItem = event.getCurrentItem(); event.setResult(Result.ALLOW); event.setCancelled(true); // This is the back-button, located in the very last spot of each inventory if ((event.getRawSlot() == topInv.getSize() - 1) && event.getCurrentItem().getType() != Material.AIR) { p.closeInventory(); p.openInventory(Tools.getPreviousInventory(topInv.getTitle())); return; } if (event.getRawSlot() < topInv.getSize()) { // Opens the clicked Enchantments inventory and loads the permissions if needed if (topInv.getTitle().equals(Tools.prefix + "Enchantments")) { p.closeInventory(); p.openInventory(Tools.getEnchantmentMenu(p, clickedItem.getItemMeta().getDisplayName())); return; } // Opens the item inventory and loads the permissions if needed if (topInv.getTitle().equals(Tools.prefix + "Main Menu") && event.getRawSlot() == 4) { p.closeInventory(); p.openInventory(Tools.getItemMenu(p)); return; } // These are the specific menus, clicking one of them will lead to the enchanting menu, // which needs to be 'notified' of the enchantment to give and it's cost if (topInv.getTitle().equals(Tools.prefix + "Global") || topInv.getTitle().equals(Tools.prefix + "Bow") || topInv.getTitle().equals(Tools.prefix + "Armor") || topInv.getTitle().equals(Tools.prefix + "Helmet") || topInv.getTitle().equals(Tools.prefix + "Boots") || topInv.getTitle().equals(Tools.prefix + "Tool")) if (p.isOp() || Tools.checkPermission( Tools.getEnchantmentByDisplayname(clickedItem.getItemMeta().getDisplayName()), p)) { Inventory enchantingMenu = Main.CEEnchantingMenu; enchantingMenu.setItem(0, clickedItem); p.closeInventory(); p.openInventory(enchantingMenu); return; } else { p.sendMessage( ChatColor.RED + "[CE] You do not have permission to buy this Enchantment."); return; } // This opens the Item Creation Menu if (topInv.getTitle().equals(Tools.prefix + "Items")) if (p.isOp() || Tools.checkPermission( Tools.getItemByDisplayname(clickedItem.getItemMeta().getDisplayName()), p)) { Inventory approveMenu = Main.CEApproveMenu; approveMenu.setItem(0, clickedItem); p.closeInventory(); p.openInventory(approveMenu); return; } else { p.sendMessage(ChatColor.RED + "[CE] You do not have permission to buy this Item."); return; } } if (topInv.getTitle().equals(Tools.prefix + "Enchanting") || topInv.getTitle().equals(Tools.prefix + "Item Creation")) { double cost = 0; ItemStack item = clickedItem; ItemMeta im = item.getItemMeta(); String type = ""; String successString = ""; Boolean itemSet = false; // TODO: Solve this by adding item-types // Swimsuit swimsuit = (Swimsuit) Main.items.get(9); if (topInv.getTitle().equals(Tools.prefix + "Enchanting")) { if (event.getRawSlot() > topInv.getSize() && event.isLeftClick()) { CEnchantment ce = Tools.getEnchantmentByDisplayname( topInv.getContents()[0].getItemMeta().getDisplayName()); cost = ce.getCost(); type = "enchantment " + ce.getDisplayName(); if (!ce.getApplication().equals(Application.GLOBAL) && !Tools.isApplicationCorrect(ce.getApplication(), clickedItem.getType())) { String appS = ce.getApplication().toString().toLowerCase(); p.sendMessage( ChatColor.RED + "[CE] This enchantment can only be applied to " + ChatColor.GRAY + (appS.endsWith("s") ? appS : appS + "s") + ChatColor.RED + "."); return; } List<String> lore = new ArrayList<String>(); if (clickedItem.getItemMeta().hasLore()) { lore = clickedItem.getItemMeta().getLore(); int number = 0; for (String s : lore) { CEnchantment c = Tools.getEnchantmentByDisplayname(s); if (c != null && c.originalName == ce.originalName) { p.sendMessage(ChatColor.RED + "[CE] This item already has this enchantment!"); return; } if (c != null) number++; } if (Main.maxEnchants > 0 && number >= Main.maxEnchants) { p.sendMessage( ChatColor.RED + "[CE] This item has already reached the maximum of " + ChatColor.GRAY + Main.maxEnchants + ChatColor.RED + " enchantments."); return; } } lore.add(ce.getDisplayName()); im.setLore(lore); item.setItemMeta(im); } else return; } else if (topInv.getTitle().equals(Tools.prefix + "Item Creation")) { item = topInv.getContents()[0]; cost = Tools.getItemByDisplayname(item.getItemMeta().getDisplayName()).getCost(); // if(item.hasItemMeta() && item.getItemMeta().hasDisplayName() && // item.getItemMeta().getDisplayName().equals(swimsuit.getDisplayName())) { //TODO: Always // keep the position of the Swimsuit updated // // // itemSet = true; // // int count = 0; // // for(ItemStack i : event.getView().getBottomInventory()) // if(i == null || i.getType().equals(Material.AIR)) // count++; // // if(count < 4) { // p.sendMessage(ChatColor.RED + "[CE] Your Inventory is full!"); // return; // } // // // } else { if (event.getView().getBottomInventory().firstEmpty() < 0) { p.sendMessage(ChatColor.RED + "[CE] Your Inventory is full!"); return; } // } ItemMeta itemIm = item.getItemMeta(); List<String> lore = itemIm.getLore(); lore.remove(lore.size() - 1); itemIm.setLore(lore); item.setItemMeta(itemIm); type = "item " + itemIm.getDisplayName(); } // TODO: Fix the cost for items // rewrite the whole section to check which enchantment or item is selected successString = (ChatColor.GREEN + "[CE] You have created the " + type + ChatColor.GREEN + "."); if (!p.isOp() && cost != 0) { if (Main.econ.getBalance(p.getName()) >= cost) { EconomyResponse ecr = Main.econ.withdrawPlayer(p.getName(), cost); if (ecr.transactionSuccess()) successString = (ChatColor.GREEN + "[CE] Purchased " + type + ChatColor.GREEN + " for " + cost + " " + ((cost == 1) ? Main.econ.currencyNameSingular() : Main.econ.currencyNamePlural())); else { Bukkit.getConsoleSender() .sendMessage(ChatColor.RED + "[CE] An economy error has occured:"); Bukkit.getConsoleSender().sendMessage(ChatColor.RED + ecr.errorMessage); p.closeInventory(); return; } } else { p.sendMessage(ChatColor.RED + "[CE] You do not have enough money to buy this!"); p.closeInventory(); return; } } if (item != null) { if (!itemSet) if (type.startsWith("item") && event.getRawSlot() < topInv.getSize()) p.setItemInHand(item); else p.getInventory().setItem(event.getSlot(), item); // else { // ItemStack cp = item.clone(); // ItemStack le = item.clone(); // ItemStack bo = item.clone(); // // String[] parts = swimsuit.parts; // // cp.setType(Material.IRON_CHESTPLATE); // le.setType(Material.IRON_LEGGINGS); // bo.setType(Material.IRON_BOOTS); // // im.setDisplayName(parts[1]); // cp.setItemMeta(im); // im.setDisplayName(parts[2]); // le.setItemMeta(im); // im.setDisplayName(parts[3]); // bo.setItemMeta(im); // // p.getInventory().addItem(item); // p.getInventory().addItem(cp); // p.getInventory().addItem(le); // p.getInventory().addItem(bo); // // } } p.closeInventory(); p.sendMessage(successString); return; } if (event.getRawSlot() < topInv.getSize()) { p.closeInventory(); try { p.openInventory(Tools.getNextInventory(clickedItem.getItemMeta().getDisplayName())); } catch (Exception e) { p.sendMessage(ChatColor.RED + "[CE] This feature is disabled."); } } } }