mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-05 09:26:06 +00:00
Added static create() functions for many packets
There are a few motivations here: 1) Less boilerplate code (this can be written inline) 2) It's possible to provide multiple constructors for different packet variations to reduce the chance of errors. 3) It makes things catch fire on updates in ways that static analysers can understand.
This commit is contained in:
@ -43,6 +43,16 @@ class ResourcePackDataInfoPacket extends DataPacket implements ClientboundPacket
|
||||
/** @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();
|
||||
|
Reference in New Issue
Block a user