Advanced event handling with skript-mirror

skript-mirror offers robust event support for scripts that need to:
  • listen to events that aren't supported by Skript
  • listen to multiple (even unrelated) events under the same event handler
  • listen to events with a specific priority level


Listening to custom events
You can listen to any Bukkit event (even events added by other plugins) using the event's fully qualified name. For example, if you want to listen to org.bukkit.event.entity.EnderDragonChangePhaseEvent
on "org.bukkit.event.entity.EnderDragonChangePhaseEvent":
# your code

skript-mirror exposes an event expression, allowing you to get event values using reflection.
on script load:
import "org.bukkit.entity.EnderDragon$Phase"

on "org.bukkit.event.entity.EnderDragonChangePhaseEvent":
if event.getNewPhase() is {Phase}.CIRCLING!:
event.setNewPhase({Phase}.CHARGE_PLAYER!);


Listening to multiple events with the same handler
You can listen to multiple events with the same handler. The events do not have to be related, but you should take appropriate precautions if you try to access methods available in one event but not the other. For example, if you want to listen to both org.bukkit.event.entity.ProjectileLaunchEvent and org.bukkit.event.entity.ProjectileHitEvent
on "org.bukkit.event.entity.ProjectileLaunchEvent" and "org.bukkit.event.entity.ProjectileHitEvent":
# your code


Setting a priority level
You can specify a specific event priority to manually set which order your event handlers run. This allows you to coordinate when your event handlers run with respect to other plugins and other scripts.
on "org.bukkit.event.entity.EnderDragonChangePhaseEvent" with priority lowest:
# your code

on "org.bukkit.event.entity.EnderDragonChangePhaseEvent" with priority low:
# your code

on "org.bukkit.event.entity.EnderDragonChangePhaseEvent" with priority normal:
# your code

on "org.bukkit.event.entity.EnderDragonChangePhaseEvent" with priority high:
# your code

on "org.bukkit.event.entity.EnderDragonChangePhaseEvent" with priority highest:
# your code

on "org.bukkit.event.entity.EnderDragonChangePhaseEvent" with priority monitor:
# your code