Пример #1
0
 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 =====");
 }
Пример #2
0
  /**
   * 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
 protected void onInventoryClick(InventoryClickEvent event, Player player) {
   event.setCancelled(true);
   final int slot = event.getRawSlot();
   if (slot >= 0 && slot <= 7) {
     // handle changing sell stack size
     ItemStack item = event.getCurrentItem();
     if (item != null && item.getType() != Material.AIR) {
       int amount = item.getAmount();
       amount = this.getNewAmountAfterEditorClick(event, amount);
       if (amount <= 0) amount = 1;
       if (amount > item.getMaxStackSize()) amount = item.getMaxStackSize();
       item.setAmount(amount);
     }
   } else if ((slot >= 9 && slot <= 16) || (slot >= 18 && slot <= 25)) {
     if (((TradingPlayerShopkeeper) shopkeeper).clickedItem != null) {
       // placing item
       final Inventory inventory = event.getInventory();
       Bukkit.getScheduler()
           .runTaskLater(
               ShopkeepersPlugin.getInstance(),
               new Runnable() {
                 public void run() {
                   inventory.setItem(slot, ((TradingPlayerShopkeeper) shopkeeper).clickedItem);
                   ((TradingPlayerShopkeeper) shopkeeper).clickedItem = null;
                 }
               },
               1);
     } else {
       // changing stack size
       ItemStack item = event.getCurrentItem();
       if (item != null && item.getType() != Material.AIR) {
         int amount = item.getAmount();
         amount = this.getNewAmountAfterEditorClick(event, amount);
         if (amount <= 0) {
           event.getInventory().setItem(slot, null);
         } else {
           if (amount > item.getMaxStackSize()) amount = item.getMaxStackSize();
           item.setAmount(amount);
         }
       }
     }
   } else if (slot >= 27) {
     // clicking in player inventory
     if (event.isShiftClick() || !event.isLeftClick()) {
       return;
     }
     ItemStack cursor = event.getCursor();
     if (cursor != null && cursor.getType() != Material.AIR) {
       return;
     }
     ItemStack current = event.getCurrentItem();
     if (current != null && current.getType() != Material.AIR) {
       ((TradingPlayerShopkeeper) shopkeeper).clickedItem = current.clone();
       ((TradingPlayerShopkeeper) shopkeeper).clickedItem.setAmount(1);
     }
   } else {
     super.onInventoryClick(event, player);
   }
 }
Пример #4
0
  @ClickHandler(
      status = {tNpcStatus.MANAGE_SELL, tNpcStatus.MANAGE_BUY},
      inventory = InventoryType.TRADER,
      shift = true)
  public void itemsAttribs(InventoryClickEvent e) {
    // debug info
    dB.info("Item managing click event");

    // select the item that should have the price changed
    if (selectAndCheckItem(e.getSlot())) {
      if (e.isShiftClick()) {
        if (e.isLeftClick()) {
          stock.setAmountsInventory(inventory, status, getSelectedItem());
          parseStatus(tNpcStatus.MANAGE_AMOUNTS);
        } else // if it's a shift rightclick
        {

        }
      } else // no shift click
      {
        if (e.isLeftClick()) {
          if (getSelectedItem().hasFlag(StackPrice.class))
            getSelectedItem().removeFlag(StackPrice.class);
          else getSelectedItem().addFlag(".sp");

          locale.sendMessage(
              player,
              "key-change",
              "key",
              "#stack-price",
              "value",
              String.valueOf(getSelectedItem().hasFlag(StackPrice.class)));
        } else // if it's a shift rightclick
        {

        }
      }
    }
    e.setCancelled(true);
  }
Пример #5
0
 @ClickHandler(
     status = {
       tNpcStatus.SELL,
       tNpcStatus.BUY,
       tNpcStatus.SELL_AMOUNTS,
       tNpcStatus.MANAGE_SELL,
       tNpcStatus.MANAGE_BUY,
       tNpcStatus.MANAGE_AMOUNTS,
       tNpcStatus.MANAGE_PRICE,
       tNpcStatus.MANAGE_LIMIT
     },
     shift = true,
     inventory = InventoryType.PLAYER)
 public void botDebug(InventoryClickEvent e) {
   // debug info
   dB.info("Inventory click, by: ", player.getName(), ", status: ", status.name().toLowerCase());
   dB.info("slot: ", e.getSlot(), ", left: ", e.isLeftClick(), ", shift: ", e.isShiftClick());
 }
Пример #6
0
 @Override
 public void onClicked(InventoryClickEvent event) {
   int newValue = value;
   if (event.isLeftClick()) {
     newValue -= event.isShiftClick() ? altIncr : incr;
   } else if (event.isRightClick()) {
     newValue += event.isShiftClick() ? altIncr : incr;
   }
   newValue = Math.max(Math.min(newValue, range.getMaximumInteger()), range.getMinimumInteger());
   if (newValue != value && callback.run(newValue)) {
     value = newValue;
     event.setCurrentItem(getTexture());
   } else {
     // vetoed by the block!
     if (event.getWhoClicked() instanceof Player) {
       STBUtil.complain((Player) event.getWhoClicked());
     }
   }
 }
Пример #7
0
  /**
   * Price managing for manager stock, this allows you to change prices for all items in your
   * traders stock
   *
   * @param e
   */
  @ClickHandler(
      status = {tNpcStatus.MANAGE_PRICE},
      inventory = InventoryType.TRADER)
  public void managePrices(InventoryClickEvent e) {
    // debug info
    dB.info("Price managing click event");

    // select the item that should have the price changed
    if (selectAndCheckItem(e.getSlot())) {
      // show the current price in chat, if cursor is AIR
      if (e.getCursor().getTypeId() == 0) {
        // sends the message
        locale.sendMessage(
            player, "key-value", "key", "#price", "value", getSelectedItem().getPriceFormated());
      } else {
        // adds the price attribute to the item
        Price price = getSelectedItem().getPriceAttr();

        // adds value to the current price
        if (e.isLeftClick()) {
          // increases the price using specialBlockValue*cursorAmount
          price.increase(Settings.getBlockValue(e.getCursor()) * e.getCursor().getAmount());

          // sends a message
          locale.sendMessage(
              player, "key-change", "key", "#price", "value", getSelectedItem().getPriceFormated());
        } else
        // remove value from the current price
        if (e.isRightClick()) {
          // decreases the price using specialBlockValue*cursorAmount
          price.decrease(Settings.getBlockValue(e.getCursor()) * e.getCursor().getAmount());

          // sends a message
          locale.sendMessage(
              player, "key-change", "key", "#price", "value", getSelectedItem().getPriceFormated());
        }
      }
    }
    e.setCancelled(true);
  }
Пример #8
0
 @Override
 public void onClick(Player player, InventoryClickEvent event) {
   if (event.getCurrentItem() != null && !event.getCurrentItem().getType().equals(Material.AIR)) {
     if (event.getRawSlot() <= event.getSlot()) {
       int slot = event.getSlot();
       PlayerShopOffer offer = shop.getOffers().get(slot);
       if (offer != null) {
         if (event.isLeftClick()) {
           if (player.getName().equalsIgnoreCase(shop.getOwnerName())) {
             handleOfferEdit(player, event, offer);
           } else {
             handleTrade(player, event, offer);
           }
         } else if (event.isRightClick()) {
           if (getSession().getPermissionsProvider().has(player, ASPermissionKey.MANAGER)) {
             handleOfferEdit(player, event, offer);
           }
         }
       }
     }
   }
 }
Пример #9
0
  @ClickHandler(
      status = {tNpcStatus.SELL, tNpcStatus.BUY},
      inventory = InventoryType.PLAYER)
  public void buyItems(InventoryClickEvent e) {
    e.setCancelled(true);
    // check permission
    if (!perms.has(player, "dtl.trader.buy")) return;

    clearSelection();
    int slot = e.getSlot();
    if (e.isLeftClick()) {
      if (selectAndCheckItem(e.getCurrentItem(), "buy")) {
        int scale = e.getCurrentItem().getAmount() / getSelectedItem().getAmount();
        if (scale == 0) return;

        if (handleClick(e.getRawSlot())) {
          if (!buyTransaction(scale)) {
            // send message
            locale.sendMessage(
                player,
                "trader-transaction-failed-trader-money",
                "npc",
                settings.getNPC().getName());
          } else {
            // remove the amount from inventory
            removeFromInventory(slot, scale);

            // send the transaction success message
            locale.sendMessage(
                player,
                "trader-transaction-success",
                "trader",
                getNPC().getName(),
                "player",
                player.getName(),
                "action",
                "#sold",
                "item",
                getSelectedItem().getName(),
                "amount",
                String.valueOf(getSelectedItem().getAmount() * scale),
                "price",
                String.valueOf(stock.parsePrice(getSelectedItem(), 0) * scale));

            // update the inventory lore
            updatePlayerInventory();
          }
        } else {
          // send the information message
          locale.sendMessage(
              player,
              "trader-transaction-item",
              "item",
              getSelectedItem().getName(),
              "amount",
              String.valueOf(getSelectedItem().getAmount()),
              "price",
              String.valueOf(stock.parsePrice(getSelectedItem(), 0)));
        }
      }
    } else {
      if (selectAndCheckItem(e.getCurrentItem(), "buy")) {
        int scale = e.getCurrentItem().getAmount() / getSelectedItem().getAmount();
        if (scale == 0) return;

        if (handleClick(e.getRawSlot())) {
          if (!buyTransaction()) {
            // send message
            locale.sendMessage(
                player,
                "trader-transaction-failed-trader-money",
                "npc",
                settings.getNPC().getName());
          } else {
            // remove the amount from inventory
            removeFromInventory(slot);

            // send the transaction success message
            locale.sendMessage(
                player,
                "trader-transaction-success",
                "trader",
                getNPC().getName(),
                "player",
                player.getName(),
                "action",
                "#sold",
                "item",
                getSelectedItem().getName(),
                "amount",
                String.valueOf(getSelectedItem().getAmount()),
                "price",
                String.valueOf(stock.parsePrice(getSelectedItem(), 0)));

            // update the inventory lore
            updatePlayerInventory();
          }
        } else {
          // send the information message
          locale.sendMessage(
              player,
              "trader-transaction-item",
              "item",
              getSelectedItem().getName(),
              "amount",
              String.valueOf(getSelectedItem().getAmount()),
              "price",
              String.valueOf(stock.parsePrice(getSelectedItem(), 0)));
        }
      }
    }
  }
Пример #10
0
  @ClickHandler(
      status = {tNpcStatus.SELL},
      inventory = InventoryType.TRADER)
  public void sellItems(InventoryClickEvent e) {
    e.setCancelled(true);
    // check permission
    if (!perms.has(player, "dtl.trader.sell")) return;

    int slot = e.getSlot();
    if (stock.isUiSlot(slot)) return;

    if (e.isLeftClick()) {
      if (selectAndCheckItem(slot)) {
        if (getSelectedItem().hasMultipleAmounts()) {
          // send message
          locale.sendMessage(player, "trader-stock-toggled", "stock", "#stock-amounts");

          // change status
          status = tNpcStatus.SELL_AMOUNTS;
          stock.setAmountsInventory(inventory, status, getSelectedItem());
        } else if (handleClick(e.getRawSlot())) {
          if (!inventoryHasPlace()) {
            // send message
            locale.sendMessage(player, "trader-transaction-failed-inventory");
          } else if (!sellTransaction()) {
            // send message
            locale.sendMessage(player, "trader-transaction-failed-player-money");
          } else {
            addToInventory();

            // send message
            locale.sendMessage(
                player,
                "trader-transaction-success",
                "trader",
                getNPC().getName(),
                "player",
                player.getName(),
                "action",
                "#bought",
                "item",
                getSelectedItem().getName(),
                "amount",
                String.valueOf(getSelectedItem().getAmount()),
                "price",
                String.valueOf(getSelectedItem().getPrice()));

            // update inventory - lore
            updatePlayerInventory();
          }
        } else {
          // informations about the item some1 wants to buy
          locale.sendMessage(
              player,
              "trader-transaction-item",
              "item",
              getSelectedItem().getName(),
              "amount",
              String.valueOf(getSelectedItem().getAmount()),
              "price",
              String.valueOf(getSelectedItem().getPrice()));
        }
      }
    } else {
      if (selectAndCheckItem(slot)) {
        if (handleClick(e.getRawSlot())) {
          if (!inventoryHasPlace()) {
            // send message
            locale.sendMessage(player, "trader-transaction-failed-inventory");
          } else if (!sellTransaction()) {
            // send message
            locale.sendMessage(player, "trader-transaction-failed-player-money");
          } else {
            addToInventory();

            // send message
            locale.sendMessage(
                player,
                "trader-transaction-success",
                "trader",
                getNPC().getName(),
                "player",
                player.getName(),
                "action",
                "#bought",
                "item",
                getSelectedItem().getName(),
                "amount",
                String.valueOf(getSelectedItem().getAmount()),
                "price",
                String.valueOf(getSelectedItem().getPrice()));

            // update inventory - lore
            updatePlayerInventory();
          }
        } else {
          // informations about the item some1 wants to buy
          locale.sendMessage(
              player,
              "trader-transaction-item",
              "item",
              getSelectedItem().getName(),
              "amount",
              String.valueOf(getSelectedItem().getAmount()),
              "price",
              String.valueOf(getSelectedItem().getPrice()));
        }
      }
    }
  }
Пример #11
0
  @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.");
        }
      }
    }
  }