Merge branch 'stable'

# Conflicts:
#	resources/vanilla
#	src/pocketmine/Player.php
This commit is contained in:
Dylan K. Taylor 2020-06-17 22:23:17 +01:00
commit e6a3f7baa2
3 changed files with 6 additions and 3 deletions

View File

@ -23,6 +23,7 @@ declare(strict_types=1);
namespace pocketmine\network\mcpe\convert;
use pocketmine\entity\InvalidSkinException;
use pocketmine\entity\Skin;
use pocketmine\network\mcpe\protocol\types\SkinData;
@ -58,12 +59,11 @@ class LegacySkinAdapter implements SkinAdapter{
$capeData = $data->isPersonaCapeOnClassic() ? "" : $data->getCapeImage()->getData();
$geometryName = "";
$resourcePatch = json_decode($data->getResourcePatch(), true);
if(isset($resourcePatch["geometry"]["default"]) && is_string($resourcePatch["geometry"]["default"])){
$geometryName = $resourcePatch["geometry"]["default"];
}else{
//TODO: Kick for invalid skin
throw new InvalidSkinException("Missing geometry name field");
}
return new Skin($data->getSkinId(), $data->getSkinImage()->getData(), $capeData, $geometryName, $data->getGeometryData());

View File

@ -23,6 +23,7 @@ declare(strict_types=1);
namespace pocketmine\network\mcpe\convert;
use pocketmine\entity\InvalidSkinException;
use pocketmine\entity\Skin;
use pocketmine\network\mcpe\protocol\types\SkinData;
@ -38,6 +39,7 @@ interface SkinAdapter{
/**
* Allows you to convert skin data to a skin entity.
* @throws InvalidSkinException
*/
public function fromSkinData(SkinData $data) : Skin;
}

View File

@ -24,6 +24,7 @@ declare(strict_types=1);
namespace pocketmine\network\mcpe\handler;
use Mdanter\Ecc\Crypto\Key\PublicKeyInterface;
use pocketmine\entity\InvalidSkinException;
use pocketmine\event\player\PlayerPreLoginEvent;
use pocketmine\network\BadPacketException;
use pocketmine\network\mcpe\auth\ProcessLoginTask;
@ -112,7 +113,7 @@ class LoginPacketHandler extends PacketHandler{
$clientData = $this->parseClientData($packet->clientDataJwt);
try{
$skin = SkinAdapterSingleton::get()->fromSkinData(ClientDataToSkinDataHelper::getInstance()->fromClientData($clientData));
}catch(\InvalidArgumentException $e){
}catch(\InvalidArgumentException | InvalidSkinException $e){
$this->session->getLogger()->debug("Invalid skin: " . $e->getMessage());
$this->session->disconnect("disconnectionScreen.invalidSkin");