PocketMine-MP 5.35.1 git-e32e836dad793a3a3c8ddd8927c00e112b1e576a
Loading...
Searching...
No Matches
ResourcePackInfoEntry.php
1<?php
2
3/*
4 * This file is part of BedrockProtocol.
5 * Copyright (C) 2014-2022 PocketMine Team <https://github.com/pmmp/BedrockProtocol>
6 *
7 * BedrockProtocol is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 */
12
13declare(strict_types=1);
14
15namespace pocketmine\network\mcpe\protocol\types\resourcepacks;
16
17use pmmp\encoding\ByteBufferReader;
18use pmmp\encoding\ByteBufferWriter;
19use pmmp\encoding\LE;
21use Ramsey\Uuid\UuidInterface;
22
24 public function __construct(
25 private UuidInterface $packId,
26 private string $version,
27 private int $sizeBytes,
28 private string $encryptionKey = "",
29 private string $subPackName = "",
30 private string $contentId = "",
31 private bool $hasScripts = false,
32 private bool $isAddonPack = false,
33 private bool $isRtxCapable = false,
34 private string $cdnUrl = ""
35 ){}
36
37 public function getPackId() : UuidInterface{
38 return $this->packId;
39 }
40
41 public function getVersion() : string{
42 return $this->version;
43 }
44
45 public function getSizeBytes() : int{
46 return $this->sizeBytes;
47 }
48
49 public function getEncryptionKey() : string{
50 return $this->encryptionKey;
51 }
52
53 public function getSubPackName() : string{
54 return $this->subPackName;
55 }
56
57 public function getContentId() : string{
58 return $this->contentId;
59 }
60
61 public function hasScripts() : bool{
62 return $this->hasScripts;
63 }
64
65 public function isAddonPack() : bool{ return $this->isAddonPack; }
66
67 public function isRtxCapable() : bool{ return $this->isRtxCapable; }
68
69 public function getCdnUrl() : string{ return $this->cdnUrl; }
70
71 public function write(ByteBufferWriter $out) : void{
72 CommonTypes::putUUID($out, $this->packId);
73 CommonTypes::putString($out, $this->version);
74 LE::writeUnsignedLong($out, $this->sizeBytes);
75 CommonTypes::putString($out, $this->encryptionKey);
76 CommonTypes::putString($out, $this->subPackName);
77 CommonTypes::putString($out, $this->contentId);
78 CommonTypes::putBool($out, $this->hasScripts);
79 CommonTypes::putBool($out, $this->isAddonPack);
80 CommonTypes::putBool($out, $this->isRtxCapable);
81 CommonTypes::putString($out, $this->cdnUrl);
82 }
83
84 public static function read(ByteBufferReader $in) : self{
85 $uuid = CommonTypes::getUUID($in);
86 $version = CommonTypes::getString($in);
87 $sizeBytes = LE::readUnsignedLong($in);
88 $encryptionKey = CommonTypes::getString($in);
89 $subPackName = CommonTypes::getString($in);
90 $contentId = CommonTypes::getString($in);
91 $hasScripts = CommonTypes::getBool($in);
92 $isAddonPack = CommonTypes::getBool($in);
93 $rtxCapable = CommonTypes::getBool($in);
94 $cdnUrl = CommonTypes::getString($in);
95 return new self($uuid, $version, $sizeBytes, $encryptionKey, $subPackName, $contentId, $hasScripts, $isAddonPack, $rtxCapable, $cdnUrl);
96 }
97}