Solved Lore + Display Name not working

Discussion in 'Plugin Development' started by Boobah, Apr 28, 2017.

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

    Boobah

    I'm trying to make a GUI for prefs. Everything is going well apart from one item in the GUI. I think I have done it exactly the same as all the other items, but for some reason the lore and display name won't show. You can also move the item out of the inventory. Code:
    Code:
    ItemStack privateMsgT = new ItemStack(Material.MAP);
            ItemMeta privateMsgTmeta = privateMsgT.getItemMeta();
            privateMsgTmeta.setDisplayName(ChatColor.GREEN + "Private Messaging");
            ArrayList<String> privateMsgTLore = new ArrayList<String>();
            privateMsgTLore.add(ChatColor.GREEN + "Enabled");
            privateMsgTLore.add("");
            privateMsgTLore.add(ChatColor.WHITE + "Click to Disable");
            privateMsgTmeta.setLore(privateMsgTLore);
            privateMsgT.setItemMeta(privateMsgTmeta);
    
            ItemStack privateMsgF = new ItemStack(Material.MAP);
            ItemMeta privateMsgFmeta = privateMsgF.getItemMeta();
            privateMsgFmeta.setDisplayName(ChatColor.RED + "Private Messaging");
            ArrayList<String> privateMsgFLore = new ArrayList<String>();
            privateMsgFLore.add(ChatColor.RED + "Disabled");
            privateMsgFLore.add("");
            privateMsgFLore.add(ChatColor.WHITE + "Click to Enable");
            privateMsgFmeta.setLore(privateMsgFLore);
            privateMsgF.setItemMeta(privateMsgFmeta);
    
            ItemStack privateMsgTdye = new ItemStack(Material.INK_SACK, 1, (byte) 10);
            ItemMeta privateMsgTdyemeta = privateMsgT.getItemMeta();
            privateMsgTdyemeta.setLore(privateMsgTLore);
            privateMsgTdye.setItemMeta(privateMsgTmeta);
    
            ItemStack privateMsgFdye = new ItemStack(Material.INK_SACK, 1, (byte) 8);
            ItemMeta privateMsgFdyemeta = privateMsgF.getItemMeta();
            privateMsgFdyemeta.setLore(privateMsgFLore);
            privateMsgFdye.setItemMeta(privateMsgFmeta);
    [​IMG]
     
  2. Offline

    Caderape2

    @Boobah
    You don't set it with the good meta

    I will suggest to make name easier when you do stuff like that. (like item1 and meta1, then item2 and meta2. You will see directly if something is wrong)

    For the 2 last one, you take the meta from the itemstack map
     
  3. Offline

    Boobah

    That's exactly how I did it for other items and it worked fine for those.
     
  4. Offline

    yPedx

    @Boobah
    Do you have an inventory name check before you define what all the items do? No need to include colors, just the exact name. (I don't remember if it was called playerInventoryInteractEvent or something like that, not on pc..)
    Code:
    ItemStack privateMsgTdye = new ItemStack(Material.INK_SACK, 1, (byte) 10);
            ItemMeta privateMsgTdyemeta = privateMsgT.getItemMeta();
            privateMsgTdyemeta.setLore(privateMsgTLore);
            privateMsgTdye.setItemMeta(privateMsgTmeta);
    At the end you're trying to se the itemMeta from the item in the top of your code, "privateMsgTMeta" and not "privateMsgTDyemeta"
     
    Last edited: Apr 29, 2017
  5. Offline

    Boobah

    I tried that but it didn't work. I've fixed it now though by just adding lore to the item instead of taking it from privateMsgT.
     
Thread Status:
Not open for further replies.

Share This Page