InGamePacketHandler: do not process repeated skin change requests for the same full skin ID

this fixes a feedback loop with persona skins in 1.19.60.
This commit is contained in:
Dylan K. Taylor 2023-02-08 20:16:41 +00:00
parent 40b90bb722
commit 475888b031
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -149,6 +149,8 @@ class InGamePacketHandler extends PacketHandler{
/** @var bool */
public $forceMoveSync = false;
protected ?string $lastRequestedFullSkinId = null;
public function __construct(
private Player $player,
private NetworkSession $session,
@ -745,6 +747,14 @@ class InGamePacketHandler extends PacketHandler{
}
public function handlePlayerSkin(PlayerSkinPacket $packet) : bool{
if($packet->skin->getFullSkinId() === $this->lastRequestedFullSkinId){
//TODO: HACK! In 1.19.60, the client sends its skin back to us if we sent it a skin different from the one
//it's using. We need to prevent this from causing a feedback loop.
$this->session->getLogger()->debug("Refused duplicate skin change request");
return true;
}
$this->lastRequestedFullSkinId = $packet->skin->getFullSkinId();
$this->session->getLogger()->debug("Processing skin change request");
try{
$skin = SkinAdapterSingleton::get()->fromSkinData($packet->skin);