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.
| Event | When it fires | Cancellable | Mutable |
|---|---|---|---|
StrengthenPreAttemptEvent | Before the success roll and cost | Yes | setSuccessRate |
StrengthenAttemptEvent | After a strengthen attempt is fully resolved | No | Read-only |
StrengthenTransferEvent | Before the target item is rebuilt | Yes | setTransferredStar |
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
| Method | Return | Description |
|---|---|---|
getPlayer() | Player | Player performing the attempt. |
getTargetItem() | ItemStack | Item being strengthened, may be null. |
getRecipeId() | String | Strengthen recipe id, may be null. |
getCurrentStar() | int | Star level before the attempt. |
getTargetStar() | int | Target star level on success. |
getSuccessRate() | double | Success rate used for the roll (0-100). |
setSuccessRate(double) | void | Change the success rate. |
isCancelled() | boolean | Whether the event is cancelled. |
setCancelled(boolean) | void | Cancel 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
| Method | Return | Description |
|---|---|---|
getPlayer() | Player | Player performing the attempt. |
getResult() | AttemptResult | Fully resolved attempt result (emaki.jiuwu.craft.strengthen.model.AttemptResult). |
isSuccess() | boolean | Whether 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
| Method | Return | Description |
|---|---|---|
getPlayer() | Player | Player performing the transfer. |
getSource() | ItemStack | Source item providing stars. |
getTarget() | ItemStack | Target item receiving stars. |
getTargetRecipeId() | String | Strengthen recipe id of the target item. |
getSourceStar() | int | Current star count of the source item. |
getDecayRate() | double | Transfer decay rate. |
getTransferredStar() | int | Stars to transfer unless changed or cancelled. |
setTransferredStar(int) | void | Change the transferred stars; re-validated and clamped to the target recipe max star, a value of 0 or less aborts the transfer. |
isCancelled() | boolean | Whether the event is cancelled. |
setCancelled(boolean) | void | Cancel 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
AttemptResultreturned byStrengthenAttemptEvent.getResult()lives in theemaki.jiuwu.craft.strengthen.modelpackage; useresult.success()to check the outcome. - The transferred star count set on
StrengthenTransferEventis re-validated and clamped by EmakiStrengthen and will not exceed the target recipe cap.