Player::getNetworkSession() now explicitly handles disconnected state by throwing an exception

instead of just allowing return of possibly-null networkSession
This commit is contained in:
Dylan K. Taylor
2021-01-10 19:50:13 +00:00
parent 3ef2a19527
commit 5e73417fa9

View File

@ -530,6 +530,9 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
} }
public function getNetworkSession() : NetworkSession{ public function getNetworkSession() : NetworkSession{
if($this->networkSession === null){
throw new \InvalidStateException("Player is not connected");
}
return $this->networkSession; return $this->networkSession;
} }