Ejemplo n.º 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;
 }
Ejemplo n.º 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);
     }
   }
 }
Ejemplo n.º 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();
 }