-
Notifications
You must be signed in to change notification settings - Fork 2
Events
Located in com/hypixel/hytale/event/
| Interface | Purpose |
|---|---|
IBaseEvent<KeyType> |
Root marker interface for all events with generic routing key |
IEvent<KeyType> |
Synchronous events - blocks until all handlers complete |
IAsyncEvent<KeyType> |
Asynchronous events - returns CompletableFuture
|
ICancellable |
Events that can be cancelled before processing |
IProcessedEvent |
Events that track post-processing status |
Located in component/system/
EcsEvent (base)
├── CancellableEcsEvent implements ICancellableEcsEvent
│ ├── BreakBlockEvent
│ ├── PlaceBlockEvent
│ ├── DiscoverZoneEvent
│ ├── ChangeGameModeEvent
│ ├── CraftRecipeEvent
│ ├── DamageBlockEvent
│ ├── DropItemEvent
│ └── ... (many more)
└── UseBlockEvent
├── UseBlockEvent.Pre (cancellable)
└── UseBlockEvent.Post (notification only)
Located in server/core/event/events/
PlayerEvent<KeyType> implements IEvent<KeyType>
├── PlayerConnectEvent
├── PlayerDisconnectEvent
├── PlayerChatEvent implements ICancellable
├── PlayerInteractEvent implements ICancellable
├── PlayerMouseButtonEvent
├── PlayerMouseMotionEvent
├── PlayerCraftEvent
├── PlayerReadyEvent
└── AddPlayerToWorldEvent
EntityEvent<EntityType, KeyType> implements IEvent<KeyType>
├── EntityRemoveEvent
├── LivingEntityInventoryChangeEvent
└── LivingEntityUseBlockEvent
BootEvent implements IEvent<Void>
PrepareUniverseEvent implements IEvent<Void>
ShutdownEvent implements IEvent<Void>
Located in assetstore/event/
AssetStoreEvent<KeyType>
├── RegisterAssetStoreEvent
└── RemoveAssetStoreEvent
AssetsEvent<K, T>
├── GenerateAssetsEvent
├── LoadedAssetsEvent
└── RemovedAssetsEvent
| Class | Purpose |
|---|---|
EventBus |
Main event bus implementation |
SyncEventBusRegistry |
Handles synchronous IEvent dispatch |
AsyncEventBusRegistry |
Handles async IAsyncEvent with CompletableFuture
|
EventConsumerMap |
Stores listeners organized by priority |
-
Keyed Registration - Context-specific (e.g., world-specific events)
eventBus.register(BreakBlockEvent.class, worldKey, event -> { ... });
-
Global Registration - Receives ALL events of that type
eventBus.registerGlobal(BreakBlockEvent.class, event -> { ... });
-
Unhandled Registration - Fallback when keyed handlers don't process
eventBus.registerUnhandled(SomeEvent.class, event -> { ... });
| Priority | Value | Use Case |
|---|---|---|
FIRST |
-21844 | Must run before all others |
EARLY |
-10922 | Run early in chain |
NORMAL |
0 | Default priority |
LATE |
10922 | Run after most handlers |
LAST |
21844 | Must run after all others |
eventBus.dispatchFor(EventClass.class, key)
└── SyncEventBusRegistry.dispatchFor(key)
└── SyncEventConsumerMap.dispatch(event)
├── Dispatch keyed listeners (by priority)
├── If handled → return event
├── Else → dispatch unhandled listeners
└── Return modified event
eventBus.dispatchForAsync(EventClass.class, key)
└── AsyncEventBusRegistry.dispatchFor(key)
└── AsyncEventConsumerMap.dispatch(event)
└── Returns CompletableFuture chain
Queries are part of the ECS (Entity Component System), not the event system directly. They filter which entities a system should operate on.
Located in component/query/
| Query Type | Purpose |
|---|---|
AnyQuery |
Matches all archetypes (entities) |
ExactArchetypeQuery |
Matches specific archetype only |
NotQuery |
Negates another query |
AndQuery |
Logical AND of multiple queries |
OrQuery |
Logical OR of multiple queries |
ReadWriteArchetypeQuery |
For read/write component operations |
public abstract class EntityEventSystem<ECS_TYPE, EventType extends EcsEvent>
extends EventSystem<EventType> implements QuerySystem<ECS_TYPE> {
@Override
public Query<ECS_TYPE> getQuery() {
// Define which entities receive this event
return Query.and(hasHealthComponent, hasPositionComponent);
}
@Override
public void handle(int index, ArchetypeChunk<ECS_TYPE> chunk,
Store<ECS_TYPE> store, CommandBuffer<ECS_TYPE> buffer,
EventType event) {
// Only called for entities matching the query
}
}Purpose: When an EcsEvent is dispatched, the EntityEventSystem uses its Query to filter which entities should receive and process that event. This is how the ECS efficiently routes events only to relevant entities.
public class BootEvent implements IEvent<Void> {
// No additional fields needed
}public class PlayerChatEvent extends PlayerEvent<Void> implements ICancellable {
private boolean cancelled;
@Override
public boolean isCancelled() { return cancelled; }
@Override
public void setCancelled(boolean cancelled) { this.cancelled = cancelled; }
}public abstract class UseBlockEvent extends EcsEvent {
// Common fields...
public static final class Pre extends UseBlockEvent implements ICancellableEcsEvent {
// Can be cancelled before action
}
public static final class Post extends UseBlockEvent {
// Notification only, after action completed
}
}eventBus.register(PlayerConnectEvent.class, event -> {
Player player = event.getPlayer();
// Handle connection
});eventBus.register(EventPriority.EARLY, BreakBlockEvent.class, event -> {
// Runs before NORMAL priority handlers
});eventBus.register(BreakBlockEvent.class, event -> {
if (!hasPermission(player)) {
event.setCancelled(true); // Prevent block break
}
});eventBus.registerAsync(SomeAsyncEvent.class, future ->
future.thenApply(event -> {
// Process asynchronously
return event;
}));EventRegistration registration = eventBus.register(SomeEvent.class, handler);
// Later...
registration.unregister();| Feature | Implementation |
|---|---|
| No annotations | Uses functional Consumer<T> and Function<> patterns |
| Type safety | Generics throughout (IEvent<KeyType>) |
| Thread safety |
ConcurrentHashMap, CopyOnWriteArrayList, AtomicReference
|
| Cancellation |
ICancellable and ICancellableEcsEvent interfaces |
| Priorities | 5 predefined + custom short values |
| Sync/Async | Separate registries for each |
| ECS Integration |
Query system filters entities for event handling |
| Total events | ~107 concrete event implementations |
This section provides a comprehensive list of all events in the codebase, organized by their handler/listener system.
Located in server/core/event/
| Event | Key Type | Cancellable | Description |
|---|---|---|---|
BootEvent |
Void |
No | Fired when server boots |
ShutdownEvent |
Void |
No | Fired when server shuts down |
PrepareUniverseEvent |
Void |
No | Universe preparation (deprecated) |
| Event | Key Type | Cancellable | Description |
|---|---|---|---|
PlayerConnectEvent |
Void |
No | Player connects to server |
PlayerDisconnectEvent |
Void |
No | Player disconnects from server |
PlayerReadyEvent |
Void |
No | Player is fully loaded and ready |
PlayerSetupConnectEvent |
Void |
Yes | Player setup phase connection |
PlayerSetupDisconnectEvent |
Void |
No | Player setup phase disconnection |
PlayerChatEvent |
String |
Yes | Player sends chat message |
PlayerCraftEvent |
String |
No | Player crafts an item |
PlayerInteractEvent |
String |
Yes | Player interacts with something |
PlayerMouseButtonEvent |
Void |
No | Mouse button input |
PlayerMouseMotionEvent |
Void |
No | Mouse motion input |
AddPlayerToWorldEvent |
String |
No | Player added to world (key: world name) |
DrainPlayerFromWorldEvent |
String |
No | Player removed from world (key: world name) |
| Event | Key Type | Cancellable | Description |
|---|---|---|---|
EntityRemoveEvent |
- | No | Entity is removed |
LivingEntityInventoryChangeEvent |
- | No | Entity inventory changed |
LivingEntityUseBlockEvent |
String |
No | Entity uses a block |
| Event | Key Type | Cancellable | Description |
|---|---|---|---|
AddWorldEvent |
String |
Yes | World is being added |
RemoveWorldEvent |
String |
No | World is being removed |
StartWorldEvent |
String |
No | World has started |
AllWorldsLoadedEvent |
String |
No | All worlds finished loading |
ChunkPreLoadProcessEvent |
- | No | Before chunk loading |
ChunkSaveEvent |
- | No | Chunk being saved (ECS) |
ChunkUnloadEvent |
- | No | Chunk being unloaded (ECS) |
MoonPhaseChangeEvent |
- | No | Moon phase changed (ECS) |
WorldPathChangedEvent |
Void |
No | World path changed |
| Event | Key Type | Description |
|---|---|---|
PlayerPermissionChangeEvent |
Void |
Player permission changed |
GroupPermissionChangeEvent |
Void |
Group permission changed |
PlayerGroupEvent |
Void |
Player group membership changed |
| Event | Key Type | Description |
|---|---|---|
PluginSetupEvent |
Class<? extends PluginBase> |
Plugin is being set up |
| Event | Description |
|---|---|
PrefabPasteEvent |
Prefab is being pasted |
PrefabPlaceEntityEvent |
Entity placed from prefab |
| Event | Key Type | Description |
|---|---|---|
AssetPackRegisterEvent |
Void |
Asset pack registered |
AssetPackUnregisterEvent |
Void |
Asset pack unregistered |
LoadAssetEvent |
Void |
Asset loaded |
GenerateSchemaEvent |
Void |
Schema generation |
CommonAssetMonitorEvent |
- | Common asset monitoring |
SendCommonAssetsEvent |
- | Sending common assets |
| Event | Module | Description |
|---|---|---|
GenerateDefaultLanguageEvent |
i18n | Default language generation |
CombatTextUIComponentAnimationEvent |
Entity UI | Combat text animation |
CombatTextUIComponentOpacityAnimationEvent |
Entity UI | Combat text opacity |
CombatTextUIComponentPositionAnimationEvent |
Entity UI | Combat text position |
CombatTextUIComponentScaleAnimationEvent |
Entity UI | Combat text scale |
KillFeedEvent |
Entity Damage | Kill feed notification |
SingleplayerRequestAccessEvent |
Singleplayer | Singleplayer access request |
Located in server/core/event/events/ecs/
These events extend EcsEvent or CancellableEcsEvent and are dispatched through the Entity Component System.
| Event | Cancellable | Description |
|---|---|---|
BreakBlockEvent |
Yes | Block is being broken |
PlaceBlockEvent |
Yes | Block is being placed |
DamageBlockEvent |
Yes | Block is being damaged |
UseBlockEvent |
No | Block is being used |
UseBlockEvent.Pre |
Yes | Before block use (cancellable) |
DropItemEvent |
Yes | Item is being dropped |
InteractivelyPickupItemEvent |
Yes | Item is being picked up |
SwitchActiveSlotEvent |
Yes | Active slot is being switched |
ChangeGameModeEvent |
Yes | Game mode is being changed |
CraftRecipeEvent |
Yes | Recipe is being crafted |
DiscoverZoneEvent |
No | Zone discovered |
DiscoverZoneEvent.Display |
Yes | Zone discovery display |
Located in assetstore/event/
| Event | Key Type | Description |
|---|---|---|
RegisterAssetStoreEvent |
Void |
Asset store registered |
RemoveAssetStoreEvent |
Void |
Asset store removed |
GenerateAssetsEvent<T> |
Asset type | Assets generated |
LoadedAssetsEvent<T> |
Asset type | Assets loaded |
RemovedAssetsEvent<T> |
Asset type | Assets removed |
AssetMonitorEvent |
- | Asset monitoring |
AssetStoreMonitorEvent |
- | Store monitoring |
AssetsEvent |
- | Generic assets event |
Located in builtin/asseteditor/event/
| Event | Key Type | Async | Description |
|---|---|---|---|
AssetEditorActivateButtonEvent |
String (buttonId) |
No | Button activated |
AssetEditorAssetCreatedEvent |
Asset type ID | No | Asset created |
AssetEditorClientDisconnectEvent |
- | No | Client disconnected |
AssetEditorFetchAutoCompleteDataEvent |
Dataset name | Yes | Fetch autocomplete |
AssetEditorRequestDataSetEvent |
Dataset name | Yes | Request dataset |
AssetEditorSelectAssetEvent |
- | No | Asset selected |
AssetEditorUpdateWeatherPreviewLockEvent |
- | No | Weather preview lock |
Located in builtin/instances/ and builtin/adventure/
| Event | Key Type | Description |
|---|---|---|
DiscoverInstanceEvent |
- | Instance discovered (ECS) |
DiscoverInstanceEvent.Display |
- | Instance discovery display (cancellable) |
TreasureChestOpeningEvent |
String (world name) |
Treasure chest opening |
VoidEvent |
- | Void event (ECS) |
Located in protocol/
These events handle client-server communication.
| Event | Description |
|---|---|
SoundEvent |
Sound playback |
BlockSoundEvent |
Block-related sound |
ItemSoundEvent |
Item-related sound |
BlockParticleEvent |
Block particle effects |
MouseButtonEvent |
Mouse button input packet |
MouseMotionEvent |
Mouse motion input packet |
CombatTextEntityUIComponentAnimationEvent |
Combat text animation packet |
ItemReticleClientEvent |
Item reticle update |
CustomPageEvent |
Custom UI page event |
ReticleEvent |
Reticle state event |
Located in server/npc/
| Event | Description |
|---|---|
SensorEvent |
Base sensor event |
SensorEntityEvent |
Entity-based sensor event |
BuilderSensorEvent |
Builder-pattern sensor config |
BuilderSensorEntityEvent |
Builder-pattern entity sensor |
AllNPCsLoadedEvent |
All NPCs finished loading |
LoadedNPCEvent |
Single NPC loaded |
Sensor Event Types:
| Type | Description |
|---|---|
PlayerFirst |
Player takes priority |
PlayerOnly |
Only players trigger |
NpcFirst |
NPC takes priority |
NpcOnly |
Only NPCs trigger |
Located in component/system/
| Class | Purpose |
|---|---|
EcsEvent |
Base for all ECS events |
CancellableEcsEvent |
Cancellable ECS events |
ICancellableEcsEvent |
Interface for cancellable ECS events |
EventSystemType<ECS_TYPE, Event, SYSTEM_TYPE> |
Event system type registration |
WorldEventType<ECS_TYPE, Event> |
World-scoped event system |
EntityEventType<ECS_TYPE, Event> |
Entity-scoped event system |
| Handler | Events |
|---|---|
ObjectivePlugin |
PlayerDisconnectEvent |
BuilderToolsPlugin |
PlayerConnectEvent, PlayerDisconnectEvent
|
CreativeHubPlugin |
PlayerConnectEvent (global) |
InstancesPlugin |
PlayerConnectEvent |
MountPlugin |
PlayerDisconnectEvent |
ServerPlayerListModule |
PlayerConnectEvent, PlayerDisconnectEvent
|
AssetEditorPlugin |
All AssetEditor* events |
CraftingManager |
PlayerCraftEvent (world-keyed) |
| Module | Events |
|---|---|
AssetModule |
BootEvent |
MigrationModule |
BootEvent |
PermissionsModule |
Permission events |
InteractionModule |
Block interaction events |
I18nModule |
GenerateDefaultLanguageEvent |
SingleplayerModule |
SingleplayerRequestAccessEvent |
| Handler | Events |
|---|---|
AssetEditorPacketHandler |
AssetEditor* events (sync/async) |
GamePacketHandler |
Input events |
SetupPacketHandler |
Setup events |