Skip to content

Event API

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

EventWhen it firesCancellableMutable
StrengthenPreAttemptEventBefore the success roll and costYessetSuccessRate
StrengthenAttemptEventAfter a strengthen attempt is fully resolvedNoRead-only
StrengthenTransferEventBefore the target item is rebuiltYessetTransferredStar

StrengthenPreAttemptEvent

Fires after the preview passes condition checks, before the success roll and before any cost is charged.

Event behavior

  • It is cancellable. If cancelled, there is no roll, no rebuild, and no cost charged.
  • The success rate can be changed with setSuccessRate, expressed as a percentage from 0 to 100.
  • Fired on the main thread; asynchronous paths skip the event.

Main methods

MethodReturnDescription
getPlayer()PlayerPlayer performing the attempt.
getTargetItem()ItemStackItem being strengthened, may be null.
getRecipeId()StringStrengthen recipe id, may be null.
getCurrentStar()intStar level before the attempt.
getTargetStar()intTarget star level on success.
getSuccessRate()doubleSuccess rate used for the roll (0-100).
setSuccessRate(double)voidChange the success rate.
isCancelled()booleanWhether the event is cancelled.
setCancelled(boolean)voidCancel or restore the event.

Example

java
@EventHandler
public void onStrengthenPreAttempt(StrengthenPreAttemptEvent event) {
    // Lower the success rate for high-star attempts
    if (event.getTargetStar() >= 10) {
        event.setSuccessRate(event.getSuccessRate() * 0.5);
    }
}

StrengthenAttemptEvent

Fires after a strengthen attempt has been fully resolved. Success, failed rolls, and early failures (ineligible item, unmet conditions, rebuild or charge failure) all fire it; by this point the item has been rebuilt and the cost charged.

Event behavior

  • Not cancellable; purely informational.

Main methods

MethodReturnDescription
getPlayer()PlayerPlayer performing the attempt.
getResult()AttemptResultFully resolved attempt result (emaki.jiuwu.craft.strengthen.model.AttemptResult).
isSuccess()booleanWhether the attempt succeeded.

StrengthenTransferEvent

Fires after the transferable star count is calculated, before the target item is rebuilt.

Event behavior

  • It is cancellable. If cancelled, the target item is not rebuilt.
  • The transferred star count can be changed with setTransferredStar. EmakiStrengthen re-validates it (clamped to the target recipe's max star); a value of 0 or less aborts the transfer.
  • Fired on the main thread; asynchronous paths skip the event.

Main methods

MethodReturnDescription
getPlayer()PlayerPlayer performing the transfer.
getSource()ItemStackSource item providing stars.
getTarget()ItemStackTarget item receiving stars.
getTargetRecipeId()StringStrengthen recipe id of the target item.
getSourceStar()intCurrent star count of the source item.
getDecayRate()doubleTransfer decay rate.
getTransferredStar()intStars to transfer unless changed or cancelled.
setTransferredStar(int)voidChange the transferred stars; re-validated and clamped to the target recipe max star, a value of 0 or less aborts the transfer.
isCancelled()booleanWhether the event is cancelled.
setCancelled(boolean)voidCancel or restore the event.

Example

java
@EventHandler
public void onStrengthenTransfer(StrengthenTransferEvent event) {
    // Transfer one extra star (clamped to the target recipe cap)
    event.setTransferredStar(event.getTransferredStar() + 1);
}

Notes

  • The AttemptResult returned by StrengthenAttemptEvent.getResult() lives in the emaki.jiuwu.craft.strengthen.model package; use result.success() to check the outcome.
  • The transferred star count set on StrengthenTransferEvent is re-validated and clamped by EmakiStrengthen and will not exceed the target recipe cap.