Advertisement
Guest User

Untitled

a guest
Jul 28th, 2013
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. public static ArrayList<Player> players = new ArrayList<Player>();
  2. public static ListIterator<Player> iterPlayers = players.listIterator();
  3. public static Location holeLoc;
  4.  
  5. public static void createBlackHole(Location loc) {
  6. final int pullRadius = plugin.getConfig().getInt("Pull Radius");
  7. Block b = loc.getBlock();
  8. holeLoc = loc;
  9. b.setType(Material.CAKE_BLOCK);
  10.  
  11. Bukkit.getScheduler().runTaskTimer(plugin, new Runnable() {
  12. public void run() {
  13.  
  14. for (Player nearbyPlayers : holeLoc.getWorld().getPlayers()) {
  15. if(nearbyPlayers.getWorld() != holeLoc.getWorld() || nearbyPlayers.getLocation().distance(holeLoc) > pullRadius) {
  16. continue;
  17. }
  18. players.add(nearbyPlayers);
  19. }
  20.  
  21. while(iterPlayers.hasNext()) {
  22. Player p = iterPlayers.next();
  23. if(p.getWorld() != holeLoc.getWorld() || p.getLocation().distance(holeLoc) > pullRadius) {
  24. iterPlayers.remove();
  25. continue;
  26. }
  27. Vector vector = holeLoc.toVector().subtract(p.getLocation().toVector());
  28. p.setVelocity(vector.multiply(0.5));
  29. }
  30.  
  31. }
  32. }, 100, 999999);
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement