Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.walking.Habilidades;
- import java.util.ArrayList;
- import java.util.HashMap;
- import me.walking.main.Main;
- import org.bukkit.Bukkit;
- import org.bukkit.ChatColor;
- import org.bukkit.Location;
- import org.bukkit.Material;
- import org.bukkit.block.Block;
- 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.block.BlockBreakEvent;
- import org.bukkit.event.block.BlockPlaceEvent;
- import org.bukkit.event.entity.PlayerDeathEvent;
- import org.bukkit.event.player.PlayerDropItemEvent;
- import org.bukkit.event.player.PlayerInteractEntityEvent;
- import org.bukkit.event.player.PlayerInteractEvent;
- import org.bukkit.event.player.PlayerQuitEvent;
- import org.bukkit.inventory.ItemStack;
- import org.bukkit.inventory.meta.ItemMeta;
- import org.bukkit.potion.PotionEffect;
- import org.bukkit.potion.PotionEffectType;
- import org.bukkit.scheduler.BukkitRunnable;
- public class Gladiator
- implements Listener
- {
- private Main plugin;
- public Gladiator(Main plugin)
- {
- this.plugin = plugin;
- }
- ArrayList<String> a = me.walking.Kits.KitAPI.Gladiator;
- @SuppressWarnings({ "unchecked", "rawtypes" })
- ArrayList<Player> arena = new ArrayList();
- @SuppressWarnings({ "unchecked", "rawtypes" })
- ArrayList<Block> bArray = new ArrayList();
- @SuppressWarnings({ "unchecked", "rawtypes" })
- private transient HashMap<Player, Location> local = new HashMap();
- public static ItemStack newItem(String name, Material material)
- {
- ItemStack item = new ItemStack(material);
- ItemMeta meta = item.getItemMeta();
- meta.setDisplayName(name);
- item.setItemMeta(meta);
- return item;
- }
- @EventHandler
- public void exit(PlayerQuitEvent e)
- {
- Player p = e.getPlayer();
- if (this.arena.contains(p)) {
- this.arena.remove(p);
- }
- }
- @SuppressWarnings("deprecation")
- @EventHandler
- public void GladiatorPlaceCancel(BlockPlaceEvent e)
- {
- Player p = e.getPlayer();
- ItemStack item = newItem(ChatColor.RED + "Gladiator", Material.IRON_FENCE);
- if (p.getItemInHand().equals(item))
- {
- e.setCancelled(true);
- p.updateInventory();
- }
- }
- @SuppressWarnings("deprecation")
- @EventHandler
- public void GladiatorDrop(PlayerDropItemEvent e)
- {
- ItemStack item = newItem(ChatColor.RED + "Gladiator", Material.IRON_FENCE);
- if (e.getItemDrop().getItemStack().equals(item))
- {
- e.setCancelled(true);
- e.getPlayer().updateInventory();
- }
- }
- @EventHandler
- public void block(BlockBreakEvent e)
- {
- if (this.bArray.contains(e.getBlock())) {
- e.setCancelled(true);
- }
- }
- @EventHandler
- public void interact(final PlayerInteractEvent e)
- {
- final Player p = e.getPlayer();
- if ((e.getAction() == Action.LEFT_CLICK_BLOCK) &&
- (this.arena.contains(p)) &&
- (this.bArray.contains(e.getClickedBlock())))
- {
- e.getClickedBlock().setType(Material.BEDROCK);
- if (e.getClickedBlock().getLocation().getBlock().getType() != Material.AIR) {
- Bukkit.getScheduler().scheduleSyncDelayedTask(this.plugin, new Runnable()
- {
- public void run()
- {
- if (Gladiator.this.arena.contains(p)) {
- e.getClickedBlock().setType(Material.GLASS);
- }
- }
- }, 20L);
- }
- }
- }
- @EventHandler
- public void death(PlayerDeathEvent e)
- {
- if (((e.getEntity() instanceof Player)) && ((e.getEntity().getKiller() instanceof Player)))
- {
- Player p = e.getEntity();
- Player k = p.getKiller();
- if ((this.arena.contains(p)) && (this.arena.contains(k)))
- {
- this.arena.remove(p);
- this.arena.remove(k);
- k.sendMessage(ChatColor.GREEN + "Voce ganhou de " + p.getName());
- k.teleport((Location)this.local.get(k));
- k.removePotionEffect(PotionEffectType.WITHER);
- p.removePotionEffect(PotionEffectType.WITHER);
- }
- }
- }
- @EventHandler
- public void click(PlayerInteractEntityEvent e)
- {
- if ((e.getRightClicked() instanceof Player))
- {
- final Player c = (Player)e.getRightClicked();
- final Player p = e.getPlayer();
- if ((me.walking.Kits.KitAPI.Gladiator.contains(p.getName())))
- {
- ItemStack item = newItem(ChatColor.RED + "Gladiator", Material.IRON_FENCE);
- if ((p.getInventory().getItemInHand().equals(item)) &&
- (!this.arena.contains(p)) && (!this.arena.contains(c)))
- {
- this.arena.add(p);
- this.arena.add(c);
- this.local.put(p, p.getLocation());
- this.local.put(c, c.getLocation());
- Location arenaLoc = new Location(
- p.getWorld(),
- p.getLocation().getX(),
- p.getWorld().getHighestBlockYAt(p.getLocation()) + 70,
- p.getLocation().getZ());
- for (int x = -8; x < 7; x++) {
- for (int y = 0; y < 7; y++) {
- for (int z = -8; z < 7; z++)
- {
- Block x1 = arenaLoc.clone().add(6.0D, y, z).getBlock();
- Block x2 = arenaLoc.clone().add(-8.0D, y, z).getBlock();
- Block y1 = arenaLoc.clone().add(x, 0.0D, z).getBlock();
- Block y2 = arenaLoc.clone().add(x, 7.0D, z).getBlock();
- Block z1 = arenaLoc.clone().add(x, y, 6.0D).getBlock();
- Block z2 = arenaLoc.clone().add(x, y, -8.0D).getBlock();
- x1.setType(Material.GLASS);
- x2.setType(Material.GLASS);
- y1.setType(Material.GLASS);
- y2.setType(Material.GLASS);
- z1.setType(Material.GLASS);
- z2.setType(Material.GLASS);
- this.bArray.add(x1);
- this.bArray.add(x2);
- this.bArray.add(y1);
- this.bArray.add(y2);
- this.bArray.add(z1);
- this.bArray.add(z2);
- }
- }
- }
- p.sendMessage(ChatColor.GREEN + "Voce desafiou " + c.getName());
- p.sendMessage(ChatColor.RED + "Voce esta invencivel por 5 segundos");
- c.sendMessage(ChatColor.RED + "Voce esta invencivel por 5 segundos");
- for (int x = -8; x < 7; x++) {
- for (int y = 0; y < 7; y++) {
- for (int z = -8; z < 7; z++)
- {
- final Block x1 = arenaLoc.clone().add(6.0D, y, z).getBlock();
- final Block x2 = arenaLoc.clone().add(-8.0D, y, z).getBlock();
- final Block y1 = arenaLoc.clone().add(x, 0.0D, z).getBlock();
- final Block y2 = arenaLoc.clone().add(x, 7.0D, z).getBlock();
- final Block z1 = arenaLoc.clone().add(x, y, 6.0D).getBlock();
- final Block z2 = arenaLoc.clone().add(x, y, -8.0D).getBlock();
- p.teleport(arenaLoc.clone().add(x - 1.5D, y - 3, -7.0D));
- c.teleport(arenaLoc.clone().add(-7.0D, y - 3, z - 1.5D));
- new BukkitRunnable()
- {
- int Remaining = 130;
- public void run()
- {
- this.Remaining -= 1;
- if ((!Gladiator.this.arena.contains(p)) || (!Gladiator.this.arena.contains(c)) || (!p.isOnline()) || (!c.isOnline()))
- {
- x1.setType(Material.AIR);
- x2.setType(Material.AIR);
- y1.setType(Material.AIR);
- y2.setType(Material.AIR);
- z1.setType(Material.AIR);
- z2.setType(Material.AIR);
- Gladiator.this.bArray.remove(x1);
- Gladiator.this.bArray.remove(x2);
- Gladiator.this.bArray.remove(y1);
- Gladiator.this.bArray.remove(y2);
- Gladiator.this.bArray.remove(z1);
- Gladiator.this.bArray.remove(z2);
- cancel();
- }
- else if (this.Remaining == 0)
- {
- cancel();
- p.addPotionEffect(new PotionEffect(PotionEffectType.WITHER, 2147483647, 1));
- c.addPotionEffect(new PotionEffect(PotionEffectType.WITHER, 2147483647, 1));
- }
- }
- }.runTaskTimer(this.plugin, 0L, 20L);
- }
- }
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment