use pocketmine\network\mcpe\handler\SessionHandler; class DisconnectPacket extends DataPacket implements ClientboundPacket, ServerboundPacket{ public const NETWORK_ID = ProtocolInfo::DISCONNECT_PACKET; /** @var bool */ public $hideDisconnectionScreen = false; /** @var string */ public $message = ""; public function canBeSentBeforeLogin() : bool{ return true; } protected function decodePayload() : void{ $this->hideDisconnectionScreen = $this->getBool(); if(!$this->hideDisconnectionScreen){ $this->message = $this->getString(); } } protected function encodePayload() : void{ $this->putBool($this->hideDisconnectionScreen); if(!$this->hideDisconnectionScreen){ $this->putString($this->message); } } public function handle(SessionHandler $handler) : bool{ return $handler->handleDisconnect($this); } }