Skip to content

About

A simple add-ons manager (resource pack and behavior pack at once)

Topics

Resources

Stars

15 stars

Watchers

1 watching

Forks

Repository files navigation

Version Stars License


AddonsManager

A simple add-ons manager (resource pack and behavior pack at once) for axolotl-pm/PocketMine-MP.

Report a bug · Request a feature

Overview

  • What it does
    • Loads every add-on in the addons/ folder of your server (a folder with a manifest.json, a .zip or a .mcpack) and sends it to the players that join: resource packs and behavior packs.
    • Turns on the experimental toggles that add-ons usually need (scripting, gametest, data_driven_items, upcoming_creator_features, experimental_molang_features).
    • Exposes an API for other plugins to register their own add-ons.
  • Details
    • manifest.json files may contain comments and trailing commas.
    • A missing pack UUID (all zeros) is generated from the contents of the pack.
    • An add-on that fails to load is logged and skipped instead of stopping the plugin.
    • Resource packs are added to the server's resource pack stack (after the packs of resource_packs/), so the server sends them like its own. Behavior packs and the experiments are sent with presentkim/resourcepack-register, which lists them next to what other plugins added instead of replacing it. Everything is removed again when the plugin is disabled.
    • An add-on whose UUID is already used by a resource pack of the server is logged and skipped.

Installation & Requirements

  • Server
    • axolotl-pm/PocketMine-MP 5.51 or higher (plugin.yml api: [5.51.0]), which uses BedrockProtocol 64 (Bedrock 1.26.60).
    • PHP 8.4 or higher with ext-zip.
  • Installation
    • Download the AddonsManager phar from GitHub Releases and place it into your server's plugins directory.
    • Put your add-ons into the addons/ folder in the server's root directory (created on first start), then restart or run /addons reload.
  • Old versions
  • Development
    • composer install then composer test runs the PHPUnit tests.

Usage for plugins

use pocketmine\network\mcpe\protocol\types\resourcepacks\ResourcePackType;
use ref\api\addonsmanager\addons\FolderAddons;
use ref\api\addonsmanager\addons\PluginAddons;
use ref\api\addonsmanager\AddonsManager;
use ref\api\addonsmanager\builder\SimpleAddonsBuilder;

$manager = AddonsManager::getInstance();

// A folder, or a pack inside your plugin's resources/
$manager->register(new FolderAddons("/path/to/pack"));
$manager->register(new PluginAddons($this, "pack"));

// Built by code
$manager->register(
    (new SimpleAddonsBuilder(ResourcePackType::RESOURCES, "My pack", "A pack made by code"))
        ->json("textures/item_texture.json", [...])
        ->build()
);

Register before the players join. Add depend: [ AddonsManager ] to your plugin.yml. Add-ons registered in onLoad() are sent once AddonsManager is enabled. register() throws InvalidArgumentException when the server already has a resource pack with the same UUID.


Commands & Permissions

Command Description Permission
/addons list Lists the loaded add-ons. A player gets a form (select an add-on for its details), the console gets text addonsmanager.command.list
/addons reload Loads the addons/ folder again without restarting the server addonsmanager.command.reload
/addons manage Opens a form with a checkbox list (multiselect) to turn several add-ons of the addons/ folder on or off at once operators (addonsmanager.command)
/addons help Lists the subcommands you can use, with their usage and description operators (addonsmanager.command)
  • addonsmanager.command (operators by default) includes both. The command is autocompleted in the clients (presentkim/libcommand); the short forms l, r, m and h work too (libcommand 3.2).
  • The form shows each add-on's name, version and source (the addons/ folder or a plugin). Its details page shows the UUID, type (resource or behavior), version, size, source and dependencies, and a button lists the files that failed to load with the reason.
  • /addons reload only replaces the add-ons loaded from the addons/ folder; add-ons registered by plugins are kept. Players that are already connected need to rejoin to receive the changes, so every online player with addonsmanager.command gets a title and an action bar notice about it.
  • With the bundled resource pack (resources/pack, sent to every player, not required) /addons list is drawn as a grid of cards with an icon for the type of each add-on (resource, behavior, behavior with scripts, failed to load). The title of the form starts with an invisible marker (formatting codes only) and the pack wraps the vanilla long_form instead of redefining it, so other form packs keep working and a client without the pack sees an ordinary button list.
  • /addons manage lists the add-ons of the addons/ folder as checkboxes (checked = sent). An add-on that is off stays loaded but is not sent to the players that join from now on; the state is kept in plugin_data/AddonsManager/disabled.json, so it survives /addons reload and a restart. Add-ons registered by plugins are not listed. The form is a multiselect row of the Bedrock client 1.26.50 or later; a row where nothing is checked comes back as null, which is handled. Players that are already connected need to rejoin, like after a reload.
  • The first time a player opens the list, the action bar mentions /addons manage (once per player, with play-sound-utils 4.2). Every plugin that uses play-sound-utils registers /feedbacksound [on|off|volume <0~1>] so that a player can turn the sounds off.
  • The result of /addons reload and /addons manage is shown as a toast in the top right corner of the screen (presentkim/toast-utils), also to the other players with the command permission (instead of the title and the action bar). Without the toast pack that the server requires (force_resources: true) it is the action bar. Set toast: false in config.yml to keep the chat messages, the title and the action bar. Errors stay in the chat.
  • Messages are translated per player (resources/locale/eng.ini, kor.ini, presentkim/libmultilingual).

License

Distributed under the LGPL 3.0 License. See LICENSE for more information.

About

A simple add-ons manager (resource pack and behavior pack at once)

Topics

Resources

Stars

15 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages