Skip to content

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.

EventWhen it firesCancellableMutable
CookingStationInteractEventWhen a player interacts with a station, before dispatchNoRead-only
CookingRecipeCompleteEventBefore a station delivers its outputsYessetDropResult
PlayerNutritionConsumeEventBefore nutrition is appliedYesCancel only
NutritionThresholdChangeEventWhen a nutrition threshold is met or recoveredNoRead-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

MethodReturnDescription
getPlayer()PlayerThe interacting player, may be null.
getLocation()LocationThe station block location.
getStationType()StringStation type folder name (chopping_board, wok, grinder, steamer, oven, juicer, fermentation_barrel).
getInteractionType()StringInteraction type tag (left_click, right_click, shift_left_click, shift_right_click), empty when unknown.

Listener Example

java
@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

MethodReturnDescription
getPlayer()PlayerPlayer who triggered completion; may be null for automatic stations.
getLocation()LocationStation location.
getRecipeId()StringRecipe id.
getRecipeName()StringRecipe display name.
getStationType()StringStation type folder name (such as wok or oven).
getPhase()StringCompletion phase marker.
getOutputCount()intNumber of output entries about to be delivered.
isDropResult()booleanWhether the result drops instead of going to inventory.
setDropResult(boolean)voidChange whether the result drops.
isCancelled()booleanWhether the event is cancelled.
setCancelled(boolean)voidCancel or restore the event.

Example

java
@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

MethodReturnDescription
getPlayer()PlayerPlayer eating the item.
getItem()ItemStackItem being consumed.
getItemSource()StringResolved item source shorthand (such as minecraft-apple).
isCancelled()booleanWhether the event is cancelled.
setCancelled(boolean)voidCancel or restore the event.

Example

java
@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

MethodReturnDescription
getPlayer()PlayerPlayer whose nutrition changed.
getKind()KindThreshold kind, SINGLE or COMBO.
getRuleId()StringThreshold rule id.
getTypeId()StringNutrition type id for single thresholds; null for COMBO.
isMet()booleantrue means met, false means recovered.
getValue()doubleCurrent nutrition value for single thresholds, otherwise 0.
getThreshold()doubleConfigured threshold.
getMatchedCount()intMatched type count for combo thresholds, otherwise 0.
getRequiredCount()intRequired type count for combo thresholds, otherwise 0.

Kind enum values:

ValueDescription
SINGLESingle-type threshold.
COMBOCombo threshold.

Example

java
@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.thresholds in config.yml using 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.