From 3ac0c98199484abd08d6bb66fac5ef21c409d40d Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Mon, 10 Jun 2019 19:31:54 +0100 Subject: [PATCH] De-spaghettify spawn notification handling --- src/pocketmine/Player.php | 2 -- src/pocketmine/network/mcpe/NetworkSession.php | 1 + src/pocketmine/network/mcpe/handler/PreSpawnSessionHandler.php | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index f623927fa..559090fa0 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -1001,8 +1001,6 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener, } public function doFirstSpawn(){ - $this->networkSession->onSpawn(); - if($this->hasPermission(Server::BROADCAST_CHANNEL_USERS)){ PermissionManager::getInstance()->subscribeToPermission(Server::BROADCAST_CHANNEL_USERS, $this); } diff --git a/src/pocketmine/network/mcpe/NetworkSession.php b/src/pocketmine/network/mcpe/NetworkSession.php index 943b8584a..49601d88a 100644 --- a/src/pocketmine/network/mcpe/NetworkSession.php +++ b/src/pocketmine/network/mcpe/NetworkSession.php @@ -567,6 +567,7 @@ class NetworkSession{ } public function onSpawn() : void{ + $this->player->doFirstSpawn(); $this->setHandler(new InGameSessionHandler($this->player, $this)); } diff --git a/src/pocketmine/network/mcpe/handler/PreSpawnSessionHandler.php b/src/pocketmine/network/mcpe/handler/PreSpawnSessionHandler.php index 81a67f3df..ef8fd1f33 100644 --- a/src/pocketmine/network/mcpe/handler/PreSpawnSessionHandler.php +++ b/src/pocketmine/network/mcpe/handler/PreSpawnSessionHandler.php @@ -108,7 +108,7 @@ class PreSpawnSessionHandler extends SessionHandler{ public function handleSetLocalPlayerAsInitialized(SetLocalPlayerAsInitializedPacket $packet) : bool{ $this->player->setImmobile(false); //HACK: this is set to prevent client-side falling before spawn - $this->player->doFirstSpawn(); + $this->session->onSpawn(); return true; }