Advertisement
Guest User

DiscoArmor

a guest
May 11th, 2014
4,450
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.77 KB | None | 0 0
  1. package me.pogostick29dev.discoarmor;
  2.  
  3. import java.util.Random;
  4.  
  5. import org.bukkit.Bukkit;
  6. import org.bukkit.Color;
  7. import org.bukkit.Material;
  8. import org.bukkit.entity.Player;
  9. import org.bukkit.inventory.ItemStack;
  10. import org.bukkit.inventory.meta.LeatherArmorMeta;
  11. import org.bukkit.plugin.java.JavaPlugin;
  12.  
  13. public class DiscoArmor extends JavaPlugin {
  14.    
  15.     public void onEnable() {
  16.         Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
  17.             private Random r = new Random();
  18.            
  19.             public void run() {
  20.                 Color c = Color.fromRGB(r.nextInt(255), r.nextInt(255), r.nextInt(255));
  21.                
  22.                 for (Player p : Bukkit.getServer().getOnlinePlayers()) {
  23.                     if (p.getInventory().getHelmet() != null && p.getInventory().getHelmet().getType() == Material.LEATHER_HELMET) {
  24.                         p.getInventory().setHelmet(getColorArmor(Material.LEATHER_HELMET, c));
  25.                     }
  26.                    
  27.                     if (p.getInventory().getChestplate() != null && p.getInventory().getChestplate().getType() == Material.LEATHER_CHESTPLATE) {
  28.                         p.getInventory().setChestplate(getColorArmor(Material.LEATHER_CHESTPLATE, c));
  29.                     }
  30.                    
  31.                     if (p.getInventory().getLeggings() != null && p.getInventory().getLeggings().getType() == Material.LEATHER_LEGGINGS) {
  32.                         p.getInventory().setLeggings(getColorArmor(Material.LEATHER_LEGGINGS, c));
  33.                     }
  34.                    
  35.                     if (p.getInventory().getBoots() != null && p.getInventory().getBoots().getType() == Material.LEATHER_BOOTS) {
  36.                         p.getInventory().setBoots(getColorArmor(Material.LEATHER_BOOTS, c));
  37.                     }
  38.                 }
  39.             }
  40.         }, 0, 1);
  41.     }
  42.    
  43.     private ItemStack getColorArmor(Material m, Color c) {
  44.         ItemStack i = new ItemStack(m, 1);
  45.         LeatherArmorMeta meta = (LeatherArmorMeta) i.getItemMeta();
  46.         meta.setColor(c);
  47.         i.setItemMeta(meta);
  48.         return i;
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement