Exemple #1
0
 @Override
 public boolean unloadChunk(int X, int Z, boolean safe) {
   String index = Level.chunkHash(X, Z);
   Chunk chunk = this.chunks.containsKey(index) ? this.chunks.get(index) : null;
   if (chunk != null && chunk.unload(false, safe)) {
     this.chunks.remove(index);
     return true;
   }
   return false;
 }
 /**
  * Unloads a chunk. The chunk is saved, when it has been changed.
  *
  * @param chunk The chunk to unload.
  */
 public void unloadChunk(final Chunk chunk) {
   final Pair pos = chunk.getPos();
   synchronized (chunks) {
     chunks.remove(pos);
   }
   synchronized (reload) {
     reload.put(pos, chunk.getFile());
   }
   synchronized (otherPos) {
     otherPos.put(pos, chunk.getOtherPos());
   }
   synchronized (mayUnload) {
     mayUnload.remove(chunk);
   }
   // writes the chunk if changed
   chunk.unload();
 }