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