Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class CosmeticTask extends BukkitRunnable {
- private ItemStack getColorArmor(Material m, Color c) {
- ItemStack i = new ItemStack(m, 1); {
- LeatherArmorMeta meta = (LeatherArmorMeta) i.getItemMeta();
- meta.setColor(c);
- i.setItemMeta(meta);
- }
- return i;
- }
- private String stripDisplayName(ItemStack i) {
- return ChatColor.stripColor(i.getItemMeta().getDisplayName());
- }
- @Override
- public void run() {
- Random r = ThreadLocalRandom.current();
- Color c = Color.fromRGB(r.nextInt(255), r.nextInt(255), r.nextInt(255));
- for (Player p : Bukkit.getServer().getOnlinePlayers()) {
- ItemStack helmet = p.getInventory().getHelmet();
- ItemStack chestplate = p.getInventory().getChestplate();
- ItemStack leggings = p.getInventory().getLeggings();
- ItemStack boots = p.getInventory().getBoots();
- if (helmet != null && helmet.getType().equals(Material.LEATHER_HELMET)) {
- p.getInventory().setHelmet(getColorArmor(Material.LEATHER_HELMET, c));
- }
- if (chestplate != null && chestplate.getType().equals(Material.LEATHER_CHESTPLATE)) {
- p.getInventory().setChestplate(getColorArmor(Material.LEATHER_CHESTPLATE, c));
- }
- if (leggings != null && leggings.getType().equals(Material.LEATHER_LEGGINGS)) {
- p.getInventory().setLeggings(getColorArmor(Material.LEATHER_LEGGINGS, c));
- }
- if (boots != null && boots.getType().equals(Material.LEATHER_BOOTS)) {
- p.getInventory().setBoots(getColorArmor(Material.LEATHER_BOOTS, c));
- }
- // if (p.getInventory().getHelmet() != null && p.getInventory().getHelmet().getType() == Material.LEATHER_HELMET && ChatColor.stripColor(p.getInventory().getHelmet().getItemMeta().getDisplayName()).equalsIgnoreCase("Reward Helmet")) {
- // p.getInventory().setHelmet(getColorArmor(Material.LEATHER_HELMET, c));
- // }
- //
- // if (p.getInventory().getChestplate() != null && p.getInventory().getChestplate().getType() == Material.LEATHER_CHESTPLATE && ChatColor.stripColor(p.getInventory().getChestplate().getItemMeta().getDisplayName()).equalsIgnoreCase("Reward Chestplate")) {
- // p.getInventory().setChestplate(getColorArmor(Material.LEATHER_CHESTPLATE, c));
- // }
- //
- // if (p.getInventory().getLeggings() != null && p.getInventory().getLeggings().getType() == Material.LEATHER_LEGGINGS && ChatColor.stripColor(p.getInventory().getLeggings().getItemMeta().getDisplayName()).equalsIgnoreCase("Reward Leggings")) {
- // p.getInventory().setLeggings(getColorArmor(Material.LEATHER_LEGGINGS, c));
- // }
- //
- // if (p.getInventory().getBoots() != null && p.getInventory().getBoots().getType() == Material.LEATHER_BOOTS && ChatColor.stripColor(p.getInventory().getBoots().getItemMeta().getDisplayName()).equalsIgnoreCase("Reward Boots")) {
- // p.getInventory().setBoots(getColorArmor(Material.LEATHER_BOOTS, c));
- // }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement