public class ItemMaker implements Cloneable { private Material type; private int data; private int amount; private String title; private List lore; private Color color; private HashMap enchantments; private NBTTagCompound nbt; public ItemMaker(ItemStack item) { this.lore = new ArrayList<>(); this.enchantments = new HashMap<>(); this.type = item.getType(); this.data = item.getDurability(); this.amount = item.getAmount(); this.nbt = CraftItemStack.asNMSCopy(item).getTag(); if (item.hasItemMeta()) { if (item.getItemMeta().hasDisplayName()) { this.title = item.getItemMeta().getDisplayName(); } if (item.getItemMeta().hasLore()) { this.lore = item.getItemMeta().getLore(); } } if (item.getEnchantments() != null) { this.enchantments.putAll(item.getEnchantments()); } if (item.getType().toString().toLowerCase().contains("leather") && item.getItemMeta() instanceof LeatherArmorMeta) { LeatherArmorMeta lam = (LeatherArmorMeta) item.getItemMeta(); this.color = lam.getColor(); } } public ItemStack build() { ItemStack stack = new ItemStack(this.type, this.amount, (short) this.data); ItemMeta im = stack.getItemMeta(); if (this.title != null && !this.title.equals("")) { im.setDisplayName(this.title); } if (this.lore != null && !this.lore.isEmpty()) { im.setLore(this.lore); } if (this.color != null && this.type.toString().toLowerCase().contains("leather")) { ((LeatherArmorMeta) im).setColor(this.color); } stack.setItemMeta(im); if (this.enchantments != null && !this.enchantments.isEmpty()) { stack.addUnsafeEnchantments(this.enchantments); } net.minecraft.server.v1_8_R3.ItemStack nmsStack = CraftItemStack.asNMSCopy(stack); if (nbt != null) { nmsStack.setTag(nbt); } return CraftItemStack.asCraftMirror(nmsStack); } public ItemMaker addLore(String... lore) { for (String s : lore) { this.lore.add(ChatColor.translateAlternateColorCodes('&', (s))); } return this; }