Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private ItemStack getColorArmor(Material m, Color c) {
- ItemStack i = new ItemStack(m, 1);
- if (main.getConfig().getBoolean("Enchantments on Discoarmour"))
- i.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
- LeatherArmorMeta meta = (LeatherArmorMeta) i.getItemMeta();
- meta.setColor(c);
- i.setItemMeta(meta);
- return i;
- }
- public static int helmet;
- public static int chestplate;
- public static int leggings;
- public static int boots;
- @EventHandler
- public void onClick(InventoryClickEvent e) {
- final Player p = (Player) e.getWhoClicked();
- if (e.getInventory()
- .getName()
- .equalsIgnoreCase(
- "" + ChatColor.DARK_PURPLE + ChatColor.BOLD
- + "Main Menu")) {
- e.setCancelled(true);
- if (e.getCurrentItem() == null) {
- return;
- }
- if (e.getCurrentItem() != null
- && e.getCurrentItem().hasItemMeta()
- && e.getCurrentItem().getItemMeta().hasDisplayName()
- && e.getCurrentItem()
- .getItemMeta()
- .getDisplayName()
- .contains(
- "" + ChatColor.AQUA + ChatColor.BOLD
- + "Disco Armour")) {
- if (!p.hasPermission("wardrobe.discoarmour")) {
- p.sendMessage(ChatColor.DARK_RED + "No permission!");
- return;
- } else {
- p.getWorld().playSound(p.getLocation(),
- Sound.FIREWORK_TWINKLE2, 1, 1);
- Bukkit.getScheduler().cancelTask(helmet);
- Bukkit.getScheduler().cancelTask(chestplate);
- Bukkit.getScheduler().cancelTask(leggings);
- Bukkit.getScheduler().cancelTask(boots);
- p.getInventory().setHelmet(
- new ItemStack(Material.LEATHER_HELMET));
- p.getInventory().setChestplate(
- new ItemStack(Material.LEATHER_CHESTPLATE));
- p.getInventory().setLeggings(
- new ItemStack(Material.LEATHER_LEGGINGS));
- p.getInventory().setBoots(
- new ItemStack(Material.LEATHER_BOOTS));
- p.closeInventory();
- helmet = Bukkit.getServer().getScheduler()
- .scheduleSyncRepeatingTask(main, new Runnable() {
- private Random r = new Random();
- public void run() {
- Color c = Color.fromRGB(r.nextInt(255),
- r.nextInt(255), r.nextInt(255));
- if (p.getInventory().getHelmet() != null
- && p.getInventory().getHelmet()
- .getType() == Material.LEATHER_HELMET) {
- p.getInventory()
- .setHelmet(
- getColorArmor(
- Material.LEATHER_HELMET,
- c));
- }
- }
- }, 1, 8);
- chestplate = Bukkit.getServer().getScheduler()
- .scheduleSyncRepeatingTask(main, new Runnable() {
- private Random r = new Random();
- public void run() {
- Color c2 = Color.fromRGB(r.nextInt(255),
- r.nextInt(255), r.nextInt(255));
- if (p.getInventory().getChestplate() != null
- && p.getInventory().getChestplate()
- .getType() == Material.LEATHER_CHESTPLATE) {
- p.getInventory()
- .setChestplate(
- getColorArmor(
- Material.LEATHER_CHESTPLATE,
- c2));
- }
- }
- }, 1, 8);
- leggings = Bukkit.getServer().getScheduler()
- .scheduleSyncRepeatingTask(main, new Runnable() {
- private Random r = new Random();
- @Override
- public void run() {
- Color c3 = Color.fromRGB(r.nextInt(255),
- r.nextInt(255), r.nextInt(255));
- if (p.getInventory().getLeggings() != null
- && p.getInventory().getLeggings()
- .getType() == Material.LEATHER_LEGGINGS) {
- p.getInventory()
- .setLeggings(
- getColorArmor(
- Material.LEATHER_LEGGINGS,
- c3));
- }
- }
- }, 1, 8);
- boots = Bukkit.getServer().getScheduler()
- .scheduleSyncRepeatingTask(main, new Runnable() {
- private Random r = new Random();
- @Override
- public void run() {
- Color c4 = Color.fromRGB(r.nextInt(255),
- r.nextInt(255), r.nextInt(255));
- if (p.getInventory().getBoots() != null
- && p.getInventory().getBoots()
- .getType() == Material.LEATHER_BOOTS) {
- p.getInventory().setBoots(
- getColorArmor(
- Material.LEATHER_BOOTS,
- c4));
- }
- }
- }, 1, 8);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement