ItemStack With Lores

Discussion in 'Plugin Development' started by Albkad, Feb 21, 2017.

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

    Albkad

    So I Am Making A CustomEnchants Plugin And I Have Gotten To The Problem That I Can Only Have One Lore On A Single Item At A Time.
    Code:
                                ItemStack Smelting = new ItemStack(Material.DIAMOND_PICKAXE);
                                ItemMeta meta = Smelting.getItemMeta();
                                List<String> lore = new ArrayList<String>();
                                lore.add(ChatColor.RED + (getConfig().getString("Enchants." + ".SmeltingName")));
                                meta.setLore(lore);
                                Smelting.setItemMeta(meta);
                                p.getPlayer().getInventory().setItemInHand(Smelting);
     
  2. Offline

    MrGeneralQ


    Save all lores in a list >> For loop through them >> change it. >> set the lore to the Item again.
     
  3. Offline

    PQE

    Why can you only have one lore?

    Just use lore.add multiple times, then set the meta to your lore?
     
  4. Offline

    Albkad

    @PQE because the item already has a lore
     
  5. Online

    timtower Administrator Administrator Moderator

    @Albkad Get the original lore.
    Add your line.
    Set the lore.
     
    PQE likes this.
  6. Offline

    Albkad

    @timtower How do I do this? Like this?
    Code:
                                lore.add(p.getPlayer().getItemInHand().getItemMeta().getLore().toString());
     
  7. Offline

    Zombie_Striker

    @Albkad
    What are you trying to do? What you have will just print out string of all the values and qualities of the arraylist, which is most likely not what you want.

    If you want to add the lore to another list, use
    Code:
    List<String> lore = new ArrayList<>(ItemMeta#getLore());
     
Thread Status:
Not open for further replies.

Share This Page