How to spawn dyed leather armor

Discussion in 'Plugin Development' started by SquintingKiwi, Mar 27, 2014.

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

    SquintingKiwi

    I was just curious as how one might be able to spawn dyed leather armor for a player on command using ItemStack? Is this possible? If it is would you mind posting some sample code? Thanks, Squinting Kiwi
     
  2. Offline

    2MBKindiegames

    Here you go:

    Code:
    Color color = Color.AQUA;
    Player player;
               
                ItemStack helmet = new ItemStack(Material.LEATHER_HELMET, 1);
                ItemStack chestplate = new ItemStack(Material.LEATHER_CHESTPLATE, 1);
                ItemStack leggings = new ItemStack(Material.LEATHER_LEGGINGS, 1);
                ItemStack boots = new ItemStack(Material.LEATHER_BOOTS, 1);
               
                LeatherArmorMeta lh = (LeatherArmorMeta)helmet.getItemMeta();
                lh.setColor(color);
                helmet.setItemMeta(lh);
               
                LeatherArmorMeta lc = (LeatherArmorMeta)chestplate.getItemMeta();
                lc.setColor(color);
                chestplate.setItemMeta(lc);
               
                LeatherArmorMeta ll = (LeatherArmorMeta)leggings.getItemMeta();
                ll.setColor(color);
                leggings.setItemMeta(ll);
               
                LeatherArmorMeta lb = (LeatherArmorMeta)boots.getItemMeta();
                lb.setColor(color);
                boots.setItemMeta(lb);
               
                player.getInventory().setHelmet(helmet);
                player.getInventory().setChestplate(chestplate);
                player.getInventory().setLeggings(leggings);
                player.getInventory().setBoots(boots);
     
    SquintingKiwi likes this.
  3. Offline

    xXSniperzzXx_SD

    SquintingKiwi likes this.
  4. Offline

    SkyleTyler1337

    lb.setColor(Color.AQUA);
     
Thread Status:
Not open for further replies.

Share This Page