Lore not working...

Discussion in 'Plugin Development' started by JoltTheBolt, Dec 23, 2020.

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

    JoltTheBolt

    Code:
     public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
            if (cmd.getName().equalsIgnoreCase("incinerator")) {
                   ItemStack Incinerator = new ItemStack(Material.DIAMOND_SWORD);
                ItemMeta Incineratormeta = Incinerator.getItemMeta();
                Incineratormeta.setDisplayName(ChatColor.GOLD.toString() + ChatColor.BOLD.toString() + "Incinerator");
                   Incinerator.setItemMeta(Incineratormeta);
                sender.sendMessage(ChatColor.YELLOW + "You have been bestowed the power of Incinerator!");
                Player player = (Player) sender;
                Inventory inventory = player.getInventory();
                inventory.addItem(Incinerator);
                ArrayList<String> lore = new ArrayList<String>();
                lore.add("LORE");
                Incineratormeta.setLore(lore);
                return true;
            }
            return false;
        }
    }
    Everything works well. There is one issue. The lore that I want to add isn't here.
    upload_2020-12-23_19-7-43.png

    Can anyone help me? Thanks!
     

    Attached Files:

  2. Online

    timtower Administrator Administrator Moderator

  3. Offline

    JoltTheBolt

    Haven't I done that using
    Code:
    Incinerator.setItemMeta(Incineratormeta);
    ?
    If not, How do I do it?
     
  4. Online

    timtower Administrator Administrator Moderator

    @JoltTheBolt Yes and no, you did set it, but then you started changing it again.
    Modify the meta, set it to the item, give the item to the player.
     
  5. Offline

    JoltTheBolt

    THANK YOU so much!
    I did it like this:

    Code:
    if (cmd.getName().equalsIgnoreCase("incinerator")) {
    ItemStack Incinerator = new ItemStack(Material.DIAMOND_SWORD);
    ItemMeta Incineratormeta = Incinerator.getItemMeta();
    Incineratormeta.setDisplayName(ChatColor.GOLD.toString() + ChatColor.BOLD.toString() + "Incinerator");
    ArrayList<String> lore = new ArrayList<String>();
    lore.add(ChatColor.DARK_BLUE.toString() + "Item Ability: " + ChatColor.AQUA.toString() + "Incineration");
    lore.add(ChatColor.WHITE.toString() + "Burns everything " + ChatColor.GREEN.toString() + "5 blocks ");
    lore.add(ChatColor.WHITE.toString() + "ahead of you");
    Incineratormeta.setLore(lore);
    Incinerator.setItemMeta(Incineratormeta);
    sender.sendMessage(ChatColor.YELLOW + "You have been bestowed the power of Incinerator!");
    Player player = (Player) sender;
    Inventory inventory = player.getInventory();
    inventory.addItem(Incinerator);
     
    timtower likes this.
Thread Status:
Not open for further replies.

Share This Page