Advertisement
thegarfish

Untitled

Aug 30th, 2013
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.76 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(this, commandLabel));
  42. player.sendMessage(ChatColor.GOLD + "You Have Chosen Kit §aWarrior§6!");
  43. player.getInventory().setHelmet(new ItemStack(Material.IRON_HELMET));
  44. player.getInventory().setChestplate(new ItemStack(Material.IRON_CHESTPLATE));
  45. player.getInventory().setLeggings(new ItemStack(Material.IRON_LEGGINGS));
  46. player.getInventory().setBoots(new ItemStack(Material.IRON_BOOTS));
  47. player.getInventory().addItem(new ItemStack(Material.DIAMOND_SWORD));
  48. int amountofsoup = 8;
  49. for (int i = 0; i < amountofsoup; i++) {
  50. addSingleItem(player, Material.MUSHROOM_SOUP);
  51. }
  52. } else if (commandLabel.equalsIgnoreCase("Archer")) {
  53. player.setMetadata("kit", (MetadataValue) new FixedMetadataValue(
  54. this, commandLabel));
  55. player.sendMessage(ChatColor.GOLD + "You Have Chosen Kit §aArcher§6!");
  56. player.getInventory().setHelmet(new ItemStack(Material.CHAINMAIL_HELMET));
  57. player.getInventory().setChestplate(new ItemStack(Material.CHAINMAIL_CHESTPLATE));
  58. player.getInventory().setLeggings(new ItemStack(Material.CHAINMAIL_LEGGINGS));
  59. player.getInventory().setBoots(new ItemStack(Material.CHAINMAIL_BOOTS));
  60. ItemStack bow = new ItemStack(Material.BOW, 1);
  61. bow.addEnchantment(Enchantment.ARROW_INFINITE, 1);
  62. bow.addEnchantment(Enchantment.DURABILITY, 1);
  63. player.getInventory().addItem(bow);
  64. int amountofsoup = 8;
  65. for (int i = 0; i < amountofsoup; i++) {
  66. addSingleItem(player, Material.MUSHROOM_SOUP);
  67. }
  68. player.getInventory().addItem(new ItemStack(Material.ARROW, 1));
  69. } else if (commandLabel.equalsIgnoreCase("Tank")) {
  70. player.setMetadata("kit", (MetadataValue) new FixedMetadataValue(
  71. this, commandLabel));
  72. player.sendMessage(ChatColor.GOLD + "You Have Chosen Kit §cTank§6!");
  73. player.getInventory().setHelmet(
  74. new ItemStack(Material.DIAMOND_HELMET));
  75. player.getInventory().setChestplate(
  76. new ItemStack(Material.DIAMOND_CHESTPLATE));
  77. player.getInventory().setLeggings(
  78. new ItemStack(Material.DIAMOND_LEGGINGS));
  79. player.getInventory().setBoots(
  80. new ItemStack(Material.DIAMOND_BOOTS));
  81. player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW,
  82. Integer.MAX_VALUE, 1));
  83. player.getInventory().addItem(new ItemStack(Material.STONE_SWORD));
  84. int amountofsoup = 8;
  85. for (int i = 0; i < amountofsoup; i++) {
  86. addSingleItem(player, Material.MUSHROOM_SOUP);
  87. }
  88. }
  89. return false;
  90. }
  91.  
  92. private void addSingleItem(Player player, Material material) {
  93. player.getInventory().addItem(new ItemStack(material));
  94. }
  95.  
  96. // Events
  97.  
  98. @EventHandler
  99. public void onPlayerInteract(PlayerInteractEvent event) {
  100. if (event.getAction() == Action.RIGHT_CLICK_AIR
  101. || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
  102. Player player = event.getPlayer();
  103. if (player.getItemInHand() != null
  104. && player.getItemInHand().getType() == Material.MUSHROOM_SOUP) {
  105. if (player.getHealth() == player.getMaxHealth())
  106. return;
  107.  
  108. event.setCancelled(true);
  109. player.setHealth(player.getHealth() > 14 ? 20 : player
  110. .getHealth() + 6);
  111. player.getItemInHand().setType(Material.BOWL);
  112. }
  113. }
  114.  
  115. }
  116.  
  117. @EventHandler
  118. public void onPlayerDeath(PlayerDeathEvent event1) {
  119. if (event1.getEntity().getPlayer().hasPermission("kit.nodrop")) {
  120. event1.getDrops().clear();
  121. }
  122. }
  123. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement