Exposed LoginPacket chain data to allow plugins to access this data

This commit is contained in:
Dylan K. Taylor 2017-07-29 14:27:16 +01:00
parent aa6eef26e9
commit 3e141afe48

View File

@ -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;