Skip to content

Event API

EmakiForge exposes Bukkit events that external plugins can listen to in order to intercept or record the forging flow. Event classes live in the emaki.jiuwu.craft.forge.api.event package and use the standard HandlerList boilerplate.

EventWhen it firesCancellableMutable
ForgeStartEventJust before asynchronous forge execution beginsYesRead-only
ForgeCompletedEventAfter a forge attempt has fully completedNoRead-only

ForgeStartEvent

Fires just before asynchronous forge execution begins. This is the only cancellation point that runs on the main thread before the asynchronous chain starts.

Event behavior

  • It is cancellable. If cancelled, the forge flow does not start.
  • successRate is read-only: the success rate is decided by configuration and JavaScript rules, so the event does not expose a setter.
  • Fired on the main thread; asynchronous paths skip the event.

Main methods

MethodReturnDescription
getPlayer()PlayerPlayer performing the forge.
getRecipeId()StringForge recipe id.
isFirstCraft()booleanWhether this is the first craft of the recipe.
getSuccessRate()doubleConfigured recipe success rate (0-100), read-only.
isCancelled()booleanWhether the event is cancelled.
setCancelled(boolean)voidCancel or restore the event.

Example

java
@EventHandler
public void onForgeStart(ForgeStartEvent event) {
    // Restrict a recipe to its first craft only
    if (!event.isFirstCraft() && event.getRecipeId().equals("legendary_blade")) {
        event.setCancelled(true);
    }
}

ForgeCompletedEvent

Fires after a forge attempt has fully completed. Both success and failure fire the event; use isSuccess() to tell them apart. Unexpected errors do not fire it.

Event behavior

  • Not cancellable; purely informational.
  • Fired on the main thread.

Main methods

MethodReturnDescription
getPlayer()PlayerPlayer who performed the attempt.
getRecipeId()StringForge recipe id.
isSuccess()booleanWhether the attempt succeeded.
getResultItem()ItemStackResult item, null on failure.
getQuality()StringResolved quality tier id, may be empty.
getMultiplier()doubleResolved quality multiplier.

Example

java
@EventHandler
public void onForgeCompleted(ForgeCompletedEvent event) {
    if (event.isSuccess()) {
        getLogger().info(event.getPlayer().getName()
            + " forged successfully with quality " + event.getQuality());
    }
}

Notes

  • On failure getResultItem() returns null; check for null before reading it.
  • getQuality() may be an empty string or null depending on whether the recipe uses the quality system.