Event API
EmakiSkills exposes Bukkit events that external plugins can listen to in order to intercept, modify, or record skill flows. Event classes live in the emaki.jiuwu.craft.skills.api.event package and use the standard HandlerList boilerplate.
| Event | When it fires | Cancellable | Mutable |
|---|---|---|---|
SkillPreCastEvent | After cooldown/resource/condition checks, before skill effects run | Yes | Cancel only |
SkillPreUpgradeEvent | Before upgrade cost and roll | Yes | setSuccessRate |
SkillUpgradeEvent | After a skill upgrade attempt is fully resolved | No | Read-only |
PlayerSkillSlotChangeEvent | Before a skill slot binding changes | Yes | Cancel only |
SkillPreCastEvent
Fires after a skill passes cooldown, resource, and condition checks, before its effects run. This is the central pre-cast hook for both active and passive triggers.
Event behavior
- It is cancellable. If cancelled, the skill does not run, no resources are spent, and no cooldown is recorded.
- Fired on the server thread.
Main methods
| Method | Return | Description |
|---|---|---|
getPlayer() | Player | Player casting the skill. |
getSkillId() | String | Id of the skill about to cast. |
getTriggerId() | String | Trigger id that initiated the cast. |
isCancelled() | boolean | Whether the event is cancelled. |
setCancelled(boolean) | void | Cancel or restore the event. |
Example
java
@EventHandler
public void onSkillPreCast(SkillPreCastEvent event) {
// Block casting inside a no-magic zone
if (inNoMagicZone(event.getPlayer().getLocation())) {
event.setCancelled(true);
}
}SkillPreUpgradeEvent
Fires before the skill upgrade cost is charged and the success roll is decided.
Event behavior
- It is cancellable. If cancelled, no cost is charged and no upgrade happens.
- The success rate can be changed with
setSuccessRate, expressed as a percentage from 0 to 100. - Fired on the server thread.
Main methods
| Method | Return | Description |
|---|---|---|
getPlayer() | Player | Player performing the upgrade. |
getSkillId() | String | Skill id. |
getCurrentLevel() | int | Level before the upgrade. |
getTargetLevel() | int | Level after success. |
getMaxLevel() | int | Maximum skill level. |
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 onSkillPreUpgrade(SkillPreUpgradeEvent event) {
// Boost upgrade success rate during an event
event.setSuccessRate(Math.min(100.0, event.getSuccessRate() + 20.0));
}SkillUpgradeEvent
Fires after a skill upgrade attempt has been fully resolved. Both success and failure are reported, with level changes or failure downgrade penalties already applied.
Event behavior
- Not cancellable; purely informational.
Main methods
| Method | Return | Description |
|---|---|---|
getPlayer() | Player | Player performing the upgrade. |
getSkillId() | String | Skill id. |
getFromLevel() | int | Level before the attempt. |
getToLevel() | int | Level after the attempt. |
getSuccessRate() | double | Success rate used for the roll (0-100). |
isSuccess() | boolean | Whether the attempt succeeded. |
isDowngraded() | boolean | Whether a failure penalty caused a downgrade. |
PlayerSkillSlotChangeEvent
Fires before a player's skill slot binding changes.
Event behavior
- It is cancellable. If cancelled, the binding is not updated and the originating method returns
false. - Distinguishes equip, unequip, and bind-trigger actions.
- Fired on the server thread.
Main methods
| Method | Return | Description |
|---|---|---|
getPlayer() | Player | Player whose slot changes. |
getSlotIndex() | int | Target slot index. |
getSkillId() | String | Skill id involved (original bound skill id for UNEQUIP), may be null. |
getTriggerId() | String | Trigger id for BIND_TRIGGER, otherwise null. |
getAction() | Action | Slot change kind. |
isCancelled() | boolean | Whether the event is cancelled. |
setCancelled(boolean) | void | Cancel or restore the event. |
Action enum values:
| Value | Description |
|---|---|
EQUIP | Equip a skill to a slot. |
UNEQUIP | Unequip a skill from a slot. |
BIND_TRIGGER | Bind a trigger to a slot. |
Example
java
@EventHandler
public void onSlotChange(PlayerSkillSlotChangeEvent event) {
// Lock the first slot from being unequipped
if (event.getSlotIndex() == 0
&& event.getAction() == PlayerSkillSlotChangeEvent.Action.UNEQUIP) {
event.setCancelled(true);
}
}Notes
- Changing the success rate applies only to
SkillPreUpgradeEvent. getSkillId()andgetTriggerId()may be null for some actions; check for null before use.