Other Advanced event handling with skript-mirror

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

btk5h

Addon Developer
Jan 25, 2017
154
159
0
Pyongyang, North Korea
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
code_language.skript:
on "org.bukkit.event.entity.EnderDragonChangePhaseEvent":
  # your code
skript-mirror exposes an event expression, allowing you to get event values using reflection.
code_language.skript:
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
code_language.skript:
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.
code_language.skript:
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
 
Last edited: