Advertisement
thegarfish

Untitled

Sep 15th, 2013
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.10 KB | None | 0 0
  1. package me.thegarfish.pvp;
  2.  
  3. import org.bukkit.Color;
  4. import org.bukkit.Material;
  5. import org.bukkit.command.Command;
  6. import org.bukkit.command.CommandSender;
  7. import org.bukkit.enchantments.Enchantment;
  8. import org.bukkit.entity.Player;
  9. import org.bukkit.event.EventHandler;
  10. import org.bukkit.event.Listener;
  11. import org.bukkit.event.block.Action;
  12. import org.bukkit.event.entity.PlayerDeathEvent;
  13. import org.bukkit.event.player.PlayerDropItemEvent;
  14. import org.bukkit.event.player.PlayerInteractEvent;
  15. import org.bukkit.inventory.ItemStack;
  16. import org.bukkit.inventory.meta.LeatherArmorMeta;
  17. import org.bukkit.metadata.FixedMetadataValue;
  18. import org.bukkit.metadata.MetadataValue;
  19. import org.bukkit.plugin.java.JavaPlugin;
  20. import org.bukkit.potion.PotionEffect;
  21. import org.bukkit.potion.PotionEffectType;
  22.  
  23. public class Main extends JavaPlugin implements Listener {
  24.  
  25. public void onEnable() {
  26. System.out.print("§4KitPvP Enabled!");
  27. getServer().getPluginManager().registerEvents(this, this);
  28. getConfig().options().copyDefaults(true);
  29. saveConfig();
  30. }
  31.  
  32. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
  33. if (sender instanceof Player == false) {
  34. sender.sendMessage("You must be a player to select a kit.");
  35. return true;
  36. }
  37. if (commandLabel.equalsIgnoreCase("Stats")) {
  38. Player player = (Player) sender;
  39. player.sendMessage("§6Name: §3" + player.getName());
  40. player.sendMessage("§6Kills: §c" + getConfig().getInt("players." + player.getName() + ".kills"));
  41. player.sendMessage("§6Deaths: §c" + getConfig().getInt("players." + player.getName() + ".deaths"));
  42. player.sendMessage("§6KDR: §c" + getConfig().getInt("players." + player.getName() + ".kills") + " §4|§c " + getConfig().getInt("players." + player.getName() + ".deaths"));
  43. }
  44. Player player = (Player) sender;
  45. if (player.hasMetadata("kit")) {
  46. player.sendMessage("§cYou have already selected a kit!");
  47. return true;
  48. }
  49. else if(commandLabel.equalsIgnoreCase("Kits")) {
  50. player.sendMessage("§aKits: Warrior, Archer, Tank");
  51. player.sendMessage("§6Gold Kits: Pyromancer, Scout, ???");
  52. player.sendMessage("§cPlatinum Kits: Rot, ???");
  53. } else if(commandLabel.equalsIgnoreCase("Rot")) {
  54. player.setMetadata("kit", (MetadataValue) new FixedMetadataValue(this, commandLabel));
  55. player.sendMessage("§4ONLY ROT's WEAKNESS CAN HAND THIS KIT!");
  56. ItemStack rot = new ItemStack(Material.STICK);
  57. rot.addUnsafeEnchantment(Enchantment.KNOCKBACK, 5);
  58. player.getInventory().addItem(rot);
  59. ItemStack helm = new ItemStack(Material.LEATHER_HELMET);
  60. LeatherArmorMeta meta = (LeatherArmorMeta) helm.getItemMeta();
  61. meta.setColor(Color.FUCHSIA);
  62. helm.setItemMeta(meta);
  63. player.getInventory().setHelmet(helm);
  64. player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS,Integer.MAX_VALUE, 1));
  65. player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_DIGGING,Integer.MAX_VALUE, 4));
  66. player.addPotionEffect(new PotionEffect(PotionEffectType.HUNGER,Integer.MAX_VALUE, 1));
  67. player.getInventory().addItem(new ItemStack(Material.MUSHROOM_SOUP));
  68. player.getInventory().addItem(new ItemStack(Material.BOWL, 7));
  69. } else if(commandLabel.equalsIgnoreCase("Archer")) {
  70. player.setMetadata("kit", (MetadataValue) new FixedMetadataValue(this, commandLabel));
  71. player.sendMessage("§6You have chosen kit §aArcher§6!");
  72. player.getInventory().setHelmet(new ItemStack (Material.CHAINMAIL_HELMET));
  73. player.getInventory().setChestplate(new ItemStack (Material.CHAINMAIL_CHESTPLATE));
  74. player.getInventory().setLeggings(new ItemStack(Material.CHAINMAIL_LEGGINGS));
  75. player.getInventory().setBoots(new ItemStack(Material.CHAINMAIL_BOOTS));
  76. ItemStack bow = new ItemStack(Material.BOW);
  77. bow.addEnchantment(Enchantment.DURABILITY, 1);
  78. bow.addEnchantment(Enchantment.ARROW_KNOCKBACK, 1);
  79. bow.addEnchantment(Enchantment.ARROW_INFINITE, 1);
  80. player.getInventory().addItem(bow);
  81. int amountofsoup = 8;
  82. for (int i = 0; i < amountofsoup; i++) {
  83. addSingleItem(player, Material.MUSHROOM_SOUP);}
  84. player.getInventory().addItem(new ItemStack(Material.ARROW));
  85. } else if(commandLabel.equalsIgnoreCase("Tank")) {
  86. player.setMetadata("kit", (MetadataValue) new FixedMetadataValue(this, commandLabel));
  87. player.sendMessage("§6You have chosen kit §aTank§6!");
  88. player.getInventory().setHelmet(new ItemStack(Material.DIAMOND_HELMET));
  89. player.getInventory().setChestplate(new ItemStack(Material.DIAMOND_CHESTPLATE));
  90. player.getInventory().setLeggings(new ItemStack(Material.DIAMOND_LEGGINGS));
  91. player.getInventory().setBoots(new ItemStack(Material.DIAMOND_BOOTS));
  92. ItemStack tanksword = new ItemStack(Material.IRON_AXE);
  93. tanksword.addEnchantment(Enchantment.DURABILITY, 3);
  94. tanksword.addEnchantment(Enchantment.DAMAGE_ALL, 1);
  95. player.getInventory().addItem(tanksword);
  96. player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW,Integer.MAX_VALUE, 1));
  97. int amountofsoup = 8;
  98. for (int i = 0; i < amountofsoup; i++) {
  99. addSingleItem(player, Material.MUSHROOM_SOUP);}
  100. } else if(commandLabel.equalsIgnoreCase("Warrior")) {
  101. player.setMetadata("kit", (MetadataValue) new FixedMetadataValue(this, commandLabel));
  102. player.sendMessage("§6You have chosen kit §aWarrior§6!");
  103. player.getInventory().setHelmet(new ItemStack (Material.IRON_HELMET));
  104. player.getInventory().setChestplate(new ItemStack (Material.IRON_CHESTPLATE));
  105. player.getInventory().setLeggings(new ItemStack (Material.IRON_LEGGINGS));
  106. player.getInventory().setBoots(new ItemStack (Material.IRON_BOOTS));
  107. player.getInventory().addItem(new ItemStack (Material.DIAMOND_SWORD));
  108. int amountofsoup = 8;
  109. for (int i = 0; i < amountofsoup; i++) {
  110. addSingleItem(player, Material.MUSHROOM_SOUP);}
  111. } else if(commandLabel.equalsIgnoreCase("Pyromancer")) {
  112. player.setMetadata("kit", (MetadataValue) new FixedMetadataValue(this, commandLabel));
  113. player.sendMessage("§6You have chosen kit §cPyromancer!");
  114. player.getInventory().setHelmet(new ItemStack(Material.CHAINMAIL_HELMET));
  115. player.getInventory().setChestplate(new ItemStack(Material.CHAINMAIL_CHESTPLATE));
  116. player.getInventory().setLeggings(new ItemStack(Material.CHAINMAIL_LEGGINGS));
  117. player.getInventory().setBoots(new ItemStack(Material.CHAINMAIL_BOOTS));
  118. player.getInventory().addItem(new ItemStack(Material.FLINT_AND_STEEL));
  119. player.getInventory().addItem(new ItemStack(Material.LAVA_BUCKET));
  120. player.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE,Integer.MAX_VALUE, 1));
  121. int amountofsoup = 7;
  122. for (int i = 0; i < amountofsoup; i++) {
  123. addSingleItem(player, Material.MUSHROOM_SOUP);}
  124. } else if(commandLabel.equalsIgnoreCase("Scout")) {
  125. ItemStack scouthelm = new ItemStack(Material.LEATHER_HELMET);
  126. LeatherArmorMeta meta = (LeatherArmorMeta) scouthelm.getItemMeta();
  127. meta.setColor(Color.YELLOW);
  128. scouthelm.setItemMeta(meta);
  129. player.getInventory().setHelmet(scouthelm);
  130. ItemStack scoutchest = new ItemStack(Material.LEATHER_CHESTPLATE);
  131. LeatherArmorMeta meta1 = (LeatherArmorMeta) scoutchest.getItemMeta();
  132. meta1.setColor(Color.YELLOW);
  133. scoutchest.setItemMeta(meta1);
  134. player.getInventory().setChestplate(scoutchest);
  135. ItemStack scoutpants = new ItemStack(Material.LEATHER_LEGGINGS);
  136. LeatherArmorMeta meta11 = (LeatherArmorMeta) scoutchest.getItemMeta();
  137. meta11.setColor(Color.YELLOW);
  138. scoutpants.setItemMeta(meta11);
  139. player.getInventory().setLeggings(scoutpants);
  140. ItemStack scoutboots = new ItemStack(Material.LEATHER_BOOTS);
  141. LeatherArmorMeta meta111 = (LeatherArmorMeta) scoutboots.getItemMeta();
  142. meta111.setColor(Color.YELLOW);
  143. scoutboots.setItemMeta(meta111);
  144. player.getInventory().setBoots(scoutboots);
  145. player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED,Integer.MAX_VALUE, 1));
  146. ItemStack scoutshovel = new ItemStack(Material.IRON_SPADE);
  147. scoutshovel.addEnchantment(Enchantment.DURABILITY, 3);
  148. scoutshovel.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 2);
  149. player.getInventory().addItem(scoutshovel);
  150. int amountofsoup = 8;
  151. for (int i = 0; i < amountofsoup; i++) {
  152. addSingleItem(player, Material.MUSHROOM_SOUP);}
  153. }
  154. return false;
  155.  
  156. }
  157.  
  158. private void addSingleItem(Player player, Material material) {
  159. player.getInventory().addItem(new ItemStack(material));
  160. }
  161. @EventHandler
  162. public void onPlayerDeath(PlayerDeathEvent event) {
  163. Player p = event.getEntity();
  164. if (p.hasPermission("kit.nodrop")) {
  165. event.getDrops().clear();
  166. }
  167. p.removeMetadata("kit", this);
  168. if(p.getKiller() instanceof Player){ //Check if the entity who killed the player is a player
  169. Player killer = p.getKiller(); //The killer of the person
  170. this.reloadConfig();
  171. getConfig().set("players." + p.getName() + ".deaths", getConfig().getInt("players." + p.getName() + ".deaths") + 1); //Add a death to the player
  172. getConfig().set("players." + killer.getName() + ".kills", getConfig().getInt("players." + killer.getName() + ".kills") + 1); //Add a kill to the killer
  173. this.saveConfig();
  174. }
  175.  
  176. }
  177.  
  178. @EventHandler
  179. public void onPlayerInteract(PlayerInteractEvent event) {
  180. if (event.getAction() == Action.RIGHT_CLICK_AIR
  181. || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
  182. Player player = event.getPlayer();
  183. if (player.getItemInHand() != null
  184. && player.getItemInHand().getType() == Material.MUSHROOM_SOUP) {
  185. if (player.getHealth() == player.getMaxHealth())
  186. return;
  187.  
  188. event.setCancelled(true);
  189. player.setHealth(player.getHealth() > 14 ? 20 : player
  190. .getHealth() + 6);
  191. player.getItemInHand().setType(Material.BOWL);
  192. }
  193. }
  194. }
  195.  
  196. @EventHandler
  197. public void onPlayerDropItem(PlayerDropItemEvent event) {
  198. Player p = event.getPlayer();
  199. if(event.getItemDrop().getItemStack().getType() == Material.BOWL) {
  200. }
  201. else {
  202. event.setCancelled(true);
  203. p.sendMessage("§cWarning: §6You Can Not Drop Kit Items! §3(Only Bowls)!");
  204. }
  205.  
  206. }
  207.  
  208.  
  209. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement