Leather Armor with Dye, Lore and Display Name problem

Discussion in 'Plugin Development' started by Wbjpen, Sep 1, 2013.

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

    Wbjpen

    I have this code that's supposed to add a new Leather Chestplate to the player's inventory, that chestplate should have a custom Display Name, Lore AND dyed a custom color. It adds the Lore and Display Name just fine, but once I add the Dye Code, it removes the Display Name and Lore and I just get a regular piece of dyed armor.

    Code:java
    1. ItemStack stack = new ItemStack(Material.LEATHER_CHESTPLATE, 1);
    2. ItemMeta meta = stack.getItemMeta();
    3. ArrayList<String> lore = new ArrayList<String>();
    4. meta.setDisplayName("God Chestplate");
    5. lore.add(ChatColor.YELLOW+"Lore1");
    6. lore.add(ChatColor.YELLOW+"Lore2");
    7. lore.add(ChatColor.RED+"Lore3");
    8. meta.setLore(lore);
    9. LeatherArmorMeta lam = (LeatherArmorMeta)stack.getItemMeta();//Dye Code
    10. lam.setColor(Color.fromRGB(56, 13, 7));//Dye code
    11. stack.setItemMeta(meta);
    12. stack.setItemMeta(lam);//Dye Code
    13. event.getPlayer().getInventory().addItem(new ItemStack(stack));
     
  2. cos u set the item meta to meta then set it to lam so anything from meta is gone :p
     
  3. Offline

    Wbjpen

    When I remove the setItemMeta(lam), it gets rid of the color, but adds the Display Name and Lore. I need some way of setting "lam" to the item without using the setItemMeta.
     
  4. ((LeatherArmorMeta)meta).setColor(your color);
     
    Wbjpen likes this.
  5. Offline

    Wbjpen

    That worked perfectly! Thank you so much!
     
  6. Offline

    Drkmaster83

    Change prefix to solved, please. OCD ~(O.O)~
     
Thread Status:
Not open for further replies.

Share This Page