Skip to content

LibAssets

ImperaZim edited this page Jun 30, 2026 · 4 revisions

LibAssets

LibAssets is the official EasyLibrary asset helper library.

Repository:

https://github.com/ImperaZim/LibAssets

Package id:

libassets

Namespace:

imperazim\assets

What It Provides

  • Asset manifests with relative paths, byte size and SHA-256 hashes.
  • Manifest-vs-disk validation for missing, changed and extra files.
  • Bedrock resource-pack manifest.json parsing and validation.
  • Resource-pack directory and ZIP validation.
  • Resource-pack ZIP building when the PHP runtime supports ZipArchive or writable PharData.
  • Controlled resource-pack workflow with registered pack definitions, active, prepared, pending, disabled and invalid status checks.
  • Plugin-owned staging folders for prepared/, dist/, manifests/ and cache/.
  • Optional downloader adapter contract for LibHttp or plugin-owned transport code.

LibAssets does not own HTTP transport. Use LibHttp for request/retry/body handling, then let LibAssets validate checksums, cache paths and Bedrock resource-pack archives.

Dependencies

LibAssets depends on LibCommons for shared pure helpers:

  • SHA-256 hashing;
  • JSON encode/decode;
  • path normalization;
  • small filesystem directory/write helpers.

Standalone installs need both PHARs in plugins/:

LibCommons-1.0.0-dev.phar
LibAssets-1.0.0-dev.phar

EasyLibrary package installs declare this as:

dependencies:
  required:
    - libcommons

This dependency does not pull in HTTP, commands, forms, HUD, world editing or other runtime systems.

Resource-Pack Workflow

use imperazim\assets\resource\ResourcePackDefinition;
use imperazim\assets\resource\ResourcePackWorkflow;
use imperazim\assets\resource\ResourcePackWorkflowStatus;

$workflow = new ResourcePackWorkflow($plugin->getDataFolder() . 'resource-packs');
$workflow->register(new ResourcePackDefinition('lobby', $sourceDirectory, 'lobby-pack.zip'));

if ($workflow->inspect('lobby')->getStatus() === ResourcePackWorkflowStatus::PENDING) {
    $workflow->prepare('lobby');
}

The workflow is intentionally explicit: it prepares and validates files, but the plugin still decides how to expose or register the resulting pack.

For CDN-backed packs, use ResourcePackDefinition::fromCdn() to derive the remote archive URL from a base URL plus the controlled archive name.

Install As Package

/easylibrary packages install libcommons development confirm
/easylibrary packages install libassets development confirm

Restart and validate:

/easylibrary packages doctor
/elprobe libassets
/elprobe run libassets

Expected package-backed source:

libassets / LibAssets: class=yes plugin=package-backed-plugin source=package-backed-plugin
libassets / LibAssets: functional=yes source=package-backed-plugin test=assets-workflow-resource-pack

Clone this wiki locally