Advertisement
thegarfish

Untitled

Aug 26th, 2013
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.25 KB | None | 0 0
  1. package me.thegarfish.main;
  2.  
  3. import org.bukkit.ChatColor;
  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.PlayerInteractEvent;
  14. import org.bukkit.inventory.ItemStack;
  15. import org.bukkit.metadata.FixedMetadataValue;
  16. import org.bukkit.metadata.MetadataValue;
  17. import org.bukkit.plugin.java.JavaPlugin;
  18. import org.bukkit.potion.PotionEffect;
  19. import org.bukkit.potion.PotionEffectType;
  20.  
  21. public class Main extends JavaPlugin implements Listener {
  22.  
  23. public void onEnable() {
  24. System.out.print("§4KitPvP Has Been §aEnabled!");
  25. getServer().getPluginManager().registerEvents(this, this);
  26. }
  27.  
  28. // snip
  29. public boolean onCommand(CommandSender sender, Command cmd,
  30. String commandLabel, String[] args) {
  31. if (sender instanceof Player == false) {
  32. sender.sendMessage("You must be a player to select a kit.");
  33. return true;
  34. }
  35. Player player = (Player) sender;
  36. if (player.hasMetadata("kit")) {
  37. player.sendMessage("You have already selected a kit!");
  38. return true;
  39. }
  40. if (commandLabel.equalsIgnoreCase("Warrior")) {
  41. player.setMetadata("kit", (MetadataValue) new FixedMetadataValue(
  42. this, commandLabel));
  43.  
  44. player.sendMessage(ChatColor.GOLD
  45. + "You Have Chosen Kit §aWarrior§6!");
  46. player.getInventory()
  47. .setHelmet(new ItemStack(Material.IRON_HELMET));
  48. player.getInventory().setChestplate(
  49. new ItemStack(Material.IRON_CHESTPLATE));
  50. player.getInventory().setLeggings(
  51. new ItemStack(Material.IRON_LEGGINGS));
  52. player.getInventory().setBoots(new ItemStack(Material.IRON_BOOTS));
  53. player.getInventory()
  54. .addItem(new ItemStack(Material.DIAMOND_SWORD));
  55. int amountofsoup = 8;
  56. for (int i = 0; i < amountofsoup; i++) {
  57. addSingleItem(player, Material.MUSHROOM_SOUP);
  58. }
  59. } else if (commandLabel.equalsIgnoreCase("Archer")) {
  60. player.setMetadata("kit", (MetadataValue) new FixedMetadataValue(
  61. this, commandLabel));
  62. player.sendMessage(ChatColor.GOLD
  63. + "You Have Chosen Kit §aArcher§6!");
  64. player.getInventory().setHelmet(
  65. new ItemStack(Material.CHAINMAIL_HELMET));
  66. player.getInventory().setChestplate(
  67. new ItemStack(Material.CHAINMAIL_CHESTPLATE));
  68. player.getInventory().setLeggings(
  69. new ItemStack(Material.CHAINMAIL_LEGGINGS));
  70. player.getInventory().setBoots(
  71. new ItemStack(Material.CHAINMAIL_BOOTS));
  72. ItemStack bow = new ItemStack(Material.BOW, 1);
  73. bow.addEnchantment(Enchantment.ARROW_INFINITE, 1);
  74. bow.addEnchantment(Enchantment.DURABILITY, 1);
  75. player.getInventory().addItem(bow);
  76. int amountofsoup = 8;
  77. for (int i = 0; i < amountofsoup; i++) {
  78. addSingleItem(player, Material.MUSHROOM_SOUP);
  79. }
  80. player.getInventory().addItem(new ItemStack(Material.ARROW, 1));
  81. } else if (commandLabel.equalsIgnoreCase("Tank")) {
  82. player.setMetadata("kit", (MetadataValue) new FixedMetadataValue(
  83. this, commandLabel));
  84. player.sendMessage(ChatColor.GOLD + "You Have Chosen Kit §cTank§6!");
  85. player.getInventory().setHelmet(
  86. new ItemStack(Material.DIAMOND_HELMET));
  87. player.getInventory().setChestplate(
  88. new ItemStack(Material.DIAMOND_CHESTPLATE));
  89. player.getInventory().setLeggings(
  90. new ItemStack(Material.DIAMOND_LEGGINGS));
  91. player.getInventory().setBoots(
  92. new ItemStack(Material.DIAMOND_BOOTS));
  93. player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW,
  94. Integer.MAX_VALUE, 1));
  95. player.getInventory().addItem(new ItemStack(Material.STONE_SWORD));
  96. int amountofsoup = 8;
  97. for (int i = 0; i < amountofsoup; i++) {
  98. addSingleItem(player, Material.MUSHROOM_SOUP);
  99. }
  100. }
  101. return false;
  102. }
  103.  
  104. private void addSingleItem(Player player, Material material) {
  105. player.getInventory().addItem(new ItemStack(material));
  106. }
  107.  
  108. // ========================================================================================================================================
  109. // \\
  110. // ============================================================ Soup
  111. // ====================================================================== \\
  112. // ========================================================================================================================================
  113. // \\
  114. @EventHandler
  115. public void onPlayerInteract(PlayerInteractEvent event) {
  116. if (event.getAction() == Action.RIGHT_CLICK_AIR
  117. || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
  118. Player player = event.getPlayer();
  119. if (player.getItemInHand() != null
  120. && player.getItemInHand().getType() == Material.MUSHROOM_SOUP) {
  121. if (player.getHealth() == player.getMaxHealth())
  122. return;
  123.  
  124. event.setCancelled(true);
  125. player.setHealth(player.getHealth() > 14 ? 20 : player
  126. .getHealth() + 6);
  127. player.getItemInHand().setType(Material.BOWL);
  128. }
  129. }
  130.  
  131.  
  132. }
  133. @EventHandler
  134. public void onPlayerDeath(PlayerDeathEvent event1) {
  135. if(event1.getEntity().getPlayer().hasPermission("kit.nodrop")){
  136. event1.getDrops().clear();
  137. }
  138. }
  139. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement