API Reference
This reference documents the core classes and interfaces in the Hytale server API. Use this alongside the Plugin Development Guide.
Hytale is in Early Access. This API reference is based on verified community documentation and may change. See HytaleDocs for updates.
Package Structure
| Package | Contains |
com.hypixel.hytale.server.core.plugin | JavaPlugin, PluginBase, JavaPluginInit |
com.hypixel.hytale.server.core.event | EventBus, EventPriority, IEvent, ICancellable |
com.hypixel.hytale.server.core.event.events | Player events (Connect, Chat, etc.) |
com.hypixel.hytale.server.core.prefab.event | Block events (Break, Place, etc.) |
com.hypixel.hytale.server.core.command | Commands, CommandContext |
com.hypixel.hytale.server.core.universe.world.events | World/chunk events |
JavaPlugin Class
Base class for all Hytale plugins. Located in com.hypixel.hytale.server.core.plugin.
Class Definition
public abstract class JavaPlugin extends PluginBase {
public JavaPlugin(@Nonnull JavaPluginInit init);
// Lifecycle methods
public void setup(); // Register systems, load configs
public void start(); // Register events, commands
public void shutdown(); // Save data, cleanup
// Registry access
public EventRegistry getEventRegistry();
public CommandRegistry getCommandRegistry();
public TaskRegistry getTaskRegistry();
public EntityStoreRegistry getEntityStoreRegistry();
// Utilities
public HytaleLogger getLogger();
public Path getDataDirectory();
public <T> T withConfig(String filename, Codec<T> codec);
}
EventBus
The EventBus handles all event registration and dispatch. Access via HytaleServer.get().getEventBus() or getEventRegistry().
Event Interfaces
| Interface | Description |
IBaseEvent<KeyType> | Root interface for all events |
IEvent<KeyType> | Synchronous events |
IAsyncEvent<KeyType> | Asynchronous events |
ICancellable | Events that can be cancelled |
Registration Methods
EventBus Registration
// Basic registration
eventBus.register(EventClass.class, event -> { ... });
// With priority
eventBus.register(EventPriority.FIRST, EventClass.class, event -> { ... });
// With custom priority value
eventBus.register((short) -1000, EventClass.class, event -> { ... });
// Key-based registration
eventBus.register(EventClass.class, keyValue, event -> { ... });
// Global handler (all keys)
eventBus.registerGlobal(EventClass.class, event -> { ... });
// Fallback handler (when no other handler handles it)
eventBus.registerUnhandled(EventClass.class, event -> { ... });
// Async registration
eventBus.registerAsync(EventClass.class, future -> {
return future.thenApply(event -> {
// Process async
return event;
});
});
Dispatch Methods
Dispatching Events
// Synchronous dispatch
eventBus.dispatchFor(MyEvent.class).dispatch(new MyEvent());
// Dispatch with key
eventBus.dispatchFor(MyEvent.class, keyValue).dispatch(new MyEvent());
// Async dispatch (returns CompletableFuture)
CompletableFuture<MyEvent> future = eventBus.dispatchForAsync(MyEvent.class).dispatch(event);
// Check if handlers exist
boolean hasHandlers = eventBus.hasListener(MyEvent.class);
EventPriority Enum
| Constant | Value | Order |
FIRST | -21844 | Runs first (highest priority) |
EARLY | -10922 | Runs early |
NORMAL | 0 | Default |
LATE | 10922 | Runs late |
LAST | 21844 | Runs last (lowest priority) |
EventRegistration
Managing Registrations
// Store registration for later
EventRegistration reg = eventBus.register(MyEvent.class, handler);
// Unregister
reg.unregister();
// Check if enabled
boolean active = reg.isEnabled();
// Combine multiple registrations
EventRegistration combined = EventRegistration.combine(reg1, reg2, reg3);
Player Events
Located in com.hypixel.hytale.server.core.event.events.
| Event | Type | Cancellable | Description |
PlayerSetupConnectEvent | Sync | Yes | Before player connection |
PlayerConnectEvent | Sync | No | Player connected |
PlayerSetupDisconnectEvent | Sync | No | Before disconnect |
PlayerDisconnectEvent | Sync | No | Player disconnected |
AddPlayerToWorldEvent | Sync | No | Player added to world |
DrainPlayerFromWorldEvent | Sync | No | Player removed from world |
PlayerReadyEvent | Sync | No | Player fully loaded |
PlayerChatEvent | Async | Yes | Chat message sent |
PlayerInteractEvent | Sync | Yes | Player interaction |
PlayerCraftEvent | Sync | No | Item crafted |
PlayerMouseButtonEvent | Sync | Yes | Mouse button pressed |
PlayerMouseMotionEvent | Sync | Yes | Mouse moved |
Block Events (ECS)
Block events use the Entity Component System. Located in com.hypixel.hytale.server.core.prefab.event.
| Event | Cancellable | Description |
BreakBlockEvent | Yes | Block is broken |
PlaceBlockEvent | Yes | Block is placed |
DamageBlockEvent | Yes | Block takes damage |
UseBlockEvent.Pre | Yes | Before using block |
UseBlockEvent.Post | No | After using block |
Item Events
| Event | Cancellable | Description |
DropItemEvent.PlayerRequest | Yes | Player requests to drop item |
DropItemEvent.Drop | Yes | Item is dropped |
InteractivelyPickupItemEvent | Yes | Item picked up |
SwitchActiveSlotEvent | Yes | Hotbar slot changed |
CraftRecipeEvent.Pre | Yes | Before crafting |
CraftRecipeEvent.Post | No | After crafting |
Server Events
| Event | Description |
BootEvent | Server starting up |
ShutdownEvent | Server shutting down |
PrepareUniverseEvent | Universe being prepared |
ShutdownEvent Priorities
Built-in Shutdown Priorities
ShutdownEvent.DISCONNECT_PLAYERS = -48 // First: disconnect players
ShutdownEvent.UNBIND_LISTENERS = -40 // Then: unbind listeners
ShutdownEvent.SHUTDOWN_WORLDS = -32 // Finally: shutdown worlds
World Events
Located in com.hypixel.hytale.server.core.universe.world.events.
| Event | Description |
AddWorldEvent | World added to universe |
RemoveWorldEvent | World removed |
StartWorldEvent | World started |
ChunkPreLoadProcessEvent | Before chunk loads |
ChunkSaveEvent | Chunk saved |
ChunkUnloadEvent | Chunk unloaded |
Permission Events
| Event | Description |
PlayerPermissionChangeEvent.PermissionsAdded | Permissions added to player |
PlayerPermissionChangeEvent.PermissionsRemoved | Permissions removed |
PlayerPermissionChangeEvent.GroupAdded | Player added to group |
PlayerPermissionChangeEvent.GroupRemoved | Player removed from group |
GroupPermissionChangeEvent.Added | Group permissions added |
GroupPermissionChangeEvent.Removed | Group permissions removed |
PlayerGroupEvent.Added | Player joined group |
PlayerGroupEvent.Removed | Player left group |
Commands
Located in com.hypixel.hytale.server.core.command.
Command Classes
| Class | Use For |
AbstractPlayerCommand | Commands that target players |
AbstractAsyncCommand | Async commands (database, network) |
CommandContext
CommandContext Methods
public interface CommandContext {
// Get the command sender
CommandSender getSender();
// Get player (if sender is player)
Player getPlayer();
// Get arguments
<T> T getArgument(String name, Class<T> type);
<T> T getArgumentOrDefault(String name, T defaultValue);
// Send messages
void sendMessage(String message);
void sendError(String message);
}
Entity Component System (ECS)
Hytale uses an ECS architecture based on Flecs.
Core ECS Types
| Type | Description |
Store<EntityStore> | Container for all entities/components |
Ref<EntityStore> | Reference to a single entity |
ArchetypeChunk<EntityStore> | Batch of entities with same components |
Query<EntityStore> | Filter entities by components |
CommandBuffer<EntityStore> | Deferred entity operations |
Component Access
Working with Components
// Get component from entity
MyComponent comp = entityRef.getComponent(MyComponent.class);
// Check if entity has component
boolean has = entityRef.hasComponent(MyComponent.class);
// Set component on entity
entityRef.setComponent(new MyComponent());
Math Types
| Type | Description |
Vector3d | 3D vector with double precision (positions) |
Vector3f | 3D vector with float precision |
Vector3i | 3D vector with integers (block coordinates) |
Inventory System
Inventory Classes
// Get player inventory
Inventory inventory = player.getInventory();
// ItemStack is immutable
ItemStack stack = inventory.getItem(slotIndex);
// Item IDs use namespace:name format
String itemId = "hytale:iron_sword";
Teleportation
Using TeleportComponent
// Get teleport component
TeleportComponent teleport = entity.getComponent(TeleportComponent.class);
// Set new position
teleport.setPosition(new Vector3d(x, y, z));
Configuration System
Loading Configuration
public class MyPlugin extends JavaPlugin {
private MyConfig config;
public MyPlugin(@Nonnull JavaPluginInit init) {
super(init);
// Load with Codec
this.config = withConfig("config.json", MyConfigCodec.INSTANCE);
// Or with custom filename
this.config = withConfig("settings.json", MyConfigCodec.INSTANCE);
}
}
Built-in Codecs
| Codec | Use For |
StringCodecMapCodec | String maps |
AssetCodecMapCodec | Asset references |
MapKeyMapCodec | Keyed maps |
Creating Custom Events
Synchronous Event
Java
public class MyCustomEvent implements IEvent<Void> {
private final String message;
public MyCustomEvent(String message) {
this.message = message;
}
public String getMessage() {
return message;
}
}
Cancellable Event
Java
public class PlayerTeleportEvent implements IEvent<Void>, ICancellable {
private final Player player;
private Vector3d destination;
private boolean cancelled = false;
public PlayerTeleportEvent(Player player, Vector3d destination) {
this.player = player;
this.destination = destination;
}
public Player getPlayer() { return player; }
public Vector3d getDestination() { return destination; }
public void setDestination(Vector3d dest) { this.destination = dest; }
@Override
public boolean isCancelled() { return cancelled; }
@Override
public void setCancelled(boolean cancelled) { this.cancelled = cancelled; }
}
Key-based Event
Java
public class PlayerScoreEvent implements IEvent<UUID> {
private final UUID playerId;
private final int score;
public PlayerScoreEvent(UUID playerId, int score) {
this.playerId = playerId;
this.score = score;
}
// Key for filtering
public UUID getPlayerId() { return playerId; }
public int getScore() { return score; }
}