Skip to content

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.

EventWhen it firesCancellableMutable
SkillPreCastEventAfter cooldown/resource/condition checks, before skill effects runYesCancel only
SkillPreUpgradeEventBefore upgrade cost and rollYessetSuccessRate
SkillUpgradeEventAfter a skill upgrade attempt is fully resolvedNoRead-only
PlayerSkillSlotChangeEventBefore a skill slot binding changesYesCancel 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

MethodReturnDescription
getPlayer()PlayerPlayer casting the skill.
getSkillId()StringId of the skill about to cast.
getTriggerId()StringTrigger id that initiated the cast.
isCancelled()booleanWhether the event is cancelled.
setCancelled(boolean)voidCancel 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

MethodReturnDescription
getPlayer()PlayerPlayer performing the upgrade.
getSkillId()StringSkill id.
getCurrentLevel()intLevel before the upgrade.
getTargetLevel()intLevel after success.
getMaxLevel()intMaximum skill level.
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 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

MethodReturnDescription
getPlayer()PlayerPlayer performing the upgrade.
getSkillId()StringSkill id.
getFromLevel()intLevel before the attempt.
getToLevel()intLevel after the attempt.
getSuccessRate()doubleSuccess rate used for the roll (0-100).
isSuccess()booleanWhether the attempt succeeded.
isDowngraded()booleanWhether 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

MethodReturnDescription
getPlayer()PlayerPlayer whose slot changes.
getSlotIndex()intTarget slot index.
getSkillId()StringSkill id involved (original bound skill id for UNEQUIP), may be null.
getTriggerId()StringTrigger id for BIND_TRIGGER, otherwise null.
getAction()ActionSlot change kind.
isCancelled()booleanWhether the event is cancelled.
setCancelled(boolean)voidCancel or restore the event.

Action enum values:

ValueDescription
EQUIPEquip a skill to a slot.
UNEQUIPUnequip a skill from a slot.
BIND_TRIGGERBind 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() and getTriggerId() may be null for some actions; check for null before use.