De-spaghettify spawn notification handling

This commit is contained in:
Dylan K. Taylor 2019-06-10 19:31:54 +01:00
parent 714393820f
commit 3ac0c98199
3 changed files with 2 additions and 3 deletions

View File

@ -1001,8 +1001,6 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
} }
public function doFirstSpawn(){ public function doFirstSpawn(){
$this->networkSession->onSpawn();
if($this->hasPermission(Server::BROADCAST_CHANNEL_USERS)){ if($this->hasPermission(Server::BROADCAST_CHANNEL_USERS)){
PermissionManager::getInstance()->subscribeToPermission(Server::BROADCAST_CHANNEL_USERS, $this); PermissionManager::getInstance()->subscribeToPermission(Server::BROADCAST_CHANNEL_USERS, $this);
} }

View File

@ -567,6 +567,7 @@ class NetworkSession{
} }
public function onSpawn() : void{ public function onSpawn() : void{
$this->player->doFirstSpawn();
$this->setHandler(new InGameSessionHandler($this->player, $this)); $this->setHandler(new InGameSessionHandler($this->player, $this));
} }

View File

@ -108,7 +108,7 @@ class PreSpawnSessionHandler extends SessionHandler{
public function handleSetLocalPlayerAsInitialized(SetLocalPlayerAsInitializedPacket $packet) : bool{ public function handleSetLocalPlayerAsInitialized(SetLocalPlayerAsInitializedPacket $packet) : bool{
$this->player->setImmobile(false); //HACK: this is set to prevent client-side falling before spawn $this->player->setImmobile(false); //HACK: this is set to prevent client-side falling before spawn
$this->player->doFirstSpawn(); $this->session->onSpawn();
return true; return true;
} }