◆ __construct()
__construct |
( |
string |
$zipPath | ) |
|
ZippedResourcePack constructor.
- Parameters
-
76 $this->path = $zipPath;
78 if(!file_exists($zipPath)){
79 throw new \InvalidArgumentException(
"无法打开材质包 $zipPath: 文件夹无法打开");
82 $archive = new \ZipArchive();
83 if(($openResult = $archive->open($zipPath)) !==
true){
84 throw new \InvalidStateException(
"打开 $zipPath $openResult");
87 if(($manifestData = $archive->getFromName(
"manifest.json")) ===
false){
88 if(($manifestData = $archive->getFromName(
"pack_manifest.json")) ===
false){
89 throw new \InvalidStateException(
"无法加载材质包 $zipPath: 找不到主类");
97 throw new \InvalidStateException(
"无法加载材质包 $zipPath: 主类错误或不完整");
102 $this->fileResource = fopen($zipPath,
"rb");
◆ getPackChunk()
getPackChunk |
( |
int |
$start, |
|
|
int |
$length |
|
) |
| |
- Parameters
-
- Returns
- string
Implements ResourcePack.
152 fseek($this->fileResource, $start);
153 if(feof($this->fileResource)){
154 throw new \RuntimeException(
"Requested a resource pack chunk with invalid start offset");
156 return fread($this->fileResource, $length);
◆ getPackId()
- Returns
- string
Implements ResourcePack.
123 return $this->manifest->header->uuid;
◆ getPackName()
- Returns
- string
Implements ResourcePack.
109 return $this->manifest->header->name;
◆ getPackSize()
- Returns
- int
Implements ResourcePack.
130 return filesize($this->path);
◆ getPackVersion()
- Returns
- string
Implements ResourcePack.
116 return implode(
".", $this->manifest->header->version);
◆ getSha256()
getSha256 |
( |
bool |
$cached = true | ) |
|
- Parameters
-
- Returns
- string
139 if($this->sha256 === null or !$cached){
140 $this->sha256 = hash_file(
"sha256", $this->path,
true);
◆ verifyManifest()
static verifyManifest |
( |
\stdClass |
$manifest | ) |
|
|
static |
◆ $fileResource
◆ $manifest
◆ $path
◆ $sha256
The documentation for this class was generated from the following file:
- src/pocketmine/resourcepacks/ZippedResourcePack.php