Handling events
Listening to events
You may listen to any Bukkit-based event (including events added by other plugins) by referencing the imported class. For example, if you wanted to listen to org.bukkit.event.entity.EnderDragonChangePhaseEvent:
Some plugins use their own event handling system or do not pass their events through Bukkit's event executor (which is the case with some of Skript's internal events).
In order to listen to an event, it must extend org.bukkit.event.Event and be executed by Bukkit's event executor.
You may also 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 that are available in one event but not in the other. For example, if you want to listen to both org.bukkit.event.entity.ProjectileLaunchEvent and org.bukkit.event.entity.ProjectileHitEvent
Using the event
expression
event
expressionskript-reflect exposes an event
expression, allowing you to access event values using reflection.
The event
expression may also be used in normal Skript events.
Setting a priority level
The priority level of an event may be set to control when a particular event handler is run relative to other event handlers.
Any event priorities defined in org.bukkit.event.EventPriority may be used. Lower priority event handlers are run before higher priority event handlers.
highest
is the highest priority event handler you should use if you are modifying the contents of an event. If you only care about the final result of the event, use monitor
.
Handling cancelled events
By default, event handlers will not be called if an event is cancelled by a lower priority handler. This behavior can be changed by specifying that the handler should handle all
events.
Last updated