Skip to content

API

EmakiCooking exposes a static facade EmakiCookingApi that provides version, plugin name, and readiness probes. The full gameplay flow (station interaction, recipe resolution, nutrition application) still runs through block interactions, recipes, commands, and actions. To hook into cooking or nutrition, listen to the Event API or register JavaScript cooking rules.

  1. Public API probes: use EmakiCookingApi or CoreLib JavaScript emaki.module("cooking") to check whether the module is available.
  2. Events: listen to CookingRecipeCompleteEvent, PlayerNutritionConsumeEvent, and NutritionThresholdChangeEvent to intercept or record cooking and nutrition flows. See the Event API.
  3. JavaScript rules: register cooking result rules and completion hooks through scripts. See JavaScript.
  4. PlaceholderAPI: read nutrition state through placeholders. See Placeholders.
  5. Configuration-driven: handle most needs through recipes/, nutrition/, and config.yml.

EmakiCookingApi

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 (EmakiCookingApi.available() && EmakiCookingApi.isReady()) {
    logger.info("Cooking API version: " + EmakiCookingApi.apiVersion());
}

If you prefer the migration helper, you can run an availability check first:

java
if (!EmakiCookingApiProvider.available()) {
    return;
}

EmakiCookingApiProvider.requireAvailable();

Requirements

  • The Cooking 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:
    EmakiCooking:
      load: BEFORE
      required: false
      join-classpath: true

JavaScript access

CoreLib JavaScript scripts can query Cooking through emaki.module("cooking"). The current public API exposes readiness and identity probes only; recipe execution and station state changes still run through block interactions and action flows. For script methods that register cooking result rules and completion hooks, see JavaScript.

MethodDescription
available()Whether the Cooking API is registered.
apiVersion()API version.
pluginName()Plugin name.
ready()Whether the plugin has finished initializing.
js
function main(ctx) {
  if (emaki.module("cooking").available() && emaki.module("cooking").ready()) {
    emaki.logger.info("Cooking module=" + emaki.module("cooking").pluginName());
  }
  return true;
}

Thread safety

  • Static configuration can be cached asynchronously, but the final ItemStack or station state change must run on the main thread.
  • Do not operate on player inventories, world drops, or event objects from async tasks.
  • Cooking and nutrition events all fire on the main thread; async paths skip them.

When not to use the API

  • Fixed station recipes: use the matching station folder under recipes/.
  • Nutrition types and thresholds: use nutrition/ and the nutrition section in config.yml.
  • Manual player cooking: use block interactions.
  • Quest or achievement hooks: use events.
  • Changing outputs or adding rewards: use JavaScript rules and completion hooks.