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
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
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();
}
}

View File

@ -125,11 +125,6 @@ parameters:
count: 1
path: ../../../src/network/mcpe/NetworkSession.php
-
message: "#^Cannot call method syncCreative\\(\\) on pocketmine\\\\network\\\\mcpe\\\\InventoryManager\\|null\\.$#"
count: 1
path: ../../../src/network/mcpe/NetworkSession.php
-
message: "#^Parameter \\#1 \\$clientPub of class pocketmine\\\\network\\\\mcpe\\\\encryption\\\\PrepareEncryptionTask constructor expects string, string\\|null given\\.$#"
count: 1
@ -147,7 +142,7 @@ parameters:
-
message: "#^Parameter \\#1 \\$for of method pocketmine\\\\network\\\\mcpe\\\\NetworkSession\\:\\:syncAdventureSettings\\(\\) expects pocketmine\\\\player\\\\Player, pocketmine\\\\player\\\\Player\\|null given\\.$#"
count: 3
count: 2
path: ../../../src/network/mcpe/NetworkSession.php
-