A simple add-ons manager (resource pack and behavior pack at once) for axolotl-pm/PocketMine-MP.
- What it does
- Loads every add-on in the
addons/folder of your server (a folder with amanifest.json, a.zipor 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.
- Loads every add-on in the
- Details
manifest.jsonfiles 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.
- Server
- axolotl-pm/PocketMine-MP
5.51or higher (plugin.ymlapi: [5.51.0]), which uses BedrockProtocol 64 (Bedrock1.26.60). - PHP
8.4or higher withext-zip.
- axolotl-pm/PocketMine-MP
- Installation
- Download the
AddonsManagerphar from GitHub Releases and place it into your server'spluginsdirectory. - Put your add-ons into the
addons/folder in the server's root directory (created on first start), then restart or run/addons reload.
- Download the
- Old versions
- The version for PocketMine-MP API 4 is kept on the
legacy/pmmp-5.44branch.
- The version for PocketMine-MP API 4 is kept on the
- Development
composer installthencomposer testruns the PHPUnit tests.
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.
| 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 formsl,r,mandhwork 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 reloadonly replaces the add-ons loaded from theaddons/folder; add-ons registered by plugins are kept. Players that are already connected need to rejoin to receive the changes, so every online player withaddonsmanager.commandgets a title and an action bar notice about it.- With the bundled resource pack (
resources/pack, sent to every player, not required)/addons listis 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 vanillalong_forminstead of redefining it, so other form packs keep working and a client without the pack sees an ordinary button list. /addons managelists the add-ons of theaddons/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 inplugin_data/AddonsManager/disabled.json, so it survives/addons reloadand a restart. Add-ons registered by plugins are not listed. The form is amultiselectrow of the Bedrock client1.26.50or later; a row where nothing is checked comes back asnull, 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 reloadand/addons manageis 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. Settoast: falseinconfig.ymlto 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).
Distributed under the LGPL 3.0 License. See LICENSE for more information.