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.
Recommended integration paths
- Public API probes: use
EmakiCookingApior CoreLib JavaScriptemaki.module("cooking")to check whether the module is available. - Events: listen to
CookingRecipeCompleteEvent,PlayerNutritionConsumeEvent, andNutritionThresholdChangeEventto intercept or record cooking and nutrition flows. See the Event API. - JavaScript rules: register cooking result rules and completion hooks through scripts. See JavaScript.
- PlaceholderAPI: read nutrition state through placeholders. See Placeholders.
- Configuration-driven: handle most needs through
recipes/,nutrition/, andconfig.yml.
EmakiCookingApi
| 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 (EmakiCookingApi.available() && EmakiCookingApi.isReady()) {
logger.info("Cooking API version: " + EmakiCookingApi.apiVersion());
}If you prefer the migration helper, you can run an availability check first:
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.
dependencies:
server:
EmakiCooking:
load: BEFORE
required: false
join-classpath: trueJavaScript 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.
| Method | Description |
|---|---|
available() | Whether the Cooking API is registered. |
apiVersion() | API version. |
pluginName() | Plugin name. |
ready() | Whether the plugin has finished initializing. |
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 thenutritionsection inconfig.yml. - Manual player cooking: use block interactions.
- Quest or achievement hooks: use events.
- Changing outputs or adding rewards: use JavaScript rules and completion hooks.