Advertisement
Guest User

Amor RainBow

a guest
Mar 30th, 2015
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.37 KB | None | 0 0
  1. private ItemStack getColorArmor(Material m, Color c) {
  2. ItemStack i = new ItemStack(m, 1);
  3. if (main.getConfig().getBoolean("Enchantments on Discoarmour"))
  4. i.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
  5. LeatherArmorMeta meta = (LeatherArmorMeta) i.getItemMeta();
  6. meta.setColor(c);
  7. i.setItemMeta(meta);
  8. return i;
  9. }
  10.  
  11. public static int helmet;
  12. public static int chestplate;
  13. public static int leggings;
  14. public static int boots;
  15.  
  16. @EventHandler
  17. public void onClick(InventoryClickEvent e) {
  18. final Player p = (Player) e.getWhoClicked();
  19. if (e.getInventory()
  20. .getName()
  21. .equalsIgnoreCase(
  22. "" + ChatColor.DARK_PURPLE + ChatColor.BOLD
  23. + "Main Menu")) {
  24. e.setCancelled(true);
  25. if (e.getCurrentItem() == null) {
  26.  
  27. return;
  28. }
  29.  
  30. if (e.getCurrentItem() != null
  31. && e.getCurrentItem().hasItemMeta()
  32. && e.getCurrentItem().getItemMeta().hasDisplayName()
  33. && e.getCurrentItem()
  34. .getItemMeta()
  35. .getDisplayName()
  36. .contains(
  37. "" + ChatColor.AQUA + ChatColor.BOLD
  38. + "Disco Armour")) {
  39. if (!p.hasPermission("wardrobe.discoarmour")) {
  40. p.sendMessage(ChatColor.DARK_RED + "No permission!");
  41. return;
  42. } else {
  43. p.getWorld().playSound(p.getLocation(),
  44. Sound.FIREWORK_TWINKLE2, 1, 1);
  45. Bukkit.getScheduler().cancelTask(helmet);
  46. Bukkit.getScheduler().cancelTask(chestplate);
  47. Bukkit.getScheduler().cancelTask(leggings);
  48. Bukkit.getScheduler().cancelTask(boots);
  49.  
  50. p.getInventory().setHelmet(
  51. new ItemStack(Material.LEATHER_HELMET));
  52. p.getInventory().setChestplate(
  53. new ItemStack(Material.LEATHER_CHESTPLATE));
  54. p.getInventory().setLeggings(
  55. new ItemStack(Material.LEATHER_LEGGINGS));
  56. p.getInventory().setBoots(
  57. new ItemStack(Material.LEATHER_BOOTS));
  58.  
  59. p.closeInventory();
  60.  
  61. helmet = Bukkit.getServer().getScheduler()
  62. .scheduleSyncRepeatingTask(main, new Runnable() {
  63. private Random r = new Random();
  64.  
  65. public void run() {
  66. Color c = Color.fromRGB(r.nextInt(255),
  67. r.nextInt(255), r.nextInt(255));
  68.  
  69. if (p.getInventory().getHelmet() != null
  70. && p.getInventory().getHelmet()
  71. .getType() == Material.LEATHER_HELMET) {
  72. p.getInventory()
  73. .setHelmet(
  74. getColorArmor(
  75. Material.LEATHER_HELMET,
  76. c));
  77. }
  78.  
  79. }
  80. }, 1, 8);
  81.  
  82. chestplate = Bukkit.getServer().getScheduler()
  83. .scheduleSyncRepeatingTask(main, new Runnable() {
  84. private Random r = new Random();
  85.  
  86. public void run() {
  87. Color c2 = Color.fromRGB(r.nextInt(255),
  88. r.nextInt(255), r.nextInt(255));
  89.  
  90. if (p.getInventory().getChestplate() != null
  91. && p.getInventory().getChestplate()
  92. .getType() == Material.LEATHER_CHESTPLATE) {
  93. p.getInventory()
  94. .setChestplate(
  95. getColorArmor(
  96. Material.LEATHER_CHESTPLATE,
  97. c2));
  98. }
  99. }
  100. }, 1, 8);
  101.  
  102. leggings = Bukkit.getServer().getScheduler()
  103. .scheduleSyncRepeatingTask(main, new Runnable() {
  104. private Random r = new Random();
  105.  
  106. @Override
  107. public void run() {
  108. Color c3 = Color.fromRGB(r.nextInt(255),
  109. r.nextInt(255), r.nextInt(255));
  110.  
  111. if (p.getInventory().getLeggings() != null
  112. && p.getInventory().getLeggings()
  113. .getType() == Material.LEATHER_LEGGINGS) {
  114. p.getInventory()
  115. .setLeggings(
  116. getColorArmor(
  117. Material.LEATHER_LEGGINGS,
  118. c3));
  119. }
  120. }
  121. }, 1, 8);
  122.  
  123. boots = Bukkit.getServer().getScheduler()
  124. .scheduleSyncRepeatingTask(main, new Runnable() {
  125. private Random r = new Random();
  126.  
  127. @Override
  128. public void run() {
  129. Color c4 = Color.fromRGB(r.nextInt(255),
  130. r.nextInt(255), r.nextInt(255));
  131.  
  132. if (p.getInventory().getBoots() != null
  133. && p.getInventory().getBoots()
  134. .getType() == Material.LEATHER_BOOTS) {
  135. p.getInventory().setBoots(
  136. getColorArmor(
  137. Material.LEATHER_BOOTS,
  138.  
  139. c4));
  140. }
  141. }
  142. }, 1, 8);
  143. }
  144.  
  145. }
  146. }
  147. }
  148. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement