PocketMine-MP/src/network/mcpe/protocol/PlayerSkinPacket.php
2021-03-16 23:03:00 +00:00

71 lines
2.0 KiB
PHP

<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
use pocketmine\network\mcpe\protocol\types\skin\SkinData;
use Ramsey\Uuid\UuidInterface;
class PlayerSkinPacket extends DataPacket implements ClientboundPacket, ServerboundPacket{
public const NETWORK_ID = ProtocolInfo::PLAYER_SKIN_PACKET;
/** @var UuidInterface */
public $uuid;
/** @var string */
public $oldSkinName = "";
/** @var string */
public $newSkinName = "";
/** @var SkinData */
public $skin;
public static function create(UuidInterface $uuid, SkinData $skinData) : self{
$result = new self;
$result->uuid = $uuid;
$result->skin = $skinData;
return $result;
}
protected function decodePayload(PacketSerializer $in) : void{
$this->uuid = $in->getUUID();
$this->skin = $in->getSkin();
$this->newSkinName = $in->getString();
$this->oldSkinName = $in->getString();
$this->skin->setVerified($in->getBool());
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putUUID($this->uuid);
$out->putSkin($this->skin);
$out->putString($this->newSkinName);
$out->putString($this->oldSkinName);
$out->putBool($this->skin->isVerified());
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handlePlayerSkin($this);
}
}