Advertisement
Guest User

Untitled

a guest
May 30th, 2015
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package net.ultimamc.spigot.free.chunkunloader;
  2.  
  3. import org.bukkit.plugin.*;
  4. import java.util.*;
  5. import org.bukkit.*;
  6. import org.bukkit.entity.*;
  7.  
  8. public class ChunkBreaker {
  9. public static void clear(JavaPlugin p) {
  10. List<World> worlds = new ArrayList<>();
  11. for (World w : Bukkit.getWorlds()) {
  12. worlds.add(w);
  13. for (final String wo : this.p.getConfig().getStringList("disabled-worlds")) {
  14. if (Bukkit.getWorld(wo) != null) {
  15. worlds.remove(wo);
  16. }
  17. }
  18. for (final World world : this.worlds) {
  19. Chunk[] loadedChunks;
  20. for (int length = (loadedChunks = world.getLoadedChunks()).length, i = 0; i < length; ++i) {
  21. final Chunk c = loadedChunks[i];
  22. Collection<Player> onlinePlayers;
  23. for (int length2 = (onlinePlayers = Bukkit.getOnlinePlayers()).length, j = 0; j < length2; ++j) {
  24. final Player p = onlinePlayers[j];
  25. if (!p.getLocation().getChunk().equals(c)) {
  26. c.unload();
  27. }
  28. }
  29. }
  30. }
  31. }
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement