Solved Lore not adding

Discussion in 'Plugin Development' started by vhbob, Feb 12, 2016.

Thread Status:
Not open for further replies.
  1. Offline

    vhbob

    Hello, as the title seggests i have lore but it will not add it to the item... before you ask, yes i registered my events and yes the config is correct, i have tested this and it wont even add a lore like "test" please help:
    Code:
    @EventHandler
        public void addEnchant(InventoryClickEvent e) {
            Player p = (Player) e.getWhoClicked();
            int level = p.getLevel();
            ItemStack i = e.getCurrentItem();
            ItemMeta im = i.getItemMeta();
            if (e.getInventory().getName().equalsIgnoreCase("Pick your item")) {
                e.setCancelled(true);
                final String type = e.getCurrentItem().getType().name();
                if(type.contains("_SWORD") || type.contains("_AXE")) {
                    String enchant = getConfig().getString(p.getName());
                    if (enchant.equalsIgnoreCase("Poison I")) {
                        p.sendMessage("Test");
                        if (im.getLore() != null) {
                            List<String> lore = im.getLore();
                            lore.add(ChatColor.GRAY + "test");
                            im.setLore(lore);
                            i.setItemMeta(im);
                        } else {
                            List<String> Lore = new ArrayList<>();
                            Lore.add(ChatColor.GRAY + "test");
                            im.setLore(Lore);
                            i.setItemMeta(im);
                        }
                        p.setLevel(level-50);
                        p.sendMessage(ChatColor.GREEN + "The " + enchant + " enchantment has been added to your item!");
                        p.closeInventory();
                        getConfig().set(p.getName(), "");
                        saveConfig();
                    }
                } else {
                    p.closeInventory();
                    p.sendMessage(ChatColor.RED + "You can only enchant swords or axes!");
                }
            }
        }
     
  2. Offline

    Chloe-chan

    Set the ItemMeta back to the Item.

    EDIT: I take that back. Try updating player's inventory ?
     
  3. Offline

    vhbob

    rewriting the plugin nvm
     
Thread Status:
Not open for further replies.

Share This Page