Fixed a crash when saving chunks

This commit is contained in:
Shoghi Cervantes 2015-04-15 15:54:27 +02:00
parent 5ca4f5416c
commit 298b973604

View File

@ -2159,6 +2159,7 @@ class Level implements ChunkManager, Metadatable{
}
try{
if($chunk !== null and $this->getAutoSave()){
$entities = 0;
foreach($chunk->getEntities() as $e){
if($e instanceof Player){
@ -2167,11 +2168,11 @@ class Level implements ChunkManager, Metadatable{
++$entities;
}
$save = ($chunk->hasChanged() or count($chunk->getTiles()) > 0 or $entities > 0);
if($chunk !== null and $this->getAutoSave() and $save){
if($chunk->hasChanged() or count($chunk->getTiles()) > 0 or $entities > 0){
$this->provider->setChunk($x, $z, $chunk);
$this->provider->saveChunk($x, $z);
}
}
$this->provider->unloadChunk($x, $z, $safe);
}catch(\Exception $e){
$logger = $this->server->getLogger();