Skip to content

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.

  1. Public API probes: use EmakiForgeApi or CoreLib JavaScript emaki.module("forge") to check whether the module is available.
  2. Events: listen to ForgeStartEvent and ForgeCompletedEvent to intercept or record the forging flow. See the Event API.
  3. JavaScript rules: register forge success-rate rules and result hooks through scripts. See JavaScript.
  4. PlaceholderAPI: read forging-related state through placeholders. See Placeholders.
  5. Configuration-driven: handle most needs through recipes/*.yml and config.yml.

EmakiForgeApi

MethodReturnDescription
available()booleanWhether the API bridge is installed.
apiVersion()StringAPI version, empty string when unavailable.
pluginName()StringPlugin name, empty string when unavailable.
isReady()booleanWhether the plugin has finished initializing.
java
if (EmakiForgeApi.available() && EmakiForgeApi.isReady()) {
    logger.info("Forge API version: " + EmakiForgeApi.apiVersion());
}

During migration you can also use the compatibility helper EmakiForgeApiProvider:

MethodReturnsDescription
available()booleanEquivalent to EmakiForgeApi.available().
requireAvailable()voidThrows IllegalStateException when unavailable.
java
if (!EmakiForgeApiProvider.available()) {
    return;
}

EmakiForgeApiProvider.requireAvailable();

install(Bridge) and uninstall(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.
yaml
dependencies:
  server:
    EmakiForge:
      load: BEFORE
      required: false
      join-classpath: true

JavaScript 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.

MethodDescription
available()Whether the Forge API is registered.
apiVersion()API version.
pluginName()Plugin name.
ready()Whether the plugin has finished initializing.
js
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.
  • ForgeStartEvent is 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 materials node and the quality configuration in config.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.