Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.thegarfish.main;
- import org.bukkit.ChatColor;
- 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.event.EventHandler;
- import org.bukkit.event.Listener;
- import org.bukkit.event.block.Action;
- import org.bukkit.event.entity.PlayerDeathEvent;
- import org.bukkit.event.player.PlayerInteractEvent;
- import org.bukkit.inventory.ItemStack;
- import org.bukkit.metadata.FixedMetadataValue;
- import org.bukkit.metadata.MetadataValue;
- import org.bukkit.plugin.java.JavaPlugin;
- import org.bukkit.potion.PotionEffect;
- import org.bukkit.potion.PotionEffectType;
- public class Main extends JavaPlugin implements Listener {
- public void onEnable() {
- System.out.print("§4KitPvP Has Been §aEnabled!");
- getServer().getPluginManager().registerEvents(this, this);
- }
- // snip
- public boolean onCommand(CommandSender sender, Command cmd,
- String commandLabel, String[] args) {
- if (sender instanceof Player == false) {
- sender.sendMessage("You must be a player to select a kit.");
- return true;
- }
- Player player = (Player) sender;
- if (player.hasMetadata("kit")) {
- player.sendMessage("You have already selected a kit!");
- return true;
- }
- if (commandLabel.equalsIgnoreCase("Warrior")) {
- player.setMetadata("kit", (MetadataValue) new FixedMetadataValue(
- this, commandLabel));
- player.sendMessage(ChatColor.GOLD
- + "You Have Chosen Kit §aWarrior§6!");
- player.getInventory()
- .setHelmet(new ItemStack(Material.IRON_HELMET));
- player.getInventory().setChestplate(
- new ItemStack(Material.IRON_CHESTPLATE));
- player.getInventory().setLeggings(
- new ItemStack(Material.IRON_LEGGINGS));
- player.getInventory().setBoots(new ItemStack(Material.IRON_BOOTS));
- player.getInventory()
- .addItem(new ItemStack(Material.DIAMOND_SWORD));
- int amountofsoup = 8;
- for (int i = 0; i < amountofsoup; i++) {
- addSingleItem(player, Material.MUSHROOM_SOUP);
- }
- } else if (commandLabel.equalsIgnoreCase("Archer")) {
- player.setMetadata("kit", (MetadataValue) new FixedMetadataValue(
- this, commandLabel));
- player.sendMessage(ChatColor.GOLD
- + "You Have Chosen Kit §aArcher§6!");
- player.getInventory().setHelmet(
- new ItemStack(Material.CHAINMAIL_HELMET));
- player.getInventory().setChestplate(
- new ItemStack(Material.CHAINMAIL_CHESTPLATE));
- player.getInventory().setLeggings(
- new ItemStack(Material.CHAINMAIL_LEGGINGS));
- player.getInventory().setBoots(
- new ItemStack(Material.CHAINMAIL_BOOTS));
- ItemStack bow = new ItemStack(Material.BOW, 1);
- bow.addEnchantment(Enchantment.ARROW_INFINITE, 1);
- bow.addEnchantment(Enchantment.DURABILITY, 1);
- player.getInventory().addItem(bow);
- int amountofsoup = 8;
- for (int i = 0; i < amountofsoup; i++) {
- addSingleItem(player, Material.MUSHROOM_SOUP);
- }
- player.getInventory().addItem(new ItemStack(Material.ARROW, 1));
- } else if (commandLabel.equalsIgnoreCase("Tank")) {
- player.setMetadata("kit", (MetadataValue) new FixedMetadataValue(
- this, commandLabel));
- player.sendMessage(ChatColor.GOLD + "You Have Chosen Kit §cTank§6!");
- player.getInventory().setHelmet(
- new ItemStack(Material.DIAMOND_HELMET));
- player.getInventory().setChestplate(
- new ItemStack(Material.DIAMOND_CHESTPLATE));
- player.getInventory().setLeggings(
- new ItemStack(Material.DIAMOND_LEGGINGS));
- player.getInventory().setBoots(
- new ItemStack(Material.DIAMOND_BOOTS));
- player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW,
- Integer.MAX_VALUE, 1));
- player.getInventory().addItem(new ItemStack(Material.STONE_SWORD));
- int amountofsoup = 8;
- for (int i = 0; i < amountofsoup; i++) {
- addSingleItem(player, Material.MUSHROOM_SOUP);
- }
- }
- return false;
- }
- private void addSingleItem(Player player, Material material) {
- player.getInventory().addItem(new ItemStack(material));
- }
- // ========================================================================================================================================
- // \\
- // ============================================================ Soup
- // ====================================================================== \\
- // ========================================================================================================================================
- // \\
- @EventHandler
- public void onPlayerInteract(PlayerInteractEvent event) {
- if (event.getAction() == Action.RIGHT_CLICK_AIR
- || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
- Player player = event.getPlayer();
- if (player.getItemInHand() != null
- && player.getItemInHand().getType() == Material.MUSHROOM_SOUP) {
- if (player.getHealth() == player.getMaxHealth())
- return;
- event.setCancelled(true);
- player.setHealth(player.getHealth() > 14 ? 20 : player
- .getHealth() + 6);
- player.getItemInHand().setType(Material.BOWL);
- }
- }
- }
- @EventHandler
- public void onPlayerDeath(PlayerDeathEvent event1) {
- if(event1.getEntity().getPlayer().hasPermission("kit.nodrop")){
- event1.getDrops().clear();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement