InventoryClickEvent not working in 1.8

Discussion in 'Spigot Plugin Development' started by Ullrimax, Mar 8, 2018.

  1. Hi, I have a problem with my plugin
    So it's working perfectly on 1.9, 1.10, 1.11 and 1.12 but in 1.8 I have a very weird problem
    So it's about my GUI, it's a menu
    So I placed a syso just at the beginning of my InventoryClickEvent
    In my server, I do my command to open the menu, I click on my categorie I want, so it's working, it's opening the inventory of my categorie.
    Now I need to place an item in this inventory, when I place the item in this inventory, nothing happens, in my console i do not see my syso, so it means that the plugin did not detect the event, the problem is that it is working perfectly on other versions, I have no idea of how to fix it, can someone help me please ?
     
  2. Show us your code
     
  3. That is the code :
    Code (Text):
    @SuppressWarnings("deprecation")
        @EventHandler(priority = EventPriority.HIGHEST)
        public void onInventoryClick(InventoryClickEvent event) throws IOException {
            System.out.println("test");
            Player player = (Player) event.getWhoClicked();
            ItemStack clicked = event.getCurrentItem();
            Inventory inventory = event.getInventory();
            if ( inventories.contains(event.getInventory()) ){
                if (event.getAction().equals(InventoryAction.SWAP_WITH_CURSOR) || event.getAction().equals(InventoryAction.PLACE_ONE)){
                    event.setCancelled(true);
                    return;
                }
                if (event.isShiftClick() && !event.getAction().equals(InventoryAction.PLACE_ALL) && !event.getAction().equals(InventoryAction.PICKUP_ALL)){
                    event.setCancelled(true);
                    return;
                }
            }

            if (!inventories.contains(event.getClickedInventory()) && event.getAction().equals(InventoryAction.PLACE_ALL)){
                if (event.getCursor().hasItemMeta()){  // REMOVE LE LORE
                    if (event.getCursor().getItemMeta().hasLore() && event.getCursor().getItemMeta().getLore().toString().contains("Percentage :")){
                        ItemStack item = event.getCursor();
                        ItemMeta im = item.getItemMeta();
                        ArrayList<String> lore = (ArrayList<String>) event.getCursor().getItemMeta().getLore();
                        lore.remove(lore.size()-1);
                        im.setLore(lore);
                        item.setItemMeta(im);
                        event.setCursor(new ItemStack(Material.AIR));
                        event.getClickedInventory().setItem(event.getSlot(), item);
                        event.setCancelled(true);

                        return;
                    }
                }
            }

            if ( inventories.contains(event.getClickedInventory()) && (event.getAction().equals(InventoryAction.PLACE_ALL) || event.isShiftClick() || event.getAction().equals(InventoryAction.CLONE_STACK) || event.getAction().equals(InventoryAction.PLACE_ONE) || event.getAction().equals(InventoryAction.PLACE_SOME))){

                if (event.getCursor().hasItemMeta()){

                    if ( event.getCursor().getItemMeta().hasLore() && !event.getCursor().getItemMeta().getLore().toString().contains("Percentage :")){

                        if (event.isShiftClick()){
                            event.setCancelled(true);
                            return;
                        }

                        placed = event.getCursor();
                        placedM = placed.getItemMeta();
                        slot = event.getSlot();
                        inve = event.getClickedInventory();
                        input.add(player);
                        event.setCursor(new ItemStack(Material.AIR));
                        event.setCancelled(true);
                        player.closeInventory();
                        player.sendMessage(ChatColor.GOLD + "What is the probability to drop this item ? (Between 0 and 1) ");
                        return;
                    } else if (!event.getCursor().getItemMeta().hasLore()){

                        if (event.isShiftClick()){
                            event.setCancelled(true);
                            return;
                        }

                        placed = event.getCursor();
                        placedM = placed.getItemMeta();
                        slot = event.getSlot();
                        inve = event.getClickedInventory();
                        input.add(player);
                        event.setCursor(new ItemStack(Material.AIR));
                        event.setCancelled(true);
                        player.closeInventory();
                        player.sendMessage(ChatColor.GOLD + "What is the probability to drop this item ? (Between 0 and 1) ");
                        return;
                    }

                } else {

                    if (event.isShiftClick()){
                        event.setCancelled(true);
                        return;
                    }

                    placed = event.getCursor();
                    placedM = placed.getItemMeta();
                    slot = event.getSlot();
                    inve = event.getClickedInventory();
                    input.add(player);
                    event.setCursor(new ItemStack(Material.AIR));
                    event.setCancelled(true);
                    player.closeInventory();
                    player.sendMessage(ChatColor.GOLD + "What is the probability to drop this item ? (Between 0 and 1) ");
                    return;
                }
            }

            if (clicked != null && clicked.getType() != Material.AIR) {

                if (inventory.getName().equals(Inventories.menu.getName())) { // Categorie Selecting

                    if (clicked.getItemMeta().equals(Inventories.menu.getItem(3).getItemMeta())) {
                        player.closeInventory();
                        get(Inventories.fish, "Fish");
                        player.openInventory(Inventories.fish);
                        System.out.println("fish");
                        return;
                    }
                    if (clicked.getItemMeta().equals(Inventories.menu.getItem(4).getItemMeta())) {
                        player.closeInventory();
                        get(Inventories.treasure, "Treasure");
                        player.openInventory(Inventories.treasure);
                        return;
                    }
                    if (clicked.getItemMeta().equals(Inventories.menu.getItem(5).getItemMeta())) {
                        player.closeInventory();
                        get(Inventories.junk, "Junk");
                        player.openInventory(Inventories.junk);
                        return;
                    }

                }


                if (inventory.getName().equals(Inventories.pfish.getName())) {  // Probabilities

                    if (clicked.getItemMeta().equals(Inventories.pfish.getItem(2).getItemMeta())) {
                        player.closeInventory();
                        pinput.add(player);
                        categorie1 = "pFish";
                        categorie2 = "pTreasure";
                        categorie3 = "pJunk";
                        player.sendMessage(ChatColor.GREEN + "Please write the percentage of getting a "+ ChatColor.BLUE + "fish"+ ChatColor.GREEN +" (Must be an Integer)");
                    }
                    if (clicked.getItemMeta().equals(Inventories.pfish.getItem(4).getItemMeta())) {
                        player.closeInventory();
                        pinput.add(player);
                        categorie1 = "lots1f";
                        categorie2 = "lots1t";
                        categorie3 = "lots1j";
                        player.sendMessage(ChatColor.GREEN + "Please write the percentage of getting a "+ ChatColor.BLUE + "fish"+ ChatColor.GREEN +" (Must be an Integer)");
                    }
                    if (clicked.getItemMeta().equals(Inventories.pfish.getItem(5).getItemMeta())) {
                        player.closeInventory();
                        pinput.add(player);
                        categorie1 = "lots2f";
                        categorie2 = "lots2t";
                        categorie3 = "lots2j";
                        player.sendMessage(ChatColor.GREEN + "Please write the percentage of getting a "+ ChatColor.BLUE + "fish"+ ChatColor.GREEN +" (Must be an Integer)");
                    }
                    if (clicked.getItemMeta().equals(Inventories.pfish.getItem(6).getItemMeta())) {
                        player.closeInventory();
                        pinput.add(player);
                        categorie1 = "lots3f";
                        categorie2 = "lots3t";
                        categorie3 = "lots3j";
                        player.sendMessage(ChatColor.GREEN + "Please write the percentage of getting a "+ ChatColor.BLUE + "fish"+ ChatColor.GREEN +" (Must be an Integer)");
                    }

                }
            }
        }
    So it's after I chose a categorie, so this code bellow, that the plugin doesn't detect the event anymore :
    Code (Text):
    if (inventory.getName().equals(Inventories.menu.getName())) { // Categorie Selecting

                    if (clicked.getItemMeta().equals(Inventories.menu.getItem(3).getItemMeta())) {
                        player.closeInventory();
                        get(Inventories.fish, "Fish");
                        player.openInventory(Inventories.fish);
                        System.out.println("fish");
                        return;
                    }
                    if (clicked.getItemMeta().equals(Inventories.menu.getItem(4).getItemMeta())) {
                        player.closeInventory();
                        get(Inventories.treasure, "Treasure");
                        player.openInventory(Inventories.treasure);
                        return;
                    }
                    if (clicked.getItemMeta().equals(Inventories.menu.getItem(5).getItemMeta())) {
                        player.closeInventory();
                        get(Inventories.junk, "Junk");
                        player.openInventory(Inventories.junk);
                        return;
                    }

                }
     
  4. 1.8 is no longer supported how hard is this to understand.
    Also are you regiserting the event
     
    • Agree Agree x 1
    • Winner Winner x 1
  5. Yeah I'm registering the event lol.. I told that my plugin is working perfectly in newer versions
    And some users of my plugin have their server in 1.8
     
  6. I already tried to put spigot 1.8.8 jar as the library but it's not giving me any error, I have really no idea of how to solve this problem, this is very very weird I don't understand how it is possible
     
  7. up, please someone help me ?
     
  8. Do you have an error in your server console?
     
  9. No, nothing :/ It's unbelievable
     
  10. Do you have other plugins installed? Maybe another plugin is conflicting.
     
  11. No I have nothing else, and as I told before, on 1.9+ spigots it's working perfectly, and on 1.8 spigot it's not working
     
  12. The server doesn't even output "test" to the console?
     
  13. It justs input when i click To change the categorie, when i click in the categorie inventory its not doing anything
     
  14. md_5

    Administrator Developer

    I don't think it's broken, but let's assume it is.

    What do you expect to be done about it given this version of Spigot hasn't been updated in over two years?
     
    • Agree Agree x 2
    • Winner Winner x 2
  15. the event is in the JavaPlugin class?
    does the event inside a class that implements Listener?
    do u registered the event's class in onEnable?
     
  16. Yeah yeah

    Because a user of my plugin is using Spigot 1.8
     
  17. He's asking what you expect to be done about it.. lol
     
  18. My plugin is a premium plugin, this user paid to get this plugin, so this user has to have a working plugin
     
  19. He HAS to if IS possible to do. If it is not, you can't do much about It.
     
  20. maybe you have unstable spigot jar?
     

Share This Page