Advertisement
Guest User

MoveEvent

a guest
Jan 21st, 2015
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. private ArrayList<String> players = new ArrayList<>();
  2.  
  3. @EventHandler
  4. public void onMoveOverPlate(PlayerMoveEvent ev) {
  5.  
  6. final Player p = ev.getPlayer();
  7.  
  8. if (p.getLocation().getBlock().getType() == Material.STONE_PLATE) {
  9.  
  10. if (p.getLocation().subtract(0.0, 1.0, 0.0).getBlock().getType() == Material.REDSTONE_BLOCK) {
  11.  
  12. if (!(players.contains(p.getName()))) {
  13.  
  14. players.add(p.getName());
  15. p.setAllowFlight(true);
  16.  
  17. Bukkit.getScheduler().scheduleSyncDelayedTask(main, new Runnable() {
  18. @Override
  19. public void run() {
  20. players.remove(p.getName());
  21.  
  22. if (p.getGameMode() == GameMode.CREATIVE) {
  23. p.setAllowFlight(true);
  24. } else {
  25. p.setAllowFlight(false);
  26. }
  27.  
  28. }
  29. }, 20*2);
  30.  
  31. Vector v = p.getLocation().getDirection().setY(2).multiply(20);
  32. p.setVelocity(v);
  33.  
  34.  
  35. }
  36. }
  37. }
  38.  
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement