Skip to content

Latest commit

 

History

History
178 lines (131 loc) · 3.37 KB

File metadata and controls

178 lines (131 loc) · 3.37 KB

EasyLibrary Module Examples

This directory contains complete PocketMine-MP plugins that demonstrate the EasyLibrary 2.0 module system.

Running the Examples

  1. Copy an example plugin directory into the server's plugins/ directory.
  2. Install and enable EasyLibrary 2.0.
  3. Start the server.
  4. Inspect the modules with:
/easymodule list
/easymodule doctor
/easymodule services
/easymodule capabilities
/easymodule graph

Included Examples

01-basic-plugin

Demonstrates:

  • easylibrary-modules in plugin.yml.
  • A complete module.yml.
  • BaseModule and ModuleContext.
  • Module-scoped logging, configuration, and storage.
  • A tracked command, listener, repeating task, and cleanup callback.
  • A shared service and public module API.
  • A module health check.

Commands:

/examplehello
/examplehello api
/examplehello service
/examplehello config

02-economy-provider-plugin

Provides a small in-memory economy implementation.

Demonstrates:

  • Shared service registration.
  • A typed service contract.
  • A public module API.
  • The economy capability.
  • Cross-plugin service consumption.

Commands:

/exampleeco balance
/exampleeco give <player> <amount>
/exampleeco take <player> <amount>

03-farm-consumer-plugin

Consumes the economy service and capability from 02-economy-provider-plugin.

Demonstrates:

  • Required service dependencies.
  • Required capability dependencies.
  • Optional module dependencies.
  • Cross-plugin provider resolution.

Commands:

/examplefarm
/examplefarm harvest
/examplefarm provider

Run this example together with 02-economy-provider-plugin.

04-diagnostics-plugin

Provides controlled success and failure cases for diagnostics.

It includes:

  • A healthy module.
  • A module with a missing module dependency.
  • A module with a missing service dependency.
  • A module disabled by its manifest.

Use it to test:

/easymodule doctor
/easymodule why <id>
/easymodule failures

Reference plugin.yml

name: EasyModuleBasicExample
main: easylibraryexamples\basic\BasicExamplePlugin
version: 1.0.0
api: 5.0.0
src-namespace-prefix: easylibraryexamples\basic

depend:
  - EasyLibrary

easylibrary-modules:
  - path: modules
    namespace: easylibraryexamples\basic\modules

Reference module.yml

id: examples:hello
name: Hello Module Example
version: 1.0.0
loader: HelloModule
namespace: easylibraryexamples\basic\modules\hello
load: POSTWORLD
enabled: true

provides:
  services:
    - examples:hello-service
  capabilities:
    - examples.hello

requires:
  services: []
  capabilities: []

dependencies: []
soft-dependencies: []
plugin-dependencies: []

Recommended Test Sequence

  1. Run 01-basic-plugin.
  2. Run 02-economy-provider-plugin and 03-farm-consumer-plugin together.
  3. Add 04-diagnostics-plugin to test controlled failures.

Useful checks:

/easymodule info examples:hello
/easymodule resources examples:hello
/easymodule health examples:hello
/easymodule reload examples:hello
/easymodule disable-runtime examples:hello
/easymodule enable examples:hello

Persistent disable test:

/easymodule disable examples:hello

Restart the server, verify that the module remains disabled, and then run:

/easymodule enable examples:hello

Module reload recreates the instance and runtime resources. It does not unload already loaded PHP classes.