API
EmakiForge exposes a static facade EmakiForgeApi that provides version, plugin name, and readiness probes. The full forging flow (execution, quality calculation, material resolution) still runs through recipes, GUI, commands, and actions. To hook into forging results, listen to the Event API or register JavaScript forge rules.
Recommended integration paths
- Public API probes: use
EmakiForgeApior CoreLib JavaScriptemaki.module("forge")to check whether the module is available. - Events: listen to
ForgeStartEventandForgeCompletedEventto intercept or record the forging flow. See the Event API. - JavaScript rules: register forge success-rate rules and result hooks through scripts. See JavaScript.
- PlaceholderAPI: read forging-related state through placeholders. See Placeholders.
- Configuration-driven: handle most needs through
recipes/*.ymlandconfig.yml.
EmakiForgeApi
| Method | Return | Description |
|---|---|---|
available() | boolean | Whether the API bridge is installed. |
apiVersion() | String | API version, empty string when unavailable. |
pluginName() | String | Plugin name, empty string when unavailable. |
isReady() | boolean | Whether the plugin has finished initializing. |
if (EmakiForgeApi.available() && EmakiForgeApi.isReady()) {
logger.info("Forge API version: " + EmakiForgeApi.apiVersion());
}During migration you can also use the compatibility helper EmakiForgeApiProvider:
| Method | Returns | Description |
|---|---|---|
available() | boolean | Equivalent to EmakiForgeApi.available(). |
requireAvailable() | void | Throws IllegalStateException when unavailable. |
if (!EmakiForgeApiProvider.available()) {
return;
}
EmakiForgeApiProvider.requireAvailable();
install(Bridge)anduninstall(Bridge)are called only by EmakiForge's own lifecycle: the bridge is installed on enable and removed on disable. Third-party plugins should not call them.
Requirements
- The Forge module is installed and enabled on the server.
- The calling plugin declares an optional dependency in
paper-plugin.yml. - Do not modify Bukkit items or player inventories directly on async threads.
dependencies:
server:
EmakiForge:
load: BEFORE
required: false
join-classpath: trueJavaScript access
CoreLib JavaScript scripts can query Forge through emaki.module("forge"). The current public API exposes readiness and identity probes only; actual forging still runs through recipes, GUI, and action flows. For script methods that register forge success-rate rules and result hooks, see JavaScript.
| Method | Description |
|---|---|
available() | Whether the Forge API is registered. |
apiVersion() | API version. |
pluginName() | Plugin name. |
ready() | Whether the plugin has finished initializing. |
function main(ctx) {
if (emaki.module("forge").available() && emaki.module("forge").ready()) {
emaki.logger.info("Forge API version=" + emaki.module("forge").apiVersion());
}
return true;
}Thread safety
- Static configuration can be cached asynchronously, but the final ItemStack change must run on the main thread.
- Do not operate on player inventories, world drops, or event objects from async tasks.
ForgeStartEventis the only main-thread cancellation point before the async forge chain begins; listen to it when you need to intercept before forging.
When not to use the API
- Fixed recipe inputs, capacity, and results: use
recipes/*.yml. - Material contribution and quality modifiers: use the recipe
materialsnode and the quality configuration inconfig.yml. - Manual player forging: use the GUI and commands.
- Quest or achievement hooks: use events.
- Changing success rate or granting rewards: use JavaScript rules and result hooks.