NetworkSession: account for possibility of syncGameMode() being called before the player is ready to receive it

close #4323
This commit is contained in:
Dylan K. Taylor
2021-10-04 22:12:58 +01:00
parent 6332af3e59
commit 356a49d225
2 changed files with 5 additions and 8 deletions

View File

@@ -754,8 +754,10 @@ class NetworkSession{
public function syncGameMode(GameMode $mode, bool $isRollback = false) : void{
$this->sendDataPacket(SetPlayerGameTypePacket::create(TypeConverter::getInstance()->coreGameModeToProtocol($mode)));
$this->syncAdventureSettings($this->player);
if(!$isRollback){
if($this->player !== null){
$this->syncAdventureSettings($this->player);
}
if(!$isRollback && $this->invManager !== null){
$this->invManager->syncCreative();
}
}