From 6f4d4be3dac85223813a84de4759bf367329ea2a Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Wed, 17 Jun 2020 22:31:44 +0100 Subject: [PATCH] InGamePacketHandler: handle InvalidSkinException thrown by SkinAdapter::fromSkinData() --- src/network/mcpe/handler/InGamePacketHandler.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/network/mcpe/handler/InGamePacketHandler.php b/src/network/mcpe/handler/InGamePacketHandler.php index 0514c6e90..3f46d8792 100644 --- a/src/network/mcpe/handler/InGamePacketHandler.php +++ b/src/network/mcpe/handler/InGamePacketHandler.php @@ -27,6 +27,7 @@ use pocketmine\block\ItemFrame; use pocketmine\block\Sign; use pocketmine\block\utils\SignText; use pocketmine\entity\animation\ConsumingItemAnimation; +use pocketmine\entity\InvalidSkinException; use pocketmine\event\player\PlayerEditBookEvent; use pocketmine\inventory\transaction\action\InventoryAction; use pocketmine\inventory\transaction\CraftingTransaction; @@ -634,7 +635,12 @@ class InGamePacketHandler extends PacketHandler{ } public function handlePlayerSkin(PlayerSkinPacket $packet) : bool{ - return $this->player->changeSkin(SkinAdapterSingleton::get()->fromSkinData($packet->skin), $packet->newSkinName, $packet->oldSkinName); + try{ + $skin = SkinAdapterSingleton::get()->fromSkinData($packet->skin); + }catch(InvalidSkinException $e){ + throw BadPacketException::wrap($e, "Invalid skin in PlayerSkinPacket"); + } + return $this->player->changeSkin($skin, $packet->newSkinName, $packet->oldSkinName); } public function handleSubClientLogin(SubClientLoginPacket $packet) : bool{