Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static ArrayList<Player> players = new ArrayList<Player>();
- public static ListIterator<Player> iterPlayers = players.listIterator();
- public static Location holeLoc;
- public static void createBlackHole(Location loc) {
- final int pullRadius = plugin.getConfig().getInt("Pull Radius");
- Block b = loc.getBlock();
- holeLoc = loc;
- b.setType(Material.CAKE_BLOCK);
- Bukkit.getScheduler().runTaskTimer(plugin, new Runnable() {
- public void run() {
- for (Player nearbyPlayers : holeLoc.getWorld().getPlayers()) {
- if(nearbyPlayers.getWorld() != holeLoc.getWorld() || nearbyPlayers.getLocation().distance(holeLoc) > pullRadius) {
- continue;
- }
- players.add(nearbyPlayers);
- }
- while(iterPlayers.hasNext()) {
- Player p = iterPlayers.next();
- if(p.getWorld() != holeLoc.getWorld() || p.getLocation().distance(holeLoc) > pullRadius) {
- iterPlayers.remove();
- continue;
- }
- Vector vector = holeLoc.toVector().subtract(p.getLocation().toVector());
- p.setVelocity(vector.multiply(0.5));
- }
- }
- }, 100, 999999);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement