Пример #1
0
 @Override
 public void close() {
   this.unloadChunks();
   for (String index : new ArrayList<>(this.regions.keySet())) {
     RegionLoader region = this.regions.get(index);
     try {
       region.close();
     } catch (IOException e) {
       throw new RuntimeException(e);
     }
     this.regions.remove(index);
   }
   this.level = null;
 }
Пример #2
0
 @Override
 public void doGarbageCollection() {
   int limit = (int) (System.currentTimeMillis() - 300);
   for (Map.Entry entry : this.regions.entrySet()) {
     String index = (String) entry.getKey();
     RegionLoader region = (RegionLoader) entry.getValue();
     if (region.lastUsed <= limit) {
       try {
         region.close();
       } catch (IOException e) {
         throw new RuntimeException(e);
       }
       this.regions.remove(index);
     }
   }
 }
Пример #3
0
 @Override
 public boolean isChunkGenerated(int chunkX, int chunkZ) {
   RegionLoader region = this.getRegion(chunkX >> 5, chunkZ >> 5);
   return region != null
       && region.chunkExists(chunkX - region.getX() * 32, chunkZ - region.getZ() * 32)
       && this.getChunk(chunkX - region.getX() * 32, chunkZ - region.getZ() * 32, true)
           .isGenerated();
 }