__Immortality__

kits

Oct 25th, 2019
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.59 KB | None | 0 0
  1. package com.immortal.core;
  2.  
  3. import java.util.HashMap;
  4. import java.util.UUID;
  5.  
  6. import org.bukkit.Material;
  7. import org.bukkit.command.Command;
  8. import org.bukkit.command.CommandSender;
  9. import org.bukkit.enchantments.Enchantment;
  10. import org.bukkit.entity.Player;
  11. import org.bukkit.inventory.ItemStack;
  12. import org.bukkit.plugin.java.JavaPlugin;
  13.  
  14. import net.md_5.bungee.api.ChatColor;
  15.  
  16. public class KitPVP extends JavaPlugin
  17. {
  18. private HashMap<UUID,Long> cooldownPVP = new HashMap<UUID, Long>();
  19. private HashMap<UUID,Long> cooldownElite = new HashMap<UUID, Long>();
  20.  
  21. @Override
  22. public void onEnable()
  23. {
  24. System.out.println("KitPvP plugin has been enabled.");
  25. }
  26.  
  27. @Override
  28. public void onDisable()
  29. {
  30. System.out.println("KitPvP plugin has been disabled.");
  31. }
  32.  
  33. @Override
  34. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
  35. {
  36. if(cmd.getName().equals("kit"))
  37. {
  38. if(sender instanceof Player)
  39. {
  40. Player p = (Player) sender;
  41.  
  42. if(args.length == 0)
  43. {
  44. p.sendMessage(ChatColor.BLUE + "Kits: " + ChatColor.YELLOW + "PVP, Elite, God");
  45. return true;
  46. }
  47.  
  48. if(args[0].equalsIgnoreCase("pvp"))
  49. {
  50. int cooldownSecondsTime = 20;
  51.  
  52. if(cooldownPVP.containsKey(p.getUniqueId()))
  53. {
  54. long secondsLeft = ((cooldownPVP.get(p.getUniqueId()) / 1000) + cooldownSecondsTime) - (System.currentTimeMillis() / 1000);
  55.  
  56. if(secondsLeft > 0)
  57. {
  58. p.sendMessage(ChatColor.RED + "KitPVP is on cooldown please wait " + secondsLeft + " seconds.");
  59. }
  60.  
  61. }
  62. else
  63. {
  64. recoverItems(p); //Makes sure that the items you're wearing come to you're inventory
  65.  
  66. equipPVPArmor(p);
  67. equipPVPWeapons(p);
  68.  
  69. p.sendMessage(ChatColor.YELLOW + p.getName() + ChatColor.BLUE + " you have recieved Kit PVP!");
  70. cooldownPVP.put(p.getUniqueId(), System.currentTimeMillis());
  71. p.sendMessage(ChatColor.GREEN + "You now have a cooldown for " + cooldownSecondsTime + " seconds.");
  72. }
  73. }
  74. else if(args[0].equalsIgnoreCase("elite"))
  75. {
  76. p.sendMessage(ChatColor.YELLOW + p.getName() + ChatColor.BLUE + " you have recieved Kit Elite!");
  77.  
  78. recoverItems(p); //Makes sure that the items you're wearing come to you're inventory
  79.  
  80. equipEliteArmor(p);
  81. equipEliteWeapons(p);
  82. } else if(args[0].equalsIgnoreCase("god"))
  83. {
  84. p.sendMessage(ChatColor.YELLOW + p.getName() + ChatColor.BLUE + " you have recieved Kit God!");
  85.  
  86. recoverItems(p); //Makes sure that the items you're wearing come to you're inventory
  87.  
  88. equipGodArmor(p);
  89. equipGodWeapons(p);
  90. } else if(args[0].equalsIgnoreCase("op"))
  91. {
  92. p.sendMessage(ChatColor.YELLOW + p.getName() + ChatColor.BLUE + " you have recieved Kit OP!");
  93.  
  94. recoverItems(p); //Makes sure that the items you're wearing come to you're inventory
  95.  
  96. equipOPArmor(p);
  97. equipOPWeapons(p);
  98. }
  99. else
  100. {
  101. p.sendMessage(ChatColor.RED + "That kit does not exist");
  102. }
  103. } else
  104. {
  105. System.out.println("You cannot use this command through console");
  106. }
  107. }
  108. return true;
  109. }
  110.  
  111. private void recoverItems(Player p)
  112. {
  113. if(p.getInventory().getHelmet() != null)
  114. {
  115. ItemStack helmet = p.getInventory().getHelmet();
  116. ItemStack recoveryItem = new ItemStack(helmet.getType());
  117. recoveryItem.setItemMeta(helmet.getItemMeta());
  118. recoveryItem.setDurability(helmet.getDurability());
  119. p.getInventory().addItem(recoveryItem);
  120. }
  121.  
  122. if(p.getInventory().getChestplate() != null)
  123. {
  124. ItemStack chestplate = p.getInventory().getChestplate();
  125. ItemStack recoveryItem = new ItemStack(chestplate.getType());
  126. recoveryItem.setItemMeta(chestplate.getItemMeta());
  127. recoveryItem.setDurability(chestplate.getDurability());
  128. p.getInventory().addItem(recoveryItem);
  129. }
  130.  
  131. if(p.getInventory().getLeggings() != null)
  132. {
  133. ItemStack leggings = p.getInventory().getLeggings();
  134. ItemStack recoveryItem = new ItemStack(leggings.getType());
  135. recoveryItem.setItemMeta(leggings.getItemMeta());
  136. recoveryItem.setDurability(leggings.getDurability());
  137. p.getInventory().addItem(recoveryItem);
  138. }
  139.  
  140. if(p.getInventory().getBoots() != null)
  141. {
  142. ItemStack boots = p.getInventory().getBoots();
  143. ItemStack recoveryItem = new ItemStack(boots.getType());
  144. recoveryItem.setItemMeta(boots.getItemMeta());
  145. recoveryItem.setDurability(boots.getDurability());
  146. p.getInventory().addItem(recoveryItem);
  147. }
  148. }
  149.  
  150. private void equipPVPWeapons(Player p)
  151. {
  152. ItemStack sword = new ItemStack(Material.IRON_SWORD);
  153. sword.addEnchantment(Enchantment.DAMAGE_ALL, 1);
  154. sword.getItemMeta().setDisplayName("PVP Sword");
  155. p.getInventory().addItem(new ItemStack(sword));
  156.  
  157. ItemStack bow = new ItemStack(Material.BOW);
  158. bow.getItemMeta().setDisplayName("PVP Bow");
  159.  
  160. p.getInventory().addItem(bow);
  161.  
  162. p.getInventory().addItem(new ItemStack(Material.GOLDEN_APPLE, 10));
  163. p.getInventory().addItem(new ItemStack(Material.ARROW, 32));
  164. }
  165.  
  166. private void equipPVPArmor(Player p)
  167. {
  168. ItemStack helmet = new ItemStack(Material.IRON_HELMET);
  169. helmet.addEnchantment(Enchantment.DURABILITY, 1);
  170. helmet.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
  171. p.getInventory().setHelmet(helmet);
  172.  
  173. ItemStack chestplate = new ItemStack(Material.IRON_CHESTPLATE);
  174. chestplate.addEnchantment(Enchantment.DURABILITY, 1);
  175. chestplate.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
  176. p.getInventory().setChestplate(chestplate);
  177.  
  178. ItemStack leggings = new ItemStack(Material.IRON_LEGGINGS);
  179. leggings.addEnchantment(Enchantment.DURABILITY, 1);
  180. leggings.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
  181. p.getInventory().setLeggings(leggings);
  182.  
  183. ItemStack boots = new ItemStack(Material.IRON_BOOTS);
  184. boots.addEnchantment(Enchantment.DURABILITY, 1);
  185. boots.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
  186. p.getInventory().setBoots(boots);
  187.  
  188. }
  189.  
  190. private void equipEliteWeapons(Player p)
  191. {
  192. ItemStack sword = new ItemStack(Material.DIAMOND_SWORD);
  193. sword.addEnchantment(Enchantment.DAMAGE_ALL, 1);
  194. p.getInventory().addItem(new ItemStack(sword));
  195.  
  196. ItemStack bow = new ItemStack(Material.BOW);
  197. bow.addEnchantment(Enchantment.ARROW_DAMAGE, 1);
  198. bow.addEnchantment(Enchantment.DURABILITY, 1);
  199.  
  200. p.getInventory().addItem(bow);
  201. p.getInventory().addItem(new ItemStack(Material.GOLDEN_APPLE, 15));
  202. p.getInventory().addItem(new ItemStack(Material.ARROW, 32));
  203. }
  204.  
  205. private void equipEliteArmor(Player p)
  206. {
  207. ItemStack helmet = new ItemStack(Material.IRON_HELMET);
  208. helmet.addEnchantment(Enchantment.DURABILITY, 1);
  209. helmet.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
  210. helmet.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2);
  211. p.getInventory().setHelmet(helmet);
  212.  
  213. ItemStack chestplate = new ItemStack(Material.IRON_CHESTPLATE);
  214. chestplate.addEnchantment(Enchantment.DURABILITY, 1);
  215. chestplate.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
  216. chestplate.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2);
  217. p.getInventory().setChestplate(chestplate);
  218.  
  219. ItemStack leggings = new ItemStack(Material.IRON_LEGGINGS);
  220. leggings.addEnchantment(Enchantment.DURABILITY, 1);
  221. leggings.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
  222. leggings.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2);
  223. p.getInventory().setLeggings(leggings);
  224.  
  225. ItemStack boots = new ItemStack(Material.IRON_BOOTS);
  226. boots.addEnchantment(Enchantment.DURABILITY, 1);
  227. boots.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
  228. boots.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2);
  229. p.getInventory().setBoots(boots);
  230. }
  231.  
  232. private void equipGodWeapons(Player p)
  233. {
  234. ItemStack sword = new ItemStack(Material.DIAMOND_SWORD);
  235. sword.addEnchantment(Enchantment.DAMAGE_ALL, 2);
  236. sword.addEnchantment(Enchantment.DURABILITY, 1);
  237. p.getInventory().addItem(new ItemStack(sword));
  238.  
  239. ItemStack bow = new ItemStack(Material.BOW);
  240. bow.addEnchantment(Enchantment.ARROW_DAMAGE, 1);
  241. bow.addEnchantment(Enchantment.DURABILITY, 1);
  242. bow.addEnchantment(Enchantment.ARROW_KNOCKBACK, 1);
  243. bow.addEnchantment(Enchantment.ARROW_INFINITE, 1);
  244.  
  245. p.getInventory().addItem(bow);
  246. p.getInventory().addItem(new ItemStack(Material.GOLDEN_APPLE, 15));
  247. p.getInventory().addItem(new ItemStack(Material.ARROW, 32));
  248. }
  249.  
  250. private void equipGodArmor(Player p)
  251. {
  252. ItemStack helmet = new ItemStack(Material.DIAMOND_HELMET);
  253. helmet.addEnchantment(Enchantment.DURABILITY, 1);
  254. helmet.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
  255. helmet.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2);
  256. p.getInventory().setHelmet(helmet);
  257.  
  258. ItemStack chestplate = new ItemStack(Material.DIAMOND_CHESTPLATE);
  259. chestplate.addEnchantment(Enchantment.DURABILITY, 1);
  260. chestplate.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
  261. chestplate.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2);
  262. p.getInventory().setChestplate(chestplate);
  263.  
  264. ItemStack leggings = new ItemStack(Material.DIAMOND_LEGGINGS);
  265. leggings.addEnchantment(Enchantment.DURABILITY, 1);
  266. leggings.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
  267. leggings.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2);
  268. p.getInventory().setLeggings(leggings);
  269.  
  270. ItemStack boots = new ItemStack(Material.DIAMOND_BOOTS);
  271. boots.addEnchantment(Enchantment.DURABILITY, 1);
  272. boots.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
  273. boots.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2);
  274. p.getInventory().setBoots(boots);
  275. }
  276.  
  277. private void equipOPWeapons(Player p)
  278. {
  279. ItemStack sword = new ItemStack(Material.DIAMOND_SWORD);
  280. sword.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 5);
  281. sword.addUnsafeEnchantment(Enchantment.DURABILITY, 10);
  282. sword.addUnsafeEnchantment(Enchantment.FIRE_ASPECT, 3);
  283. p.getInventory().addItem(new ItemStack(sword));
  284.  
  285. ItemStack bow = new ItemStack(Material.BOW);
  286. bow.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 5);
  287. bow.addUnsafeEnchantment(Enchantment.DURABILITY, 10);
  288. bow.addUnsafeEnchantment(Enchantment.ARROW_INFINITE, 1);
  289. sword.addEnchantment(Enchantment.ARROW_FIRE, 3);
  290.  
  291. p.getInventory().addItem(bow);
  292. p.getInventory().addItem(new ItemStack(Material.GOLDEN_APPLE, 15));
  293. p.getInventory().addItem(new ItemStack(Material.ARROW, 32));
  294. }
  295.  
  296. private void equipOPArmor(Player p)
  297. {
  298. ItemStack helmet = new ItemStack(Material.DIAMOND_HELMET);
  299. helmet.addEnchantment(Enchantment.DURABILITY, 10);
  300. helmet.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 10);
  301. helmet.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 10);
  302. p.getInventory().setHelmet(helmet);
  303.  
  304. ItemStack chestplate = new ItemStack(Material.DIAMOND_CHESTPLATE);
  305. chestplate.addEnchantment(Enchantment.DURABILITY, 10);
  306. chestplate.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 10);
  307. chestplate.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 10);
  308. p.getInventory().setChestplate(chestplate);
  309.  
  310. ItemStack leggings = new ItemStack(Material.DIAMOND_LEGGINGS);
  311. leggings.addEnchantment(Enchantment.DURABILITY, 10);
  312. leggings.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 10);
  313. leggings.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 10);
  314. p.getInventory().setLeggings(leggings);
  315.  
  316. ItemStack boots = new ItemStack(Material.DIAMOND_BOOTS);
  317. boots.addEnchantment(Enchantment.DURABILITY, 10);
  318. boots.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 10);
  319. boots.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 10);
  320. p.getInventory().setBoots(boots);
  321. }
  322. }
Advertisement
Add Comment
Please, Sign In to add comment