mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 16:24:05 +00:00
Throw exception when attempting to save a non-generated chunk (#367)
This commit is contained in:
parent
c21197ef17
commit
282095513a
@ -992,7 +992,7 @@ class Level implements ChunkManager, Metadatable{
|
||||
|
||||
public function saveChunks(){
|
||||
foreach($this->chunks as $chunk){
|
||||
if($chunk->hasChanged()){
|
||||
if($chunk->hasChanged() and $chunk->isGenerated()){
|
||||
$this->provider->setChunk($chunk->getX(), $chunk->getZ(), $chunk);
|
||||
$this->provider->saveChunk($chunk->getX(), $chunk->getZ());
|
||||
$chunk->setChanged(false);
|
||||
@ -2497,7 +2497,7 @@ class Level implements ChunkManager, Metadatable{
|
||||
|
||||
try{
|
||||
if($chunk !== null){
|
||||
if($trySave and $this->getAutoSave()){
|
||||
if($trySave and $this->getAutoSave() and $chunk->isGenerated()){
|
||||
$entities = 0;
|
||||
foreach($chunk->getEntities() as $e){
|
||||
if($e instanceof Player){
|
||||
|
@ -477,9 +477,13 @@ class LevelDB extends BaseLevelProvider{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function saveChunk(int $x, int $z) : bool{
|
||||
if($this->isChunkLoaded($x, $z)){
|
||||
$this->writeChunk($this->getChunk($x, $z));
|
||||
public function saveChunk(int $chunkX, int $chunkZ) : bool{
|
||||
if($this->isChunkLoaded($chunkX, $chunkZ)){
|
||||
$chunk = $this->getChunk($chunkX, $chunkZ);
|
||||
if(!$chunk->isGenerated()){
|
||||
throw new \InvalidStateException("Cannot save un-generated chunk");
|
||||
}
|
||||
$this->writeChunk($chunk);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -309,7 +309,11 @@ class McRegion extends BaseLevelProvider{
|
||||
|
||||
public function saveChunk(int $chunkX, int $chunkZ) : bool{
|
||||
if($this->isChunkLoaded($chunkX, $chunkZ)){
|
||||
$this->getRegion($chunkX >> 5, $chunkZ >> 5)->writeChunk($this->getChunk($chunkX, $chunkZ));
|
||||
$chunk = $this->getChunk($chunkX, $chunkZ);
|
||||
if(!$chunk->isGenerated()){
|
||||
throw new \InvalidStateException("Cannot save un-generated chunk");
|
||||
}
|
||||
$this->getRegion($chunkX >> 5, $chunkZ >> 5)->writeChunk($chunk);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user