diff --git a/src/pocketmine/resourcepacks/ResourcePack.php b/src/pocketmine/resourcepacks/ResourcePack.php index fd7962896..d4eeeb0e6 100644 --- a/src/pocketmine/resourcepacks/ResourcePack.php +++ b/src/pocketmine/resourcepacks/ResourcePack.php @@ -25,15 +25,46 @@ namespace pocketmine\resourcepacks; interface ResourcePack{ + /** + * Returns the human-readable name of the resource pack + * @return string + */ public function getPackName() : string; + /** + * Returns the pack's UUID as a human-readable string + * @return string + */ public function getPackId() : string; + /** + * Returns the size of the pack on disk in bytes. + * @return int + */ public function getPackSize() : int; + /** + * Returns a version number for the pack in the format major.minor.patch + * @return string + */ public function getPackVersion() : string; + /** + * Returns the raw SHA256 sum of the compressed resource pack zip. This is used by clients to validate pack downloads. + * @return string byte-array length 32 bytes + */ public function getSha256() : string; + /** + * Returns a chunk of the resource pack zip as a byte-array for sending to clients. + * + * Note that resource packs must **always** be in zip archive format for sending. + * A folder resource loader may need to perform on-the-fly compression for this purpose. + * + * @param int $start Offset to start reading the chunk from + * @param int $length Maximum length of data to return. + * + * @return string byte-array + */ public function getPackChunk(int $start, int $length) : string; } \ No newline at end of file diff --git a/src/pocketmine/resourcepacks/ResourcePackManager.php b/src/pocketmine/resourcepacks/ResourcePackManager.php index ed47ecb57..125c31ce0 100644 --- a/src/pocketmine/resourcepacks/ResourcePackManager.php +++ b/src/pocketmine/resourcepacks/ResourcePackManager.php @@ -46,6 +46,10 @@ class ResourcePackManager{ /** @var ResourcePack[] */ private $uuidList = []; + /** + * @param Server $server + * @param string $path Path to resource-packs directory. + */ public function __construct(Server $server, string $path){ $this->server = $server; $this->path = $path; @@ -103,6 +107,7 @@ class ResourcePackManager{ } /** + * Returns whether players must accept resource packs in order to join. * @return bool */ public function resourcePacksRequired() : bool{ @@ -110,6 +115,7 @@ class ResourcePackManager{ } /** + * Returns an array of resource packs in use, sorted in order of priority. * @return ResourcePack[] */ public function getResourceStack() : array{ @@ -117,8 +123,9 @@ class ResourcePackManager{ } /** - * @param string $id + * Returns the resource pack matching the specified UUID string, or null if the ID was not recognized. * + * @param string $id * @return ResourcePack|null */ public function getPackById(string $id){ @@ -126,6 +133,7 @@ class ResourcePackManager{ } /** + * Returns an array of pack IDs for packs currently in use. * @return string[] */ public function getPackIdList() : array{ diff --git a/src/pocketmine/resourcepacks/ZippedResourcePack.php b/src/pocketmine/resourcepacks/ZippedResourcePack.php index f65506bbe..1f49bd8c9 100644 --- a/src/pocketmine/resourcepacks/ZippedResourcePack.php +++ b/src/pocketmine/resourcepacks/ZippedResourcePack.php @@ -25,13 +25,19 @@ namespace pocketmine\resourcepacks; class ZippedResourcePack implements ResourcePack{ + /** + * Performs basic validation checks on a resource pack's manifest.json. + * TODO: add more manifest validation + * + * @param \stdClass $manifest + * @return bool + */ public static function verifyManifest(\stdClass $manifest){ if(!isset($manifest->format_version) or !isset($manifest->header) or !isset($manifest->modules)){ return false; } //Right now we don't care about anything else, only the stuff we're sending to clients. - //TODO: add more manifest validation return isset($manifest->header->description) and isset($manifest->header->name) and @@ -52,7 +58,9 @@ class ZippedResourcePack implements ResourcePack{ /** @var resource */ protected $fileResource; - + /** + * @param string $zipPath Path to the resource pack zip + */ public function __construct(string $zipPath){ $this->path = $zipPath;