xeRicker

Untitled

Aug 4th, 2016
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. @Override
  2. public boolean onCommand(CommandSender commandSender, Command command, String label, String[] args) {
  3. if (command.getName().equalsIgnoreCase("spawncreepers")) {
  4. final Player player = (Player) commandSender;
  5. new BukkitRunnable() {
  6. int step = 0;
  7.  
  8. @Override
  9. public void run() {
  10. step++;
  11. if (step <= 10 * 4) {
  12. spawnCreepers2(player);
  13. } else {
  14. cancel();
  15. }
  16. }
  17. }.runTaskTimer(Main.getInstance(), 0, 5);
  18. }
  19. return false;
  20. }
  21.  
  22. public static void spawnCreepers2(final Player player) {
  23. final Creeper c1 = player.getWorld().spawn(player.getLocation(), Creeper.class);
  24. final Creeper c2 = player.getWorld().spawn(player.getLocation(), Creeper.class);
  25. final Creeper c3 = player.getWorld().spawn(player.getLocation(), Creeper.class);
  26.  
  27. c1.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 0));
  28. c2.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 0));
  29. c3.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 0));
  30.  
  31. c1.setPowered(true);
  32. c2.setPowered(true);
  33. c3.setPowered(true);
  34.  
  35. new BukkitRunnable() {
  36. int particleStep = 0;
  37. int particleStep2 = 20 * 7;
  38. int particleStep3 = 40 * 7;
  39.  
  40. @Override
  41. public void run() {
  42. if (!player.isOnline()) {
  43. c1.remove();
  44. c2.remove();
  45. c3.remove();
  46. cancel();
  47. return;
  48. }
  49.  
  50. List<Location> locations = LocationUtils.getCircle(player.getLocation(), 3 * 7, 60 * 7);
  51.  
  52. c1.teleport(locations.get(particleStep));
  53. c2.teleport(locations.get(particleStep2));
  54. c3.teleport(locations.get(particleStep3));
  55. }
  56. }.runTaskTimer(Main.getInstance(), 0, 1);
  57. }
Advertisement
Add Comment
Please, Sign In to add comment