Separated XUID stuff from PlayerInfo into its own XboxLivePlayerInfo

This commit is contained in:
Dylan K. Taylor
2020-11-10 14:25:08 +00:00
parent c43f14a2d2
commit 6a266bcbd1
5 changed files with 83 additions and 38 deletions

View File

@@ -97,6 +97,7 @@ use pocketmine\network\NetworkSessionManager;
use pocketmine\player\GameMode;
use pocketmine\player\Player;
use pocketmine\player\PlayerInfo;
use pocketmine\player\XboxLivePlayerInfo;
use pocketmine\Server;
use pocketmine\timings\Timings;
use pocketmine\utils\TextFormat;
@@ -563,7 +564,7 @@ class NetworkSession{
return;
}
if($error === null){
if($authenticated and $this->info->getXuid() === ""){
if($authenticated and !($this->info instanceof XboxLivePlayerInfo)){
$error = "Expected XUID but none found";
}elseif($clientPubKey === null){
$error = "Missing client public key"; //failsafe
@@ -583,7 +584,7 @@ class NetworkSession{
$this->disconnect("disconnectionScreen.notAuthenticated");
return;
}
if($this->info->hasXboxData()){
if($this->info instanceof XboxLivePlayerInfo){
$this->logger->warning("Discarding unexpected XUID for non-authenticated player");
$this->info = $this->info->withoutXboxData();
}

View File

@@ -41,6 +41,7 @@ use pocketmine\network\mcpe\protocol\types\login\ClientDataToSkinDataHelper;
use pocketmine\network\mcpe\protocol\types\login\JwtChain;
use pocketmine\player\Player;
use pocketmine\player\PlayerInfo;
use pocketmine\player\XboxLivePlayerInfo;
use pocketmine\Server;
use pocketmine\uuid\UUID;
use function is_array;
@@ -116,14 +117,24 @@ class LoginPacketHandler extends PacketHandler{
}catch(\InvalidArgumentException $e){
throw BadPacketException::wrap($e, "Failed to parse login UUID");
}
$playerInfo = new PlayerInfo(
$extraData->displayName,
$uuid,
$skin,
$clientData->LanguageCode,
$extraData->XUID,
(array) $clientData
);
if($extraData->XUID !== ""){
$playerInfo = new XboxLivePlayerInfo(
$extraData->XUID,
$extraData->displayName,
$uuid,
$skin,
$clientData->LanguageCode,
(array) $clientData
);
}else{
$playerInfo = new PlayerInfo(
$extraData->displayName,
$uuid,
$skin,
$clientData->LanguageCode,
(array) $clientData
);
}
($this->playerInfoConsumer)($playerInfo);
$ev = new PlayerPreLoginEvent(