Guest User

Untitled

a guest
Mar 8th, 2015
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.67 KB | None | 0 0
  1. package me.walking.Habilidades;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.HashMap;
  5. import me.walking.main.Main;
  6. import org.bukkit.Bukkit;
  7. import org.bukkit.ChatColor;
  8. import org.bukkit.Location;
  9. import org.bukkit.Material;
  10. import org.bukkit.block.Block;
  11. import org.bukkit.entity.Player;
  12. import org.bukkit.event.EventHandler;
  13. import org.bukkit.event.Listener;
  14. import org.bukkit.event.block.Action;
  15. import org.bukkit.event.block.BlockBreakEvent;
  16. import org.bukkit.event.block.BlockPlaceEvent;
  17. import org.bukkit.event.entity.PlayerDeathEvent;
  18. import org.bukkit.event.player.PlayerDropItemEvent;
  19. import org.bukkit.event.player.PlayerInteractEntityEvent;
  20. import org.bukkit.event.player.PlayerInteractEvent;
  21. import org.bukkit.event.player.PlayerQuitEvent;
  22. import org.bukkit.inventory.ItemStack;
  23. import org.bukkit.inventory.meta.ItemMeta;
  24. import org.bukkit.potion.PotionEffect;
  25. import org.bukkit.potion.PotionEffectType;
  26. import org.bukkit.scheduler.BukkitRunnable;
  27.  
  28. public class Gladiator
  29. implements Listener
  30. {
  31. private Main plugin;
  32.  
  33. public Gladiator(Main plugin)
  34. {
  35. this.plugin = plugin;
  36. }
  37.  
  38. ArrayList<String> a = me.walking.Kits.KitAPI.Gladiator;
  39. @SuppressWarnings({ "unchecked", "rawtypes" })
  40. ArrayList<Player> arena = new ArrayList();
  41. @SuppressWarnings({ "unchecked", "rawtypes" })
  42. ArrayList<Block> bArray = new ArrayList();
  43. @SuppressWarnings({ "unchecked", "rawtypes" })
  44. private transient HashMap<Player, Location> local = new HashMap();
  45.  
  46. public static ItemStack newItem(String name, Material material)
  47. {
  48. ItemStack item = new ItemStack(material);
  49. ItemMeta meta = item.getItemMeta();
  50. meta.setDisplayName(name);
  51. item.setItemMeta(meta);
  52. return item;
  53. }
  54.  
  55. @EventHandler
  56. public void exit(PlayerQuitEvent e)
  57. {
  58. Player p = e.getPlayer();
  59. if (this.arena.contains(p)) {
  60. this.arena.remove(p);
  61. }
  62. }
  63.  
  64. @SuppressWarnings("deprecation")
  65. @EventHandler
  66. public void GladiatorPlaceCancel(BlockPlaceEvent e)
  67. {
  68. Player p = e.getPlayer();
  69. ItemStack item = newItem(ChatColor.RED + "Gladiator", Material.IRON_FENCE);
  70. if (p.getItemInHand().equals(item))
  71. {
  72. e.setCancelled(true);
  73. p.updateInventory();
  74. }
  75. }
  76.  
  77. @SuppressWarnings("deprecation")
  78. @EventHandler
  79. public void GladiatorDrop(PlayerDropItemEvent e)
  80. {
  81. ItemStack item = newItem(ChatColor.RED + "Gladiator", Material.IRON_FENCE);
  82. if (e.getItemDrop().getItemStack().equals(item))
  83. {
  84. e.setCancelled(true);
  85. e.getPlayer().updateInventory();
  86. }
  87. }
  88.  
  89. @EventHandler
  90. public void block(BlockBreakEvent e)
  91. {
  92. if (this.bArray.contains(e.getBlock())) {
  93. e.setCancelled(true);
  94. }
  95. }
  96.  
  97. @EventHandler
  98. public void interact(final PlayerInteractEvent e)
  99. {
  100. final Player p = e.getPlayer();
  101. if ((e.getAction() == Action.LEFT_CLICK_BLOCK) &&
  102. (this.arena.contains(p)) &&
  103. (this.bArray.contains(e.getClickedBlock())))
  104. {
  105. e.getClickedBlock().setType(Material.BEDROCK);
  106. if (e.getClickedBlock().getLocation().getBlock().getType() != Material.AIR) {
  107. Bukkit.getScheduler().scheduleSyncDelayedTask(this.plugin, new Runnable()
  108. {
  109. public void run()
  110. {
  111. if (Gladiator.this.arena.contains(p)) {
  112. e.getClickedBlock().setType(Material.GLASS);
  113. }
  114. }
  115. }, 20L);
  116. }
  117. }
  118. }
  119.  
  120. @EventHandler
  121. public void death(PlayerDeathEvent e)
  122. {
  123. if (((e.getEntity() instanceof Player)) && ((e.getEntity().getKiller() instanceof Player)))
  124. {
  125. Player p = e.getEntity();
  126. Player k = p.getKiller();
  127. if ((this.arena.contains(p)) && (this.arena.contains(k)))
  128. {
  129. this.arena.remove(p);
  130. this.arena.remove(k);
  131.  
  132. k.sendMessage(ChatColor.GREEN + "Voce ganhou de " + p.getName());
  133.  
  134. k.teleport((Location)this.local.get(k));
  135. k.removePotionEffect(PotionEffectType.WITHER);
  136. p.removePotionEffect(PotionEffectType.WITHER);
  137. }
  138. }
  139. }
  140.  
  141. @EventHandler
  142. public void click(PlayerInteractEntityEvent e)
  143. {
  144. if ((e.getRightClicked() instanceof Player))
  145. {
  146. final Player c = (Player)e.getRightClicked();
  147. final Player p = e.getPlayer();
  148. if ((me.walking.Kits.KitAPI.Gladiator.contains(p.getName())))
  149. {
  150. ItemStack item = newItem(ChatColor.RED + "Gladiator", Material.IRON_FENCE);
  151. if ((p.getInventory().getItemInHand().equals(item)) &&
  152. (!this.arena.contains(p)) && (!this.arena.contains(c)))
  153. {
  154. this.arena.add(p);
  155. this.arena.add(c);
  156.  
  157. this.local.put(p, p.getLocation());
  158. this.local.put(c, c.getLocation());
  159.  
  160. Location arenaLoc = new Location(
  161. p.getWorld(),
  162. p.getLocation().getX(),
  163. p.getWorld().getHighestBlockYAt(p.getLocation()) + 70,
  164. p.getLocation().getZ());
  165. for (int x = -8; x < 7; x++) {
  166. for (int y = 0; y < 7; y++) {
  167. for (int z = -8; z < 7; z++)
  168. {
  169. Block x1 = arenaLoc.clone().add(6.0D, y, z).getBlock();
  170. Block x2 = arenaLoc.clone().add(-8.0D, y, z).getBlock();
  171. Block y1 = arenaLoc.clone().add(x, 0.0D, z).getBlock();
  172. Block y2 = arenaLoc.clone().add(x, 7.0D, z).getBlock();
  173. Block z1 = arenaLoc.clone().add(x, y, 6.0D).getBlock();
  174. Block z2 = arenaLoc.clone().add(x, y, -8.0D).getBlock();
  175.  
  176. x1.setType(Material.GLASS);
  177. x2.setType(Material.GLASS);
  178. y1.setType(Material.GLASS);
  179. y2.setType(Material.GLASS);
  180. z1.setType(Material.GLASS);
  181. z2.setType(Material.GLASS);
  182.  
  183. this.bArray.add(x1);
  184. this.bArray.add(x2);
  185. this.bArray.add(y1);
  186. this.bArray.add(y2);
  187. this.bArray.add(z1);
  188. this.bArray.add(z2);
  189. }
  190. }
  191. }
  192. p.sendMessage(ChatColor.GREEN + "Voce desafiou " + c.getName());
  193. p.sendMessage(ChatColor.RED + "Voce esta invencivel por 5 segundos");
  194. c.sendMessage(ChatColor.RED + "Voce esta invencivel por 5 segundos");
  195. for (int x = -8; x < 7; x++) {
  196. for (int y = 0; y < 7; y++) {
  197. for (int z = -8; z < 7; z++)
  198. {
  199. final Block x1 = arenaLoc.clone().add(6.0D, y, z).getBlock();
  200. final Block x2 = arenaLoc.clone().add(-8.0D, y, z).getBlock();
  201. final Block y1 = arenaLoc.clone().add(x, 0.0D, z).getBlock();
  202. final Block y2 = arenaLoc.clone().add(x, 7.0D, z).getBlock();
  203. final Block z1 = arenaLoc.clone().add(x, y, 6.0D).getBlock();
  204. final Block z2 = arenaLoc.clone().add(x, y, -8.0D).getBlock();
  205.  
  206. p.teleport(arenaLoc.clone().add(x - 1.5D, y - 3, -7.0D));
  207. c.teleport(arenaLoc.clone().add(-7.0D, y - 3, z - 1.5D));
  208.  
  209. new BukkitRunnable()
  210. {
  211. int Remaining = 130;
  212.  
  213. public void run()
  214. {
  215. this.Remaining -= 1;
  216. if ((!Gladiator.this.arena.contains(p)) || (!Gladiator.this.arena.contains(c)) || (!p.isOnline()) || (!c.isOnline()))
  217. {
  218. x1.setType(Material.AIR);
  219. x2.setType(Material.AIR);
  220. y1.setType(Material.AIR);
  221. y2.setType(Material.AIR);
  222. z1.setType(Material.AIR);
  223. z2.setType(Material.AIR);
  224.  
  225. Gladiator.this.bArray.remove(x1);
  226. Gladiator.this.bArray.remove(x2);
  227. Gladiator.this.bArray.remove(y1);
  228. Gladiator.this.bArray.remove(y2);
  229. Gladiator.this.bArray.remove(z1);
  230. Gladiator.this.bArray.remove(z2);
  231.  
  232. cancel();
  233. }
  234. else if (this.Remaining == 0)
  235. {
  236. cancel();
  237. p.addPotionEffect(new PotionEffect(PotionEffectType.WITHER, 2147483647, 1));
  238. c.addPotionEffect(new PotionEffect(PotionEffectType.WITHER, 2147483647, 1));
  239. }
  240. }
  241. }.runTaskTimer(this.plugin, 0L, 20L);
  242. }
  243. }
  244. }
  245. }
  246. }
  247. }
  248. }
  249. }
Advertisement
Add Comment
Please, Sign In to add comment