Event System
The Hytale server implements an event system that allows mods to react to game events, modify behavior, and communicate with each other.
The system is built around a central EventBus that manages event registration and dispatch. Events can be:
- Synchronous (
IEvent) - Handlers called immediately in priority order - Asynchronous (
IAsyncEvent) - Handlers useCompletableFuturefor async processing - Cancellable (
ICancellable) - Handlers can prevent the action from occurring - Keyed - Events filtered by key (world name, asset type, etc.)
Quick Reference
Section titled “Quick Reference”| Task | Guide |
|---|---|
| Listen for events | Listening to Events |
| Create custom events | Creating Custom Events |
| Dispatch events | Dispatching Events |
| Event reference | Event Reference |
Event Flow
Section titled “Event Flow”- Event Created - Code creates an event instance
- Dispatcher Obtained -
eventBus.dispatchFor(EventClass.class)or with key - Dispatch -
dispatcher.dispatch(event)calls handlers in priority order - Keyed Matching - For keyed events, only matching listeners are called
- Global Fallback - Global listeners receive all keyed events
- Unhandled Fallback - Unhandled listeners only called if no keyed match
- Result - For cancellable events, check
event.isCancelled()
Package Structure
Section titled “Package Structure”Built-in events by package:
| Package | Description |
|---|---|
com.hypixel.hytale.assetstore.event | Asset loading and hot-reload |
com.hypixel.hytale.server.core.event.events | Core server (boot, shutdown) |
com.hypixel.hytale.server.core.event.events.ecs | Block/item interactions |
com.hypixel.hytale.server.core.event.events.entity | Entity lifecycle |
com.hypixel.hytale.server.core.event.events.permissions | Permission changes |
com.hypixel.hytale.server.core.event.events.player | Player actions |
com.hypixel.hytale.server.core.plugin.event | Plugin lifecycle |
com.hypixel.hytale.server.core.prefab.event | Prefab paste/place |
com.hypixel.hytale.server.core.universe.world.events | World and chunks |
See the Event Reference for a complete list of all events.