WorldManager: fixed loading the default world's spawn chunk when unloading the default world

yo dawg
I heard you like loading and unloading
so I put some loading inside your unloading
so you can load while you unload
This commit is contained in:
Dylan K. Taylor 2022-02-04 19:21:46 +00:00
parent 2a4111868c
commit 712ffb3e31
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -154,12 +154,12 @@ class WorldManager{
$this->server->getLogger()->info($this->server->getLanguage()->translate(KnownTranslationFactory::pocketmine_level_unloading($world->getDisplayName())));
try{
$safeSpawn = $this->defaultWorld !== null ? $this->defaultWorld->getSafeSpawn() : null;
$safeSpawn = $this->defaultWorld !== null && $this->defaultWorld !== $world ? $this->defaultWorld->getSafeSpawn() : null;
}catch(WorldException $e){
$safeSpawn = null;
}
foreach($world->getPlayers() as $player){
if($world === $this->defaultWorld or $safeSpawn === null){
if($safeSpawn === null){
$player->disconnect("Forced default world unload");
}else{
$player->teleport($safeSpawn);