*/ private string $baseClass = Player::class; /** @phpstan-var class-string */ private string $playerClass = Player::class; public function __construct(private NetworkSession $session){} public function getNetworkSession() : NetworkSession{ return $this->session; } public function getAddress() : string{ return $this->session->getIp(); } public function getPort() : int{ return $this->session->getPort(); } /** * Returns the base class that the final player class must extend. * * @return string * @phpstan-return class-string */ public function getBaseClass(){ return $this->baseClass; } /** * Sets the class that the final player class must extend. * The new base class must be a subclass of the current base class. * This can (perhaps) be used to limit the options for custom player classes provided by other plugins. * * @param string $class * @phpstan-param class-string $class */ public function setBaseClass($class) : void{ if(!is_a($class, $this->baseClass, true)){ throw new \RuntimeException("Base class $class must extend " . $this->baseClass); } $this->baseClass = $class; } /** * Returns the class that will be instantiated to create the player after the event. * * @return string * @phpstan-return class-string */ public function getPlayerClass(){ return $this->playerClass; } /** * Sets the class that will be instantiated to create the player after the event. The class must not be abstract, * and must be an instance of the base class. * * @param string $class * @phpstan-param class-string $class */ public function setPlayerClass($class) : void{ Utils::testValidInstance($class, $this->baseClass); $this->playerClass = $class; } }