Solved GUI - Item Click doesnt work

Discussion in 'Plugin Development' started by VNGC, Mar 18, 2020.

  1. Offline

    VNGC

    i think, i am totally wrong?

    Code:
        public static Inventory inv = null;
        @EventHandler
        public void Inventory(InventoryClickEvent event) {
            Player p = (Player) event.getWhoClicked();
    
    
            if (event.getView().getTitle().equals("Challenges")) {
                event.setCancelled(true);
    
            }
            if (event.getCurrentItem().getType() == Material.CRAFTING_TABLE) {
                noCrafting.crafting = !noCrafting.crafting;
                ItemStack stack = new ItemStack(Material.CRAFTING_TABLE);
                ItemMeta meta = stack.getItemMeta();
                meta.setDisplayName("§7[§6Crafting§7]");
                ArrayList<String> crafting = new ArrayList<String>();
                if (noCrafting.crafting) {
                    crafting.add(0, "§eWenn §aaktiviert, §estirbst du wenn jemand ein §7Item §ecraftet!");
                    crafting.add(1, ""); // placeholder
                    crafting.add(2, "§7[§aaktiviert§7]");
                    meta.setLore(crafting);
                    stack.setItemMeta(meta);
                } else {
    
                    crafting.add(0, "§eWenn §aaktiviert, §estirbst du wenn jemand ein §7Item §ecraftet!");
                    crafting.add(1, "");
                    crafting.add(2, "§7[§4deaktiviert§7]");
                    meta.setLore(crafting);
                    stack.setItemMeta(meta);
                }
                inv.setItem(1, stack);
                p.getPlayer().openInventory(inv);
    edit: got it! just forgot to create the inv again. much thanks to you all!
     

Share This Page