Solved Lore is null

Discussion in 'Plugin Development' started by HeartandSoul, Oct 30, 2016.

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

    HeartandSoul

    This usually works, but the lore is null (The first lore.add())

    Code:
                        ItemStack bottle = new ItemStack(Material.EMERALD, 1);
                        ItemMeta meta = bottle.getItemMeta();
                        List<String> lore = meta.getLore();
                        lore.add("§6Experience Bottle");
                        lore.add("§2The experience contained in this bottle is below: ");
                        lore.add("" + exp);
                        meta.setLore(lore);
                        meta.setDisplayName("§a§lCustom Exp Bottle");
                        bottle.setItemMeta(meta);
     
  2. Offline

    timtower Administrator Administrator Moderator

  3. Offline

    HeartandSoul

  4. Offline

    timtower Administrator Administrator Moderator

    @HeartandSoul If there is no lore then getLore returns null.
    hasLore() returns a boolean if there is a lore.
    Check it, if it returns false: make a new list to use as the lore.
     
  5. Offline

    HeartandSoul

    Thanks!

    Solved.
     
Thread Status:
Not open for further replies.

Share This Page