Advertisement
Guest User

Untitled

a guest
Dec 15th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. public void playAnimation(ArmorStand armorStand) {
  2. armorStand.teleport(LOBBY_TO_KILLAGER.getEnterLocation());
  3.  
  4. int delay = 1;
  5. int firstBlockWalked = 21;
  6. int secondBlockWalked = 51;
  7. int thirdBlockWalked = 30;
  8.  
  9. int first = Bukkit.getScheduler().scheduleSyncRepeatingTask(lobby, () -> {
  10. armorStand.teleport(armorStand.getLocation().subtract(0, 0, 2));
  11. }, 0, delay);
  12.  
  13. Bukkit.getScheduler().scheduleSyncDelayedTask(lobby, () -> {
  14. Bukkit.getScheduler().cancelTask(first);
  15.  
  16. Location newLocation = new Location(armorStand.getLocation().getWorld()
  17. , armorStand.getLocation().getX(), armorStand.getLocation().getY(), armorStand.getLocation().getZ()
  18. , -90, armorStand.getLocation().getPitch());
  19.  
  20. armorStand.teleport(newLocation);
  21.  
  22. int second = Bukkit.getScheduler().scheduleSyncRepeatingTask(lobby, () -> {
  23. armorStand.teleport(armorStand.getLocation().add(2, 0, 0));
  24. }, 0, delay);
  25.  
  26. Bukkit.getScheduler().scheduleSyncDelayedTask(lobby, () -> {
  27. Bukkit.getScheduler().cancelTask(second);
  28.  
  29. Location newSecondLocation = new Location(armorStand.getLocation().getWorld()
  30. , armorStand.getLocation().getX(), armorStand.getLocation().getY(), armorStand.getLocation().getZ()
  31. , 180, armorStand.getLocation().getPitch());
  32.  
  33. armorStand.teleport(newSecondLocation);
  34.  
  35. int third = Bukkit.getScheduler().scheduleSyncRepeatingTask(lobby, () -> {
  36. armorStand.teleport(armorStand.getLocation().subtract(0, 0, 2));
  37. }, 0, delay);
  38.  
  39. Bukkit.getScheduler().scheduleSyncDelayedTask(lobby, () -> {
  40. Bukkit.getScheduler().cancelTask(third);
  41.  
  42. }, delay * (thirdBlockWalked / 2));
  43.  
  44. }, delay * (secondBlockWalked / 2));
  45.  
  46. }, delay * (firstBlockWalked / 2));
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement