Level: Unload chunks prior to save() to avoid saving chunks twice on shutdown

save() calls saveChunks() which saves any chunks found to be modified. But chunk unloading does this anyway, so it's better to unload first and then trigger the save mechanism, to avoid saving chunks twice.
This commit is contained in:
Dylan K. Taylor 2018-03-07 19:47:54 +00:00
parent 73a5788774
commit 1f77c074e9

View File

@ -450,14 +450,14 @@ class Level implements ChunkManager, Metadatable{
throw new \InvalidStateException("Tried to close a level which is already closed");
}
if($this->getAutoSave()){
$this->save();
}
foreach($this->chunks as $chunk){
$this->unloadChunk($chunk->getX(), $chunk->getZ(), false);
}
if($this->getAutoSave()){
$this->save();
}
$this->unregisterGenerator();
$this->provider->close();