Advertisement
Guest User

Disco2

a guest
Dec 19th, 2014
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.66 KB | None | 0 0
  1. package pl.boomdroom;
  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.  
  12. public class DiscoArmor{
  13.    
  14.     public DiscoArmor(Main instance){}
  15.    
  16.     public static void DA(){
  17.         Bukkit.getScheduler().scheduleSyncRepeatingTask(Main.instance, new Runnable(){
  18.             private Random r = new Random();
  19.             public void run(){
  20.                 Color c = Color.fromRGB(r.nextInt(255), r.nextInt(255), r.nextInt(255));
  21.                
  22.                 for(Player p : Bukkit.getOnlinePlayers()){
  23.                     if(p.getInventory().getHelmet() !=null){
  24.                         if(p.getInventory().getHelmet().getType().equals(Material.LEATHER_HELMET)){
  25.                             p.getInventory().setHelmet(CA(Material.LEATHER_HELMET, c));
  26. }
  27. }
  28.                     if(p.getInventory().getLeggings() !=null){
  29.                         if(p.getInventory().getLeggings().getType().equals(Material.LEATHER_LEGGINGS)){
  30.                             p.getInventory().setLeggings(CA(Material.LEATHER_LEGGINGS, c));
  31. }
  32. }
  33.                     if(p.getInventory().getChestplate() !=null){
  34.                         if(p.getInventory().getChestplate().getType().equals(Material.LEATHER_CHESTPLATE)){
  35.                             p.getInventory().setChestplate(CA(Material.LEATHER_CHESTPLATE, c));
  36. }
  37. }
  38.                     if(p.getInventory().getBoots() !=null){
  39.                         if(p.getInventory().getBoots().getType().equals(Material.LEATHER_BOOTS)){
  40.                             p.getInventory().setBoots(CA(Material.LEATHER_BOOTS, c));
  41. }
  42. }              
  43.         }, 20, 10);
  44.        
  45.         private ItemStack CA(Material m, Color c){
  46.             ItemStack i = new ItemStack(m, 1);
  47.             LeatherArmorMeta im = (LeatherArmorMeta) i.getItemMeta();
  48.             im.setColor(c);
  49.             i.setItemMeta(im);
  50. }  
  51. }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement