Hello, I want to give a player dyed armor on a command, but i don't know how to make a custom itemstack, and also not how to make it dyed :S Can someone may help me?
Code: ItemStack item = new ItemStack(Material.LEATHER_HELMET; LeatherArmorMeta meta = (LeatherArmorMeta) item.getItemMeta(); meta.setColor(Color.AQUA); item.setItemMeta(meta);
BlazeEyezz there is this search function on the forums, ya know http://forums.bukkit.org/search/39548161/?q=coloring+leather&o=date
Seadragon91 Tried your code but won't work :l Got the same errors as when i tried it by my self Got this: Can someone help me ? EDIT by Moderator: merged posts, please use the edit button instead of double posting.
After the LEATHER_HELMET, you forgot the closing bracket. After you fix that, try exporting, i'm not sure why these errors are appearing.
Now got les errors, but still 4 errors :l First error says: Syntax error on token "setColor", Identifier expected after this token Second error says: Syntax error, insert "... VariableDeclaratorId" to complete FormalParameterList Third erros says: nothing Last errors says: Syntax error, insert "... VariableDeclaratorId" to complete FormalParameterList
Euhm... I don't know if this can help you but this is my code and it's working. And I have a public Enum (Idk if you need it?) Code:java public ItemStack getChestplate(Items item) { ItemStack chestplate = new ItemStack(Material.LEATHER_CHESTPLATE, 1); LeatherArmorMeta meta = (LeatherArmorMeta)chestplate.getItemMeta(); switch (item) { case Chestplateblue: meta.setDisplayName(ChatColor.GOLD + "Monster Fur"); meta.setColor(Color.BLUE); meta.addEnchant(Enchantment.PROTECTION_FIRE, 1, true); chestplate.setItemMeta(meta); } return chestplate; }
thx, got only one error under Chestplateblue :l DarkRangerMC EDIT: i tried this: Code:java public enum Items { Chestplateblue }
Now i want to add this itemstack as his body. i tried this, but got an error under chestplate Code:java p.getInventory().setChestplate(chestplate);
Let me check this for you: Code:java p.getInventory().setChestplate(new ItemStack(getChestplate(Items.Chestplateblue))); This should work
Thx, it's working now! Now i want to make multiple items with colors. I tried to adjust it, but I didn't do it very well http://i.gyazo.com/8719b3566b4313123e8f4abe26291027.png EDIT by Moderator: merged posts, please use the edit button instead of double posting.
aha, i'll try that And I still have to set the items using Code:java p.getInventory().setChestplate(new ItemStack(getChestplate(Items.Chestplateblue)));p.getInventory().setChestplate(new ItemStack(getChestplate(Items.Legsblue))); ? Because now, i just get an normal leather chestplate in the chestplate slot :l DarkRangerMC
BlazeEyezz I'd suggest researching a bit on how enums and Java in general works, so you can understand the error you get from your IDE.
Code:java p.getInventory().setChestplate(new ItemStack(getChestplate(Items.Chestplateblue)));p.getInventory().setChestplate(new ItemStack(getLegs(Items.Legsblue))); You forgot to replace getChestplate with getLegs
I have some code for you! I am now on my mobile, I'll post it here when I get home. Basically the function takes the material (leather armor parts) and a color (RGB). Hope it will help!
Got a new problem :l The helmet that has to be red doesn't have any color. Code:java public enum Items { Chestplateblue, Legsblue } public ItemStack getHelmet(Items item) { ItemStack chestplate = new ItemStack(Material.LEATHER_HELMET, 1); LeatherArmorMeta meta = (LeatherArmorMeta)chestplate.getItemMeta(); switch (item) { case Chestplateblue: meta.setDisplayName(ChatColor.GOLD + "Hat"); meta.setColor(Color.GREEN); chestplate.setItemMeta(meta); } return chestplate; } public ItemStack getHelmet2(Items item) { ItemStack legs = new ItemStack(Material.LEATHER_HELMET, 1); LeatherArmorMeta meta1 = (LeatherArmorMeta)legs.getItemMeta(); switch (item) { case Legsblue: meta1.setDisplayName(ChatColor.GOLD + "Hat"); meta1.setColor(Color.RED); legs.setItemMeta(meta1); } return legs; }