mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-07 02:08:21 +00:00
SkinAdapter::fromSkinData() may now throw InvalidSkinException
fixes a rogue TODO in LegacySkinAdapter and invalid skins maybe showing up as Steve instead of getting kicked off the server
This commit is contained in:
@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol\types;
|
||||
|
||||
use pocketmine\entity\InvalidSkinException;
|
||||
use pocketmine\entity\Skin;
|
||||
|
||||
use function is_string;
|
||||
@ -56,12 +57,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());
|
||||
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol\types;
|
||||
|
||||
use pocketmine\entity\InvalidSkinException;
|
||||
use pocketmine\entity\Skin;
|
||||
|
||||
/**
|
||||
@ -37,6 +38,7 @@ interface SkinAdapter{
|
||||
|
||||
/**
|
||||
* Allows you to convert skin data to a skin entity.
|
||||
* @throws InvalidSkinException
|
||||
*/
|
||||
public function fromSkinData(SkinData $data) : Skin;
|
||||
}
|
||||
|
Reference in New Issue
Block a user