Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.immortal.core;
- import java.util.HashMap;
- import java.util.UUID;
- import org.bukkit.Material;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandSender;
- import org.bukkit.enchantments.Enchantment;
- import org.bukkit.entity.Player;
- import org.bukkit.inventory.ItemStack;
- import org.bukkit.plugin.java.JavaPlugin;
- import net.md_5.bungee.api.ChatColor;
- public class KitPVP extends JavaPlugin
- {
- private HashMap<UUID,Long> cooldownPVP = new HashMap<UUID, Long>();
- private HashMap<UUID,Long> cooldownElite = new HashMap<UUID, Long>();
- @Override
- public void onEnable()
- {
- System.out.println("KitPvP plugin has been enabled.");
- }
- @Override
- public void onDisable()
- {
- System.out.println("KitPvP plugin has been disabled.");
- }
- @Override
- public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
- {
- if(cmd.getName().equals("kit"))
- {
- if(sender instanceof Player)
- {
- Player p = (Player) sender;
- if(args.length == 0)
- {
- p.sendMessage(ChatColor.BLUE + "Kits: " + ChatColor.YELLOW + "PVP, Elite, God");
- return true;
- }
- if(args[0].equalsIgnoreCase("pvp"))
- {
- int cooldownSecondsTime = 20;
- if(cooldownPVP.containsKey(p.getUniqueId()))
- {
- long secondsLeft = ((cooldownPVP.get(p.getUniqueId()) / 1000) + cooldownSecondsTime) - (System.currentTimeMillis() / 1000);
- if(secondsLeft > 0)
- {
- p.sendMessage(ChatColor.RED + "KitPVP is on cooldown please wait " + secondsLeft + " seconds.");
- }
- }
- else
- {
- recoverItems(p); //Makes sure that the items you're wearing come to you're inventory
- equipPVPArmor(p);
- equipPVPWeapons(p);
- p.sendMessage(ChatColor.YELLOW + p.getName() + ChatColor.BLUE + " you have recieved Kit PVP!");
- cooldownPVP.put(p.getUniqueId(), System.currentTimeMillis());
- p.sendMessage(ChatColor.GREEN + "You now have a cooldown for " + cooldownSecondsTime + " seconds.");
- }
- }
- else if(args[0].equalsIgnoreCase("elite"))
- {
- p.sendMessage(ChatColor.YELLOW + p.getName() + ChatColor.BLUE + " you have recieved Kit Elite!");
- recoverItems(p); //Makes sure that the items you're wearing come to you're inventory
- equipEliteArmor(p);
- equipEliteWeapons(p);
- } else if(args[0].equalsIgnoreCase("god"))
- {
- p.sendMessage(ChatColor.YELLOW + p.getName() + ChatColor.BLUE + " you have recieved Kit God!");
- recoverItems(p); //Makes sure that the items you're wearing come to you're inventory
- equipGodArmor(p);
- equipGodWeapons(p);
- } else if(args[0].equalsIgnoreCase("op"))
- {
- p.sendMessage(ChatColor.YELLOW + p.getName() + ChatColor.BLUE + " you have recieved Kit OP!");
- recoverItems(p); //Makes sure that the items you're wearing come to you're inventory
- equipOPArmor(p);
- equipOPWeapons(p);
- }
- else
- {
- p.sendMessage(ChatColor.RED + "That kit does not exist");
- }
- } else
- {
- System.out.println("You cannot use this command through console");
- }
- }
- return true;
- }
- private void recoverItems(Player p)
- {
- if(p.getInventory().getHelmet() != null)
- {
- ItemStack helmet = p.getInventory().getHelmet();
- ItemStack recoveryItem = new ItemStack(helmet.getType());
- recoveryItem.setItemMeta(helmet.getItemMeta());
- recoveryItem.setDurability(helmet.getDurability());
- p.getInventory().addItem(recoveryItem);
- }
- if(p.getInventory().getChestplate() != null)
- {
- ItemStack chestplate = p.getInventory().getChestplate();
- ItemStack recoveryItem = new ItemStack(chestplate.getType());
- recoveryItem.setItemMeta(chestplate.getItemMeta());
- recoveryItem.setDurability(chestplate.getDurability());
- p.getInventory().addItem(recoveryItem);
- }
- if(p.getInventory().getLeggings() != null)
- {
- ItemStack leggings = p.getInventory().getLeggings();
- ItemStack recoveryItem = new ItemStack(leggings.getType());
- recoveryItem.setItemMeta(leggings.getItemMeta());
- recoveryItem.setDurability(leggings.getDurability());
- p.getInventory().addItem(recoveryItem);
- }
- if(p.getInventory().getBoots() != null)
- {
- ItemStack boots = p.getInventory().getBoots();
- ItemStack recoveryItem = new ItemStack(boots.getType());
- recoveryItem.setItemMeta(boots.getItemMeta());
- recoveryItem.setDurability(boots.getDurability());
- p.getInventory().addItem(recoveryItem);
- }
- }
- private void equipPVPWeapons(Player p)
- {
- ItemStack sword = new ItemStack(Material.IRON_SWORD);
- sword.addEnchantment(Enchantment.DAMAGE_ALL, 1);
- sword.getItemMeta().setDisplayName("PVP Sword");
- p.getInventory().addItem(new ItemStack(sword));
- ItemStack bow = new ItemStack(Material.BOW);
- bow.getItemMeta().setDisplayName("PVP Bow");
- p.getInventory().addItem(bow);
- p.getInventory().addItem(new ItemStack(Material.GOLDEN_APPLE, 10));
- p.getInventory().addItem(new ItemStack(Material.ARROW, 32));
- }
- private void equipPVPArmor(Player p)
- {
- ItemStack helmet = new ItemStack(Material.IRON_HELMET);
- helmet.addEnchantment(Enchantment.DURABILITY, 1);
- helmet.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
- p.getInventory().setHelmet(helmet);
- ItemStack chestplate = new ItemStack(Material.IRON_CHESTPLATE);
- chestplate.addEnchantment(Enchantment.DURABILITY, 1);
- chestplate.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
- p.getInventory().setChestplate(chestplate);
- ItemStack leggings = new ItemStack(Material.IRON_LEGGINGS);
- leggings.addEnchantment(Enchantment.DURABILITY, 1);
- leggings.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
- p.getInventory().setLeggings(leggings);
- ItemStack boots = new ItemStack(Material.IRON_BOOTS);
- boots.addEnchantment(Enchantment.DURABILITY, 1);
- boots.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
- p.getInventory().setBoots(boots);
- }
- private void equipEliteWeapons(Player p)
- {
- ItemStack sword = new ItemStack(Material.DIAMOND_SWORD);
- sword.addEnchantment(Enchantment.DAMAGE_ALL, 1);
- p.getInventory().addItem(new ItemStack(sword));
- ItemStack bow = new ItemStack(Material.BOW);
- bow.addEnchantment(Enchantment.ARROW_DAMAGE, 1);
- bow.addEnchantment(Enchantment.DURABILITY, 1);
- p.getInventory().addItem(bow);
- p.getInventory().addItem(new ItemStack(Material.GOLDEN_APPLE, 15));
- p.getInventory().addItem(new ItemStack(Material.ARROW, 32));
- }
- private void equipEliteArmor(Player p)
- {
- ItemStack helmet = new ItemStack(Material.IRON_HELMET);
- helmet.addEnchantment(Enchantment.DURABILITY, 1);
- helmet.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
- helmet.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2);
- p.getInventory().setHelmet(helmet);
- ItemStack chestplate = new ItemStack(Material.IRON_CHESTPLATE);
- chestplate.addEnchantment(Enchantment.DURABILITY, 1);
- chestplate.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
- chestplate.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2);
- p.getInventory().setChestplate(chestplate);
- ItemStack leggings = new ItemStack(Material.IRON_LEGGINGS);
- leggings.addEnchantment(Enchantment.DURABILITY, 1);
- leggings.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
- leggings.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2);
- p.getInventory().setLeggings(leggings);
- ItemStack boots = new ItemStack(Material.IRON_BOOTS);
- boots.addEnchantment(Enchantment.DURABILITY, 1);
- boots.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
- boots.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2);
- p.getInventory().setBoots(boots);
- }
- private void equipGodWeapons(Player p)
- {
- ItemStack sword = new ItemStack(Material.DIAMOND_SWORD);
- sword.addEnchantment(Enchantment.DAMAGE_ALL, 2);
- sword.addEnchantment(Enchantment.DURABILITY, 1);
- p.getInventory().addItem(new ItemStack(sword));
- ItemStack bow = new ItemStack(Material.BOW);
- bow.addEnchantment(Enchantment.ARROW_DAMAGE, 1);
- bow.addEnchantment(Enchantment.DURABILITY, 1);
- bow.addEnchantment(Enchantment.ARROW_KNOCKBACK, 1);
- bow.addEnchantment(Enchantment.ARROW_INFINITE, 1);
- p.getInventory().addItem(bow);
- p.getInventory().addItem(new ItemStack(Material.GOLDEN_APPLE, 15));
- p.getInventory().addItem(new ItemStack(Material.ARROW, 32));
- }
- private void equipGodArmor(Player p)
- {
- ItemStack helmet = new ItemStack(Material.DIAMOND_HELMET);
- helmet.addEnchantment(Enchantment.DURABILITY, 1);
- helmet.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
- helmet.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2);
- p.getInventory().setHelmet(helmet);
- ItemStack chestplate = new ItemStack(Material.DIAMOND_CHESTPLATE);
- chestplate.addEnchantment(Enchantment.DURABILITY, 1);
- chestplate.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
- chestplate.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2);
- p.getInventory().setChestplate(chestplate);
- ItemStack leggings = new ItemStack(Material.DIAMOND_LEGGINGS);
- leggings.addEnchantment(Enchantment.DURABILITY, 1);
- leggings.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
- leggings.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2);
- p.getInventory().setLeggings(leggings);
- ItemStack boots = new ItemStack(Material.DIAMOND_BOOTS);
- boots.addEnchantment(Enchantment.DURABILITY, 1);
- boots.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
- boots.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2);
- p.getInventory().setBoots(boots);
- }
- private void equipOPWeapons(Player p)
- {
- ItemStack sword = new ItemStack(Material.DIAMOND_SWORD);
- sword.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 5);
- sword.addUnsafeEnchantment(Enchantment.DURABILITY, 10);
- sword.addUnsafeEnchantment(Enchantment.FIRE_ASPECT, 3);
- p.getInventory().addItem(new ItemStack(sword));
- ItemStack bow = new ItemStack(Material.BOW);
- bow.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 5);
- bow.addUnsafeEnchantment(Enchantment.DURABILITY, 10);
- bow.addUnsafeEnchantment(Enchantment.ARROW_INFINITE, 1);
- sword.addEnchantment(Enchantment.ARROW_FIRE, 3);
- p.getInventory().addItem(bow);
- p.getInventory().addItem(new ItemStack(Material.GOLDEN_APPLE, 15));
- p.getInventory().addItem(new ItemStack(Material.ARROW, 32));
- }
- private void equipOPArmor(Player p)
- {
- ItemStack helmet = new ItemStack(Material.DIAMOND_HELMET);
- helmet.addEnchantment(Enchantment.DURABILITY, 10);
- helmet.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 10);
- helmet.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 10);
- p.getInventory().setHelmet(helmet);
- ItemStack chestplate = new ItemStack(Material.DIAMOND_CHESTPLATE);
- chestplate.addEnchantment(Enchantment.DURABILITY, 10);
- chestplate.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 10);
- chestplate.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 10);
- p.getInventory().setChestplate(chestplate);
- ItemStack leggings = new ItemStack(Material.DIAMOND_LEGGINGS);
- leggings.addEnchantment(Enchantment.DURABILITY, 10);
- leggings.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 10);
- leggings.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 10);
- p.getInventory().setLeggings(leggings);
- ItemStack boots = new ItemStack(Material.DIAMOND_BOOTS);
- boots.addEnchantment(Enchantment.DURABILITY, 10);
- boots.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 10);
- boots.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 10);
- p.getInventory().setBoots(boots);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment