EventPriority
EventPriority
Section titled “EventPriority”Package: com.hypixel.hytale.event
public enum EventPriorityDefines the execution order for event listeners registered through the EventRegistry. Listeners with lower numeric values execute first. Five standard priority levels are provided; for finer control, registration methods also accept a raw short value.
Constants
Section titled “Constants”| Constant | Numeric Value | Description |
|---|---|---|
FIRST | -21844 | Highest priority. Runs before all other standard levels. Use for listeners that must observe events before any other processing. |
EARLY | -10922 | Runs before NORMAL. Use for pre-processing or validation. |
NORMAL | 0 | Default priority. Most listeners should use this level. |
LATE | 10922 | Runs after NORMAL. Use for post-processing or reactions to earlier handling. |
LAST | 21844 | Lowest priority. Runs after all other standard levels. Use for cleanup, logging, or final-say handlers. |
The values are evenly spaced across the short range, leaving room for custom priorities between each level. For example, a priority of 5000 would run between NORMAL and LATE.
Methods
Section titled “Methods”getValue
Section titled “getValue”public short getValue()Returns the numeric priority value for this constant.
Ordering Behavior
Section titled “Ordering Behavior”Listeners are executed in ascending numeric order:
FIRST (-21844) → EARLY (-10922) → NORMAL (0) → LATE (10922) → LAST (21844)When two listeners have the same numeric priority, their relative execution order is unspecified. Do not rely on insertion order for same-priority listeners.
Custom Priorities
Section titled “Custom Priorities”All registration method families on EventRegistry provide a short overload that accepts a raw numeric priority. This allows placing a listener between standard levels:
// Register between NORMAL (0) and LATE (10922)events.register((short) 5000, PlayerConnectEvent.class, event -> { // runs after NORMAL listeners, before LATE listeners});Usage Examples
Section titled “Usage Examples”Default priority (NORMAL)
Section titled “Default priority (NORMAL)”events.register(BootEvent.class, event -> { // runs at NORMAL (0) priority});Explicit priority
Section titled “Explicit priority”events.register(EventPriority.EARLY, PlayerConnectEvent.class, event -> { // runs before NORMAL listeners});Priority for cancellation checking
Section titled “Priority for cancellation checking”// Use LATE to check if a previous listener cancelled the eventevents.register(EventPriority.LATE, PlayerSetupConnectEvent.class, event -> { if (event.isCancelled()) { getLogger().info("Connection was cancelled by an earlier listener."); }});Related Types
Section titled “Related Types”- EventRegistry — plugin-scoped registry; all registration methods accept
EventPriority - EventRegistration — handle returned by registration methods
IEventRegistry— interface defining the registration contract with priority overloads- Events Overview — index of all documented events