Event API
EmakiCooking exposes Bukkit events that external plugins can listen to in order to intercept or record cooking and nutrition flows. Event classes live in the emaki.jiuwu.craft.cooking.api.event package and use the standard HandlerList boilerplate.
| Event | When it fires | Cancellable | Mutable |
|---|---|---|---|
CookingStationInteractEvent | When a player interacts with a station, before dispatch | No | Read-only |
CookingRecipeCompleteEvent | Before a station delivers its outputs | Yes | setDropResult |
PlayerNutritionConsumeEvent | Before nutrition is applied | Yes | Cancel only |
NutritionThresholdChangeEvent | When a nutrition threshold is met or recovered | No | Read-only |
See Nutrition System for nutrition gameplay and configuration.
CookingStationInteractEvent
Fires when a player interacts with any cooking station block or furniture, covering every block source (vanilla, CraftEngine, ItemsAdder, Nexo, Oraxen and their furniture). The event fires before EmakiCooking dispatches the interaction to its station logic, so it can observe the station a player is currently operating before recipe conditions are evaluated.
Event behavior
- Not cancellable; it is a notification only. Whether the interaction itself is cancelled is decided by EmakiCooking's per-station logic.
- After it fires, EmakiCooking records the player's "most recently used station" so station placeholders (such as
%emakicooking_station_location%) can resolve against it. - Fired on the main thread.
Main methods
| Method | Return | Description |
|---|---|---|
getPlayer() | Player | The interacting player, may be null. |
getLocation() | Location | The station block location. |
getStationType() | String | Station type folder name (chopping_board, wok, grinder, steamer, oven, juicer, fermentation_barrel). |
getInteractionType() | String | Interaction type tag (left_click, right_click, shift_left_click, shift_right_click), empty when unknown. |
Listener Example
@EventHandler
public void onStationInteract(CookingStationInteractEvent event) {
if (event.getPlayer() == null) {
return;
}
// Record which station the player interacted with
event.getPlayer().sendMessage("Station: " + event.getStationType()
+ " @ " + event.getLocation().getBlockX()
+ "," + event.getLocation().getBlockY()
+ "," + event.getLocation().getBlockZ());
}Combined with the %emakicooking_station_*% placeholders, this enables per-station condition recipes such as "only a specific station of the same type yields a specific ingredient". See Placeholder Reference.
CookingRecipeCompleteEvent
Fires before a station delivers its recipe outputs. Use it to intercept the output, change whether the result drops, or record recipe completion.
Event behavior
- It is cancellable. If cancelled, outputs are not delivered and completion actions do not run.
- The drop behavior can be changed with
setDropResult. - Fired on the main thread; asynchronous paths skip the event.
Main methods
| Method | Return | Description |
|---|---|---|
getPlayer() | Player | Player who triggered completion; may be null for automatic stations. |
getLocation() | Location | Station location. |
getRecipeId() | String | Recipe id. |
getRecipeName() | String | Recipe display name. |
getStationType() | String | Station type folder name (such as wok or oven). |
getPhase() | String | Completion phase marker. |
getOutputCount() | int | Number of output entries about to be delivered. |
isDropResult() | boolean | Whether the result drops instead of going to inventory. |
setDropResult(boolean) | void | Change whether the result drops. |
isCancelled() | boolean | Whether the event is cancelled. |
setCancelled(boolean) | void | Cancel or restore the event. |
Example
@EventHandler
public void onRecipeComplete(CookingRecipeCompleteEvent event) {
// Force every output to drop on the ground
event.setDropResult(true);
// Block a specific recipe
if (event.getRecipeId().equals("forbidden_dish")) {
event.setCancelled(true);
}
}PlayerNutritionConsumeEvent
Fires before nutrition is applied to a player. This event aggregates multiple eating sources such as vanilla, MMOItems, and NeigeItems.
Event behavior
- It is cancellable. If cancelled, no nutrition is applied and food source actions do not run.
- Fired on the main thread; asynchronous paths skip the event.
Main methods
| Method | Return | Description |
|---|---|---|
getPlayer() | Player | Player eating the item. |
getItem() | ItemStack | Item being consumed. |
getItemSource() | String | Resolved item source shorthand (such as minecraft-apple). |
isCancelled() | boolean | Whether the event is cancelled. |
setCancelled(boolean) | void | Cancel or restore the event. |
Example
@EventHandler
public void onNutritionConsume(PlayerNutritionConsumeEvent event) {
// Stop a source from providing nutrition
if (event.getItemSource().startsWith("itemsadder-")) {
event.setCancelled(true);
}
}NutritionThresholdChangeEvent
An informational event fired when a nutrition threshold is met or recovered. It is edge-triggered: fired once when the threshold is met, and once again when it recovers.
Event behavior
- Not cancellable; purely informational.
- Distinguishes single-type thresholds (
SINGLE) from combo thresholds (COMBO). - Fired on the main thread.
Main methods
| Method | Return | Description |
|---|---|---|
getPlayer() | Player | Player whose nutrition changed. |
getKind() | Kind | Threshold kind, SINGLE or COMBO. |
getRuleId() | String | Threshold rule id. |
getTypeId() | String | Nutrition type id for single thresholds; null for COMBO. |
isMet() | boolean | true means met, false means recovered. |
getValue() | double | Current nutrition value for single thresholds, otherwise 0. |
getThreshold() | double | Configured threshold. |
getMatchedCount() | int | Matched type count for combo thresholds, otherwise 0. |
getRequiredCount() | int | Required type count for combo thresholds, otherwise 0. |
Kind enum values:
| Value | Description |
|---|---|
SINGLE | Single-type threshold. |
COMBO | Combo threshold. |
Example
@EventHandler
public void onThresholdChange(NutritionThresholdChangeEvent event) {
if (event.getKind() == NutritionThresholdChangeEvent.Kind.COMBO && event.isMet()) {
event.getPlayer().sendMessage("Balanced diet reached: " + event.getRuleId());
}
}Notes
- Threshold actions themselves are configured by the server admin under
nutrition.thresholdsinconfig.ymlusing CoreLib actions. This event only lets external plugins observe state changes. - Edge triggering means the same state is not dispatched repeatedly; the event fires only when a threshold is crossed.