Solved Item meta help adding enchantments

Discussion in 'Plugin Development' started by winitro, Aug 28, 2014.

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

    winitro

    I'm trying to put an enchant on each of these items but I forget how...
    Code:
                    ItemStack newBoots = dyeArmour(Material.LEATHER_BOOTS, 0, 0, 0);
                    ItemStack newChestPlate = dyeArmour(Material.LEATHER_CHESTPLATE, 255, 0, 0);
                    ItemStack newPants = dyeArmour(Material.LEATHER_LEGGINGS, 0, 0, 255);
                 
                    player.getInventory().setBoots(newBoots);
                    player.getInventory().setBoots(newChestPlate);
                    player.getInventory().setBoots(newPants);
    And here's the extra that goes with that
    Code:
        public ItemStack dyeArmour(Material material, int r, int g, int b){
            ItemStack armour = new ItemStack(material);
            LeatherArmorMeta lam = (LeatherArmorMeta) armour.getItemMeta();
         
            lam.setColor(Color.fromRGB(r, g, b));
            armour.setItemMeta(lam);
         
            return armour;
        }
        public ItemStack setMeta(ItemStack material, String name, List<String> lore) {
            if(((material == null) || material.getType() == Material.AIR) || (name == null && lore == null))
                return null;
         
            ItemMeta im = material.getItemMeta();
            if(name != null)
                im.setDisplayName(name);
            if(lore != null)
                im.setLore(lore);
         
            material.setItemMeta(im);
            return material;
        }
     
  2. Offline

    TheMintyMate

Thread Status:
Not open for further replies.

Share This Page