Advertisement
Yuki_20

Untitled

Oct 8th, 2014
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. public class Timelord
  2. implements Listener
  3. {
  4. public MainClass plugin;
  5. public ArrayList<String> frozenPlayers = new ArrayList();
  6.  
  7. public Timelord(MainClass instance)
  8. {
  9. this.plugin = instance;
  10. }
  11.  
  12. @EventHandler
  13. public void onEntityDamage(PlayerInteractEvent event) {
  14. Player player = event.getPlayer();
  15.  
  16. if ((player.getItemInHand().getType().equals(Material.WATCH)) && (
  17. (event.getAction() == Action.RIGHT_CLICK_AIR) ||
  18. (event.getAction() == Action.RIGHT_CLICK_BLOCK))) {
  19. if (Abilities.cooldown.contains(player.getName())) {
  20. player.sendMessage("§cEspere o cooldown !");
  21. return;
  22. }
  23. if (User.isTimelordkit(player).booleanValue()) {
  24. List nearbyEntities = event.getPlayer().getNearbyEntities(5.0D, 5.0D, 5.0D);
  25. for (Entity target : nearbyEntities)
  26. if ((target instanceof Player)) {
  27. Player t = (Player)target;
  28. this.frozenPlayers.add(t.getName());
  29.  
  30. Abilities.cooldown.add(player.getName());
  31. player.sendMessage("§cO Tempo foi parado !");
  32. t.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 100, 5));
  33.  
  34. Bukkit.getServer().getScheduler().runTaskLater(this.plugin, new Runnable(t) {
  35. public void run() {
  36. Timelord.this.frozenPlayers.remove(this.val$t.getName());
  37. this.val$t.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 300, 2));
  38. }
  39. }
  40. , 100L);
  41.  
  42. Bukkit.getServer().getScheduler().runTaskLater(this.plugin, new Runnable(t) {
  43. public void run() {
  44. Abilities.cooldown.remove(this.val$t.getName());
  45. }
  46. }
  47. , 800L);
  48. }
  49. }
  50. }
  51. }
  52.  
  53. @EventHandler
  54. public void onPlayerMove(PlayerMoveEvent e)
  55. {
  56. if (this.frozenPlayers.contains(e.getPlayer().getName()))
  57. e.getPlayer().teleport(e.getPlayer());
  58. }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement