mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-07 02:08:21 +00:00
Possible fix for #2077
This commit is contained in:
@ -633,7 +633,7 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function __debugInfo(){
|
public function __debugInfo(){
|
||||||
return get_class($this);
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -650,7 +650,7 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
$this->server->getPluginManager()->callEvent(new LevelSaveEvent($this));
|
$this->server->getPluginManager()->callEvent(new LevelSaveEvent($this));
|
||||||
|
|
||||||
$this->provider->setTime((int) $this->time);
|
$this->provider->setTime((int) $this->time);
|
||||||
$this->provider->saveChunks(); //TODO: only save changed chunks
|
$this->saveChunks();
|
||||||
if($this->provider instanceof BaseLevelProvider){
|
if($this->provider instanceof BaseLevelProvider){
|
||||||
$this->provider->saveLevelData();
|
$this->provider->saveLevelData();
|
||||||
}
|
}
|
||||||
@ -658,6 +658,14 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function saveChunks(){
|
||||||
|
//TODO: only save changed chunks
|
||||||
|
foreach($this->chunks as $chunk){
|
||||||
|
$this->provider->setChunk($chunk->getX(), $chunk->getZ(), $chunk);
|
||||||
|
$this->provider->saveChunk($chunk->getX(), $chunk->getZ());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Vector3 $pos
|
* @param Vector3 $pos
|
||||||
* @param int $type
|
* @param int $type
|
||||||
@ -1765,6 +1773,8 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$index = "$x:$z";
|
||||||
|
|
||||||
$chunk = $this->getChunkAt($x, $z);
|
$chunk = $this->getChunkAt($x, $z);
|
||||||
|
|
||||||
if($chunk instanceof FullChunk){
|
if($chunk instanceof FullChunk){
|
||||||
@ -1777,10 +1787,13 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
$this->timings->doChunkUnload->startTiming();
|
$this->timings->doChunkUnload->startTiming();
|
||||||
|
|
||||||
if($this->getAutoSave()){
|
if($this->getAutoSave()){
|
||||||
|
if(isset($this->chunks[$index])){
|
||||||
|
$this->provider->setChunk($x, $z, $this->chunks[$index]);
|
||||||
|
}
|
||||||
$this->provider->saveChunk($x, $z);
|
$this->provider->saveChunk($x, $z);
|
||||||
}
|
}
|
||||||
|
|
||||||
unset($this->chunks[$index = Level::chunkHash($x, $z)]);
|
unset($this->chunks[$index]);
|
||||||
$this->provider->unloadChunk($x, $z, $safe);
|
$this->provider->unloadChunk($x, $z, $safe);
|
||||||
unset($this->usedChunks[$index]);
|
unset($this->usedChunks[$index]);
|
||||||
Cache::remove("world:" . $this->getID() . ":$x:$z");
|
Cache::remove("world:" . $this->getID() . ":$x:$z");
|
||||||
|
Reference in New Issue
Block a user