NetworkSession: rename some badly-named hooks

This commit is contained in:
Dylan K. Taylor 2020-11-10 15:01:48 +00:00
parent e23379c34b
commit 75f2f12b99
2 changed files with 9 additions and 9 deletions

View File

@ -602,17 +602,17 @@ class NetworkSession{
$this->cipher = new EncryptionContext($encryptionKey); $this->cipher = new EncryptionContext($encryptionKey);
$this->setHandler(new HandshakePacketHandler(function() : void{ $this->setHandler(new HandshakePacketHandler(function() : void{
$this->onLoginSuccess(); $this->onServerLoginSuccess();
})); }));
$this->logger->debug("Enabled encryption"); $this->logger->debug("Enabled encryption");
})); }));
}else{ }else{
$this->onLoginSuccess(); $this->onServerLoginSuccess();
} }
} }
} }
private function onLoginSuccess() : void{ private function onServerLoginSuccess() : void{
$this->loggedIn = true; $this->loggedIn = true;
$this->sendDataPacket(PlayStatusPacket::create(PlayStatusPacket::LOGIN_SUCCESS)); $this->sendDataPacket(PlayStatusPacket::create(PlayStatusPacket::LOGIN_SUCCESS));
@ -636,24 +636,24 @@ class NetworkSession{
$this->logger->debug("Sending spawn notification, waiting for spawn response"); $this->logger->debug("Sending spawn notification, waiting for spawn response");
$this->sendDataPacket(PlayStatusPacket::create(PlayStatusPacket::PLAYER_SPAWN)); $this->sendDataPacket(PlayStatusPacket::create(PlayStatusPacket::PLAYER_SPAWN));
$this->setHandler(new SpawnResponsePacketHandler(function() : void{ $this->setHandler(new SpawnResponsePacketHandler(function() : void{
$this->onSpawn(); $this->onClientSpawnResponse();
})); }));
} }
private function onSpawn() : void{ private function onClientSpawnResponse() : void{
$this->logger->debug("Received spawn response, entering in-game phase"); $this->logger->debug("Received spawn response, entering in-game phase");
$this->player->setImmobile(false); //TODO: HACK: we set this during the spawn sequence to prevent the client sending junk movements $this->player->setImmobile(false); //TODO: HACK: we set this during the spawn sequence to prevent the client sending junk movements
$this->player->doFirstSpawn(); $this->player->doFirstSpawn();
$this->setHandler(new InGamePacketHandler($this->player, $this)); $this->setHandler(new InGamePacketHandler($this->player, $this));
} }
public function onDeath() : void{ public function onServerDeath() : void{
if($this->handler instanceof InGamePacketHandler){ //TODO: this is a bad fix for pre-spawn death, this shouldn't be reachable at all at this stage :( if($this->handler instanceof InGamePacketHandler){ //TODO: this is a bad fix for pre-spawn death, this shouldn't be reachable at all at this stage :(
$this->setHandler(new DeathPacketHandler($this->player, $this)); $this->setHandler(new DeathPacketHandler($this->player, $this));
} }
} }
public function onRespawn() : void{ public function onServerRespawn() : void{
$this->player->sendData(null); $this->player->sendData(null);
$this->syncAdventureSettings($this->player); $this->syncAdventureSettings($this->player);

View File

@ -2149,7 +2149,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
$this->startDeathAnimation(); $this->startDeathAnimation();
$this->networkSession->onDeath(); $this->networkSession->onServerDeath();
} }
protected function onDeathUpdate(int $tickDiff) : bool{ protected function onDeathUpdate(int $tickDiff) : bool{
@ -2187,7 +2187,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
$this->spawnToAll(); $this->spawnToAll();
$this->scheduleUpdate(); $this->scheduleUpdate();
$this->networkSession->onRespawn(); $this->networkSession->onServerRespawn();
} }
protected function applyPostDamageEffects(EntityDamageEvent $source) : void{ protected function applyPostDamageEffects(EntityDamageEvent $source) : void{