From 3e141afe4881357b76fbe9f873914b9408994f9a Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sat, 29 Jul 2017 14:27:16 +0100 Subject: [PATCH] Exposed LoginPacket chain data to allow plugins to access this data --- src/pocketmine/network/mcpe/protocol/LoginPacket.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/pocketmine/network/mcpe/protocol/LoginPacket.php b/src/pocketmine/network/mcpe/protocol/LoginPacket.php index dc5f2a38c..a92858edb 100644 --- a/src/pocketmine/network/mcpe/protocol/LoginPacket.php +++ b/src/pocketmine/network/mcpe/protocol/LoginPacket.php @@ -44,6 +44,11 @@ class LoginPacket extends DataPacket{ public $skinId; public $skin = ""; + /** @var array (the "chain" index contains one or more JWTs) */ + public $chainData = []; + /** @var string */ + public $clientDataJwt; + /** @var array decoded payload of the clientData JWT */ public $clientData = []; public function canBeSentBeforeLogin() : bool{ @@ -62,8 +67,8 @@ class LoginPacket extends DataPacket{ $this->setBuffer($this->getString(), 0); - $chainData = json_decode($this->get($this->getLInt())); - foreach($chainData->{"chain"} as $chain){ + $this->chainData = json_decode($this->get($this->getLInt()), true); + foreach($this->chainData["chain"] as $chain){ $webtoken = $this->decodeToken($chain); if(isset($webtoken["extraData"])){ if(isset($webtoken["extraData"]["displayName"])){ @@ -78,7 +83,8 @@ class LoginPacket extends DataPacket{ } } - $this->clientData = $this->decodeToken($this->get($this->getLInt())); + $this->clientDataJwt = $this->get($this->getLInt()); + $this->clientData = $this->decodeToken($this->clientDataJwt); $this->clientId = $this->clientData["ClientRandomId"] ?? null; $this->serverAddress = $this->clientData["ServerAddress"] ?? null;