@Override public void apply(Player player, MatchTeam matchTeam) { // Set leather armor in armor slots to team color if not set initially if (slot >= 100 && !hasColor && itemStack.getType().toString().contains("LEATHER_")) { LeatherArmorMeta leatherArmorMeta = (LeatherArmorMeta) itemStack.getItemMeta(); leatherArmorMeta.setColor(ColorConverter.getColor(matchTeam.getColor())); itemStack.setItemMeta(leatherArmorMeta); } if (slot == 100) player.getInventory().setBoots(itemStack); else if (slot == 101) player.getInventory().setLeggings(itemStack); else if (slot == 102) player.getInventory().setChestplate(itemStack); else if (slot == 103) player.getInventory().setHelmet(itemStack); else if (slot == -106) player.getInventory().setItemInOffHand(itemStack); else player.getInventory().setItem(slot, itemStack); }
public static CustomBlockTexture extractTextureFromEntity(ArmorStand e) { CustomBlockTexture t = new CustomBlockTexture(); short tex = (short) e.getHelmet().getDurability(); Color c = ((LeatherArmorMeta) e.getHelmet().getItemMeta()).getColor(); boolean g = e.getHelmet().containsEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL); t.setLayerPrimary(tex, c, g); if (e.getEquipment().getItemInMainHand() == null) { return t; } short tex2 = (short) e.getEquipment().getItemInMainHand().getDurability(); Color c2 = ((LeatherArmorMeta) e.getEquipment().getItemInMainHand().getItemMeta()).getColor(); boolean g2 = e.getEquipment().getItemInMainHand().containsEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL); t.setLayerSecondary(tex2, c2, g2); return t; }
/** * Get the final {@link ItemStack} with all the attributes you have been adding * * @return the {@link ItemStack} of this {@link ItemBuilder} */ @Override public ItemStack build() { ItemStack s = new ItemStack(this.getMaterial()); s.setAmount(this.getAmount()); s.setDurability(this.getDamage()); LeatherArmorMeta m = (LeatherArmorMeta) s.getItemMeta(); for (ItemFlag iflag : this.getAllItemflags()) { m.addItemFlags(iflag); } m.setDisplayName(this.getName()); m.setLore(this.getLore()); m.setColor(color); s.setItemMeta(m); for (Map.Entry<Enchantment, Integer> temp : this.getAllEnchantments().entrySet()) { s.addUnsafeEnchantment(temp.getKey(), temp.getValue()); } return s; }
public static ItemMeta parse(Element xml, ItemMeta source) { if (source instanceof BannerMeta) { return parseBanner(xml, (BannerMeta) source); } else if (source instanceof BookMeta) { return parseBook(xml, (BookMeta) source); } else if (source instanceof EnchantmentStorageMeta) { return parseEnchantmentStorage(xml, (EnchantmentStorageMeta) source); } else if (source instanceof FireworkMeta) { return parseFirework(xml, (FireworkMeta) source); } else if (source instanceof FireworkEffectMeta) { return parseFireworkEffect(xml, (FireworkEffectMeta) source); } else if (source instanceof LeatherArmorMeta) { return parseLeatherArmor(xml, (LeatherArmorMeta) source); } else if (source instanceof MapMeta) { return parseMap(xml, (MapMeta) source); } else if (source instanceof PotionMeta) { return parsePotion(xml, (PotionMeta) source); } else if (source instanceof SkullMeta) { return parseSkull(xml, (SkullMeta) source); } else if (source instanceof SpawnEggMeta) { return parseSpawnEgg(xml, (SpawnEggMeta) source); } return source; }
public static boolean isConvertable(ItemStack is) { if (is.hasItemMeta()) { ItemMeta im = is.getItemMeta(); if (im instanceof LeatherArmorMeta) try { Integer.parseInt(im.getLore().get(0).substring(15)); return true; } catch (Exception e) { } } return false; }
private static ItemStack[] coloredArmor(AnniTeam team) { Color c; if(team.getColor() == ChatColor.RED) c = Color.RED; else if(team.getColor() == ChatColor.BLUE) c = Color.BLUE; else if(team.getColor() == ChatColor.GREEN) c = Color.GREEN; else c = Color.YELLOW; ItemStack[] stacks = KitUtils.getLeatherArmor(); for(ItemStack stack : stacks) { LeatherArmorMeta meta = (LeatherArmorMeta) stack.getItemMeta(); meta.setColor(c); stack.setItemMeta(meta); } return stacks; }
public boolean disguise(Player player, String teamName) { if (!isValid(teamName)) { return false; } Team team = teams.get(teamName); ItemStack tshirt = new ItemStack(Material.LEATHER_CHESTPLATE); LeatherArmorMeta tShirtMeta = (LeatherArmorMeta) tshirt.getItemMeta(); tShirtMeta.setColor(team.tshirtColor); tShirtMeta.setDisplayName(team.chatColor + team.tshirtName); backToNormal(player, false); player.setDisplayName(team.chatColor + player.getName()); tshirt.setItemMeta(tShirtMeta); player.getInventory().setChestplate(tshirt); player.setGameMode(GameMode.ADVENTURE); TagAPI.refreshPlayer(player); _disguisedPlayers_mutex.lock(); try { disguisedPlayers.put(player, team); } finally { _disguisedPlayers_mutex.unlock(); } score.scoreTeams.get(teamName).addPlayer(player); updateScoreboards(); return true; }
public ItemStack build() { Material mat = this.mat; if (mat == null) { mat = Material.AIR; Bukkit.getLogger().warning("Null material!"); } ItemStack item = new ItemStack(this.mat, this.amount, this.data); ItemMeta meta = item.getItemMeta(); if (this.title != null) { meta.setDisplayName(this.title); } if (!this.lore.isEmpty()) { meta.setLore(this.lore); } if (meta instanceof LeatherArmorMeta) { ((LeatherArmorMeta) meta).setColor(this.color); } item.setItemMeta(meta); item.addUnsafeEnchantments(this.enchants); if (this.potion != null) { this.potion.apply(item); } return item; }
/** * Sets lore to a players armor * * @param player {@code ItemMeta} to set lore for armor * @param str Lore string */ public static void setLore(Player player, String str) { List<String> lores = new ArrayList<String>(); ItemStack[] armor = player.getInventory().getArmorContents(); lores.add(str); ItemMeta meta; for (ItemStack is : armor) { if (is != null && (meta = is.getItemMeta()) instanceof LeatherArmorMeta) { if (meta.hasLore()) { List<String> localAdd = new ArrayList<String>(); for (String l : meta.getLore()) { if (!l.startsWith(Lang.TITLE_PREFIX.toString() + "|")) { localAdd.add(l); } } lores.addAll(localAdd); } meta.setLore(lores); is.setItemMeta(meta); } } }
@Override public void run() { Color c = getNext(player.getHealth()); if(last == c) { // dont update armor if health didnt change return; } for (ItemStack is : inv.getArmorContents()){ if (is != null && is.getItemMeta() instanceof LeatherArmorMeta) { if (!Utility.isWorthy(is.getItemMeta())) { continue; } LeatherArmorMeta lam = (LeatherArmorMeta) is.getItemMeta(); lam.setColor(c); is.setItemMeta(lam); } } }
/** * Gets a String representing all special meta of this ItemStack, if any. * * @param is the ItemStack * @param separators the separators * * @return a String representing this ItemStack's special meta or an empty String * * @throws InventoryUtilException if something goes wrong */ public static String getSpecialMetaString(final ItemStack is, final String[] separators) throws InventoryUtilException { final ItemMeta meta = is.getItemMeta(); if (meta instanceof BookMeta) { return getBookMetaString((BookMeta)meta); } else if (meta instanceof EnchantmentStorageMeta) { return getEnchantmentStorageMetaString((EnchantmentStorageMeta)meta, separators); } else if (meta instanceof FireworkEffectMeta) { return getFireworkEffectMetaString((FireworkEffectMeta)meta); } else if (meta instanceof FireworkMeta) { return getFireworkMetaString((FireworkMeta)meta, separators); } else if (meta instanceof LeatherArmorMeta) { return getLeatherArmorMetaString((LeatherArmorMeta)meta); } else if (meta instanceof MapMeta) { return getMapMetaString((MapMeta)meta); } else if (meta instanceof PotionMeta) { return getPotionMetaString((PotionMeta)meta, separators); } else if (meta instanceof SkullMeta) { return getSkullMetaString((SkullMeta)meta); } else { throw new InventoryUtilException("Unknown Meta type '" + meta.getClass().getName() + "', please report this to the author (Ribesg)!"); } }
public void reload() { fake.setContents(real.getContents()); Iterator<ItemStack> it = fake.iterator(); while (it.hasNext()) { ItemStack item = it.next(); RPGItem rItem = ItemManager.toRPGItem(item); if (rItem == null) continue; item.setType(rItem.getItem()); ItemMeta meta = rItem.getLocaleMeta(locale); if (!(meta instanceof LeatherArmorMeta) && rItem.getItem().isBlock()) item.setDurability(rItem.getDataValue()); item.setItemMeta(meta); } fake.setContents(fake.getContents()); }
@CommandString("rpgitem $n[] item $m[] $data:i[]") @CommandDocumentation("$command.rpgitem.item.set.data") @CommandGroup("item_item") public void setItemItem(CommandSender sender, RPGItem item, Material material, int data) { String locale = sender instanceof Player ? Locale.getPlayerLocale((Player) sender) : "en_GB"; item.setItem(material, false); ItemMeta meta = item.getLocaleMeta(locale); if (meta instanceof LeatherArmorMeta) { ((LeatherArmorMeta) meta).setColor(Color.fromRGB(data)); } else { item.setDataValue((short) data); } for (String locales : Locale.getLocales()) { item.setLocaleMeta(locales, meta.clone()); } item.rebuild(); sender.sendMessage(ChatColor.AQUA + String.format(Locale.get("message.item.set", locale), item.getName(), item.getItem(), item.getDataValue())); ItemManager.save(Plugin.plugin); }
@CommandString("rpgitem $n[] item $m[] hex $hexcolour:s[]") @CommandDocumentation("$command.rpgitem.item.set.data.hex") @CommandGroup("item_item") public void setItemItem(CommandSender sender, RPGItem item, Material material, String hexColour) { String locale = sender instanceof Player ? Locale.getPlayerLocale((Player) sender) : "en_GB"; int dam; try { dam = Integer.parseInt((String) hexColour, 16); } catch (NumberFormatException e) { sender.sendMessage(ChatColor.RED + "Failed to parse " + hexColour); return; } item.setItem(material, true); ItemMeta meta = item.getLocaleMeta(locale); if (meta instanceof LeatherArmorMeta) { ((LeatherArmorMeta) meta).setColor(Color.fromRGB(dam)); } else { item.setDataValue((short) dam); } for (String locales : Locale.getLocales()) { item.setLocaleMeta(locales, meta.clone()); } item.rebuild(); sender.sendMessage(ChatColor.AQUA + String.format(Locale.get("message.item.set", locale), item.getName(), item.getItem(), item.getDataValue())); ItemManager.save(Plugin.plugin); }
@CommandString("rpgitem $n[] item $itemid:i[] $data:i[]") @CommandDocumentation("$command.rpgitem.item.set.id.data") @CommandGroup("item_item") public void setItemItem(CommandSender sender, RPGItem item, int id, int data) { String locale = sender instanceof Player ? Locale.getPlayerLocale((Player) sender) : "en_GB"; Material mat = Material.getMaterial(id); if (mat == null) { sender.sendMessage(ChatColor.RED + Locale.get("message.item.cant.find", locale)); return; } item.setItem(mat, true); ItemMeta meta = item.toItemStack(locale).getItemMeta(); if (meta instanceof LeatherArmorMeta) { ((LeatherArmorMeta) meta).setColor(Color.fromRGB(data)); } else { item.setDataValue((short) data); } for (String locales : Locale.getLocales()) { item.setLocaleMeta(locales, meta); } item.rebuild(); sender.sendMessage(ChatColor.AQUA + String.format(Locale.get("message.item.set", locale), item.getName(), item.getItem(), item.getDataValue())); ItemManager.save(Plugin.plugin); }
/** * Adds color to LeatherArmorMeta * * @param meta ItemMeta to change * @param config Config to read from * @throws Exception if there was an error */ private void addLeatherArmorMeta(ItemMeta meta, ConfigurationSection config) throws Exception { if (!config.contains(LEATHER_ARMOR)) { return; } String color = config.getString(LEATHER_ARMOR); String[] rgb = color.split(","); if (rgb.length < 3) { throw new Exception("Color tag '" + color + "' is invalid"); } ((LeatherArmorMeta) meta).setColor( Color.fromRGB(Integer.parseInt(rgb[0]), Integer.parseInt(rgb[1]), Integer.parseInt(rgb[2]))); }
@CommandString("rpgitem $n[] item $m[] $data:i[]") @CommandDocumentation("$command.rpgitem.item.set.data") @CommandGroup("item_item") public void setItemItem(CommandSender sender, RPGItem item, Material material, int data) { String locale = Locale.getPlayerLocale((Player) sender); item.setItem(material, false); ItemMeta meta = item.getLocaleMeta(locale); if (meta instanceof LeatherArmorMeta) { ((LeatherArmorMeta) meta).setColor(Color.fromRGB(data)); } else { item.setDataValue((short) data); } for (String locales : Locale.getLocales()) { item.setLocaleMeta(locales, meta.clone()); } item.rebuild(); sender.sendMessage(ChatColor.AQUA + String.format(Locale.get("message.item.set", locale), item.getName(), item.getItem(), item.getDataValue())); ItemManager.save(Plugin.plugin); }
@CommandString("rpgitem $n[] item $m[] hex $hexcolour:s[]") @CommandDocumentation("$command.rpgitem.item.set.data.hex") @CommandGroup("item_item") public void setItemItem(CommandSender sender, RPGItem item, Material material, String hexColour) { String locale = Locale.getPlayerLocale((Player) sender); int dam; try { dam = Integer.parseInt((String) hexColour, 16); } catch (NumberFormatException e) { sender.sendMessage(ChatColor.RED + "Failed to parse " + hexColour); return; } item.setItem(material, true); ItemMeta meta = item.getLocaleMeta(locale); if (meta instanceof LeatherArmorMeta) { ((LeatherArmorMeta) meta).setColor(Color.fromRGB(dam)); } else { item.setDataValue((short) dam); } for (String locales : Locale.getLocales()) { item.setLocaleMeta(locales, meta.clone()); } item.rebuild(); sender.sendMessage(ChatColor.AQUA + String.format(Locale.get("message.item.set", locale), item.getName(), item.getItem(), item.getDataValue())); ItemManager.save(Plugin.plugin); }
@CommandString("rpgitem $n[] item $itemid:i[] $data:i[]") @CommandDocumentation("$command.rpgitem.item.set.id.data") @CommandGroup("item_item") public void setItemItem(CommandSender sender, RPGItem item, int id, int data) { String locale = Locale.getPlayerLocale((Player) sender); Material mat = Material.getMaterial(id); if (mat == null) { sender.sendMessage(ChatColor.RED + Locale.get("message.item.cant.find", locale)); return; } item.setItem(mat, true); ItemMeta meta = item.toItemStack(locale).getItemMeta(); if (meta instanceof LeatherArmorMeta) { ((LeatherArmorMeta) meta).setColor(Color.fromRGB(data)); } else { item.setDataValue((short) data); } for (String locales : Locale.getLocales()) { item.setLocaleMeta(locales, meta); } item.rebuild(); sender.sendMessage(ChatColor.AQUA + String.format(Locale.get("message.item.set", locale), item.getName(), item.getItem(), item.getDataValue())); ItemManager.save(Plugin.plugin); }
@Override public void processMeta(Player player, ItemMeta m) { super.processMeta(player, m); LeatherArmorMeta meta = (LeatherArmorMeta) m; if(color != null) meta.setColor(color.resolve(player)); }
@Override public ItemStack generate() { ItemStack item = new ItemStack(material); ItemMeta im = item.getItemMeta(); // prepend reset to clear the default name coloring im.setDisplayName(ChatColor.RESET + name); // Get lore from string List<String> lore = stats.lore(); if (soulbound) { lore.add(ChatColor.RED + ChatColor.ITALIC.toString() + "Soulbound"); } // Get description, if it exists if (description != null && description.length() > 0) { if (lore.size() > 0 && lore.get(lore.size() - 1).length() > 0) lore.add(""); lore.addAll(RFormatter.stringToLore(description, ChatColor.GRAY)); } im.setLore(lore); im.addItemFlags(ItemFlag.HIDE_ATTRIBUTES); im.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS); im.addItemFlags(ItemFlag.HIDE_DESTROYS); im.addItemFlags(ItemFlag.HIDE_ENCHANTS); im.addItemFlags(ItemFlag.HIDE_PLACED_ON); im.addItemFlags(ItemFlag.HIDE_UNBREAKABLE); // Add color for leather armors if (leatherColor != null) { ((LeatherArmorMeta) im).setColor(leatherColor); } item.setItemMeta(im); return item; }
public ArmorStand placeBlock(Location l) { ArmorStand block = (ArmorStand) l.getWorld().spawnEntity(l, EntityType.ARMOR_STAND); block.setSmall(true); block.setGravity(false); block.setCustomName("CustomBlock"); block.setCustomNameVisible(false); block.setInvulnerable(true); block.setVisible(false); block.setMarker(true); block.setSilent(true); ItemStack a = new ItemStack(Material.LEATHER_BOOTS); a.setDurability((short) primary.getTexture()); LeatherArmorMeta am = (LeatherArmorMeta) a.getItemMeta(); am.setColor(primary.getColor()); am.setUnbreakable(true); if (primary.isGlowing()) { am.addEnchant(Enchantment.PROTECTION_ENVIRONMENTAL, 3, true); } a.setItemMeta(am); block.setHelmet(a); if (secondary != null) { ItemStack b = new ItemStack(Material.LEATHER_BOOTS); b.setDurability((short) secondary.getTexture()); LeatherArmorMeta bm = (LeatherArmorMeta) b.getItemMeta(); bm.setColor(secondary.getColor()); bm.setUnbreakable(true); if (secondary.isGlowing()) { System.out.println("H"); bm.addEnchant(Enchantment.PROTECTION_ENVIRONMENTAL, 3, true); } b.setItemMeta(bm); block.getEquipment().setItemInMainHand(b); } return block; }
private ItemStack createTeamJoinButton(final MatchPlayer player, final Team team) { ItemStack item = new ItemStack(Button.TEAM_JOIN.material); String capacityMessage = this.getTeamSizeDescription(team.getPlayers().size(), team.getMaxPlayers()); List<String> lore = Lists.newArrayList(capacityMessage); final JoinResult result = jmm.queryJoin(player, JoinRequest.user(team)); if(result.isAllowed()) { final String label = result.isRejoin() ? "teamSelection.picker.clickToRejoin" : "teamSelection.picker.clickToJoin"; lore.add(renderer.renderLegacy(new Component(new TranslatableComponent(label), ChatColor.GREEN), player.getBukkit())); } else if(result.message().isPresent()) { lore.add(renderer.renderLegacy(new Component(result.message().get(), ChatColor.RED), player.getBukkit())); result.extra().forEach(line -> { lore.add(renderer.renderLegacy(line, player.getBukkit())); }); } LeatherArmorMeta meta = (LeatherArmorMeta) item.getItemMeta(); meta.addItemFlags(ItemFlag.values()); meta.setColor(team.getFullColor()); meta.setDisplayName(team.getColor().toString() + ChatColor.BOLD + team.getName()); meta.setLore(lore); meta.addItemFlags(ItemFlag.values()); // Hides a lot more than potion effects item.setItemMeta(meta); return item; }
private ItemStack colorArmor(ItemStack stack, Color color) { LeatherArmorMeta meta = (LeatherArmorMeta) stack.getItemMeta(); meta.setColor(color); stack.setItemMeta(meta); return stack; }
public static ItemStack createColouredArmour(Material m, Color colour) { ItemStack i = new ItemStack(m); i = applyItemFlags(i); LeatherArmorMeta lam = (LeatherArmorMeta) i.getItemMeta(); lam.setColor(colour); i.setItemMeta(lam); return i; }
public static ItemStack createColouredArmour(Material m, Color colour, String n, List<String> l) { ItemStack i = new ItemStack(m); i = applyItemFlags(i); LeatherArmorMeta lam = (LeatherArmorMeta) i.getItemMeta(); lam.setDisplayName(n); lam.setLore(l); lam.setColor(colour); i.setItemMeta(lam); return i; }
public static ItemStack createColouredArmour(Material m, Color colour, String n) { ItemStack i = new ItemStack(m); i = applyItemFlags(i); LeatherArmorMeta lam = (LeatherArmorMeta) i.getItemMeta(); lam.setDisplayName(n); lam.setColor(colour); i.setItemMeta(lam); return i; }
public static ItemStack setArmourColour(ItemStack i, Color c) { Material t = i.getType(); if (!(t == Material.LEATHER_HELMET || t == Material.LEATHER_CHESTPLATE || t == Material.LEATHER_LEGGINGS || t == Material.LEATHER_BOOTS)) { return i; } LeatherArmorMeta m = (LeatherArmorMeta) i.getItemMeta(); m.setColor(c); i.setItemMeta(m); i = applyItemFlags(i); return i; }
/** * Sets the color of the itemStack. Only works on leatherItems * * @param color color * @return itemStack */ public ItemStackBuilder setColor(Color color) { if (this.getItemMeta() instanceof LeatherArmorMeta) { final LeatherArmorMeta meta = (LeatherArmorMeta) this.getItemMeta(); meta.setColor(color); this.setItemMeta(meta); } return this; }
/** * Paint a given ItemStack into gray * * @param stack Leather armor part * * @return Colored leather armor part */ public ItemStack getArmor(ItemStack stack) { LeatherArmorMeta meta = (LeatherArmorMeta) stack.getItemMeta(); meta.setColor(Color.GRAY); stack.setItemMeta(meta); return stack; }
@Override public SubMeta setFrom(ItemMeta meta) { if(meta instanceof LeatherArmorMeta){ color = new RGBColor(((LeatherArmorMeta)meta).getColor()); } return this; }
private void setWardenInv(Player target) throws SQLException { RankManager.setGuardLevel(target, 2); RankManager.setWantedLevel(target, 0); target.getInventory().clear(); ItemStack boots = new ItemStack(Material.LEATHER_BOOTS); LeatherArmorMeta bootsMeta = (LeatherArmorMeta)boots.getItemMeta(); bootsMeta.setColor(Color.fromRGB(224, 33, 15)); boots.setItemMeta(bootsMeta); target.getInventory().setBoots(boots); ItemStack leggings = new ItemStack(Material.LEATHER_LEGGINGS); LeatherArmorMeta leggingsMeta = (LeatherArmorMeta)leggings.getItemMeta(); leggingsMeta.setColor(Color.fromRGB(224, 33, 15)); leggings.setItemMeta(leggingsMeta); target.getInventory().setLeggings(leggings); ItemStack chest = new ItemStack(Material.LEATHER_CHESTPLATE); LeatherArmorMeta chestMeta = (LeatherArmorMeta)chest.getItemMeta(); chestMeta.setColor(Color.fromRGB(224, 33, 15)); chest.setItemMeta(chestMeta); target.getInventory().setChestplate(chest); ItemStack helmet = new ItemStack(Material.LEATHER_HELMET); LeatherArmorMeta helmetMeta = (LeatherArmorMeta)helmet.getItemMeta(); helmetMeta.setColor(Color.fromRGB(224, 33, 15)); helmet.setItemMeta(helmetMeta); target.getInventory().setHelmet(helmet); try{ ScrapsUtil.setScraps(target, ScrapsUtil.getScraps(target)); } catch(SQLException e){ e.printStackTrace(); } }
private void setGuardInv(Player target) throws SQLException { RankManager.setGuardLevel(target, 1); RankManager.setWantedLevel(target, 0); target.getInventory().clear(); ItemStack boots = new ItemStack(Material.LEATHER_BOOTS); LeatherArmorMeta bootsMeta = (LeatherArmorMeta)boots.getItemMeta(); bootsMeta.setColor(Color.fromRGB(145, 0, 0)); boots.setItemMeta(bootsMeta); target.getInventory().setBoots(boots); ItemStack leggings = new ItemStack(Material.LEATHER_LEGGINGS); LeatherArmorMeta leggingsMeta = (LeatherArmorMeta)leggings.getItemMeta(); leggingsMeta.setColor(Color.fromRGB(145, 0, 0)); leggings.setItemMeta(leggingsMeta); target.getInventory().setLeggings(leggings); ItemStack chest = new ItemStack(Material.LEATHER_CHESTPLATE); LeatherArmorMeta chestMeta = (LeatherArmorMeta)chest.getItemMeta(); chestMeta.setColor(Color.fromRGB(145, 0, 0)); chest.setItemMeta(chestMeta); target.getInventory().setChestplate(chest); ItemStack helmet = new ItemStack(Material.LEATHER_HELMET); LeatherArmorMeta helmetMeta = (LeatherArmorMeta)helmet.getItemMeta(); helmetMeta.setColor(Color.fromRGB(145, 0, 0)); helmet.setItemMeta(helmetMeta); target.getInventory().setHelmet(helmet); }
/** * Sets the color of the itemStack. Only works on leatherItems * * @param color color * @return builder */ public ItemStackBuilder setColor(Color color) { if (this.getItemMeta() instanceof LeatherArmorMeta) { final LeatherArmorMeta meta = (LeatherArmorMeta) this.getItemMeta(); meta.setColor(color); this.setItemMeta(meta); } return this; }
public static ItemStack createColoredArmor(Armor armor, Color color, String name) { ItemStack leatherArmor = new ItemStack(armor.getMaterial()); LeatherArmorMeta meta = (LeatherArmorMeta) leatherArmor.getItemMeta(); meta.setColor(color); if(name != null) meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name)); leatherArmor.setItemMeta(meta); return leatherArmor; }
public static ItemStack createLeatherArmor(Material material, int amount, String name, List<String> lore, Color color) { ItemStack item = createItem(material, amount, (short) 0, name, lore); LeatherArmorMeta meta = (LeatherArmorMeta) item.getItemMeta(); meta.setColor(color); item.setItemMeta(meta); return item; }