PocketMine-MP/src/pocketmine/network/mcpe/protocol/ResourcePackDataInfoPacket.php
2019-06-18 16:02:46 +01:00

76 lines
2.1 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\handler\PacketHandler;
class ResourcePackDataInfoPacket extends DataPacket implements ClientboundPacket{
public const NETWORK_ID = ProtocolInfo::RESOURCE_PACK_DATA_INFO_PACKET;
/** @var string */
public $packId;
/** @var int */
public $maxChunkSize;
/** @var int */
public $chunkCount;
/** @var int */
public $compressedPackSize;
/** @var string */
public $sha256;
public static function create(string $packId, int $maxChunkSize, int $chunkCount, int $compressedPackSize, string $sha256sum) : self{
$result = new self;
$result->packId = $packId;
$result->maxChunkSize = $maxChunkSize;
$result->chunkCount = $chunkCount;
$result->compressedPackSize = $compressedPackSize;
$result->sha256 = $sha256sum;
return $result;
}
protected function decodePayload() : void{
$this->packId = $this->getString();
$this->maxChunkSize = $this->getLInt();
$this->chunkCount = $this->getLInt();
$this->compressedPackSize = $this->getLLong();
$this->sha256 = $this->getString();
}
protected function encodePayload() : void{
$this->putString($this->packId);
$this->putLInt($this->maxChunkSize);
$this->putLInt($this->chunkCount);
$this->putLLong($this->compressedPackSize);
$this->putString($this->sha256);
}
public function handle(PacketHandler $handler) : bool{
return $handler->handleResourcePackDataInfo($this);
}
}