DISPLAYNAME DONT WORKİNG

Discussion in 'Spigot Plugin Development' started by Syanko, Dec 7, 2018 at 5:05 AM.

  1. Code (Text):
     ItemStack[] a = {new ItemStack(Material.DIAMOND_SWORD), new ItemStack(Material.WATER_BUCKET), new ItemStack(Material.FISHING_ROD), new ItemStack(Material.LAVA_BUCKET), new ItemStack(Material.WATER_BUCKET), new ItemStack(Material.COBBLESTONE), new ItemStack(Material.GOLDEN_APPLE, 6),new ItemStack(Material.GOLDEN_APPLE, 3), new ItemStack(Material.BOW), new ItemStack(Material.LAVA_BUCKET)};
        ItemMeta[] b = {a[1].getItemMeta(), a[6].getItemMeta(), a[7].getItemMeta()};
     
        a[6].getItemMeta().setDisplayName("asdas");
        a[6].setItemMeta(b[1]);
        e.getPlayer().getInventory().setContents(a);
    items adding but displayname doesnt seem to work no errors what is the mistake here
     
  2. Replace a[6].getItemMeta() with b[1] in this line:
    Code (Java):
    a[6].getItemMeta().setDisplayName("asdas");
    Corrected varient:
    Code (Text):
    b[1].setDisplayName("asdas");
     
    • Agree Agree x 1
  3. You have to set the displayname on the Itemmeta not the itemstack
     
    • Like Like x 1
  4. thanks
     

Share This Page