InventoryClick Event

Discussion in 'Plugin Development' started by UnAnswereed, Oct 30, 2017.

Thread Status:
Not open for further replies.
  1. I did an inventory menu with submenus, and I can't use InventoryClickEvent because it only counts the event in the first menu, then in the submenu it isn't works.

    Here are some examples from my code:
    if (e.getInventory().getTitle().equalsIgnoreCase(Main.EventInfo.prefix + "§5Shop")) {
                if (e.getCurrentItem().getType() == Material.DIAMOND) {
                } else if (e.getCurrentItem().getType() == Material.IRON_INGOT) {   
                } else if (e.getCurrentItem().getType() == Material.STONE) {
    if (e.getInventory().getTitle().equalsIgnoreCase("§7Iron Items")) {
                if (e.getCurrentItem().getType() == Material.WOOL || e.getCurrentItem().getDurability() == 14) {
          "/event shop");
  2. Offline


    What indicates that you can not use the InventoryClickEvent anymore? Inventory is Inventory so actually that should work
  3. @MightyOne If I open the main inventory, and then a sub, in the subinventory when I click to some item, nothing happens. But, I set a command, so I can reach the submenus instant, and in that way I can use the items, and there is a "back" button, so I can go back to the main menu, and there I can't use anything again.
  4. Offline


    Try not to use .getTitle()
    if (!e.getInventory().getName() == "name") {
    } else {
        if (e.getCurrentItem().getItemMeta().getDisplayName() == "&5name") {
    I could be wrong currently can't remember so if something is wrong I'll correct later when I'm home
  5. Offline

    timtower Administrator Administrator Moderator

    @AdamDev Strings are compared with equals or equalsIgnoreCase
    ipodtouch0218 likes this.
  6. Offline


  7. @ItsComits It's not the same problem. I can open the inventory from the main, but I can't do anything in that, and the problem isn't with the second inventory's programming.
  8. Offline


    Maybe the colored text is messing up the string comparisons. Try using ChatColor.stripColor to compare strings without their color.
  9. Offline


    Before you compare the strings that have a color assigned to them, translate the code using:
    ChatColor.translateAlternateColorCodes('§', "§5String to translate");
  10. Offline


    What are you doing? The paragraph symbol is the color code. If you're including the paragraph symbol (Which you really shouldn't. We've had multiple threads on this topic, but in short, doing this bloats the jar file and may cause problems if the color codes change), then you don't need the translate method, because all that method does is add the paragraph symbol.

    Either remove the colorcode method and leave the paragraph symbol, or replace the symbol with &.
  11. Guys, I can use every inventory if I open them with a command. But if I open it from an other inventory it's just not working
  12. Offline


    I tried your code and it should work fine. Can you post the methods that open the shop inventory and the iron shop subinventory?
  13. Offline


    Maybe you can try: ChatColor.StripColor(e.getInventory().getName()).equalsIgnorCase("iron items"). It's intested but i had issues with the chatcolor before
Thread Status:
Not open for further replies.

Share This Page