Universe
Universe
Section titled “Universe”Package: com.hypixel.hytale.server.core.universe
public class Universe extends JavaPlugin implements IMessageReceiver, MetricProviderThe top-level container for all worlds and connected players on a Hytale server. Universe is a singleton — accessed via Universe.get() — and is itself a plugin (JavaPlugin), meaning it participates in the standard plugin lifecycle.
Universe manages the complete player connection flow: when a player connects, it creates the player entity, dispatches PlayerConnectEvent, and adds the player to a World. When a player disconnects, it dispatches PlayerDisconnectEvent and cleans up the player’s state.
Singleton Access
Section titled “Singleton Access”public static Universe get()Returns the singleton Universe instance. This is the primary entry point for accessing the world and player management APIs.
World Management
Section titled “World Management”Worlds are stored in a ConcurrentHashMap<String, World> keyed by world name.
Creating Worlds
Section titled “Creating Worlds”@Nonnull@CheckReturnValuepublic CompletableFuture<World> addWorld(@Nonnull String name)Creates and adds a new World with the given name using default configuration and save path. Returns a future that completes when the world is initialized and ready.
@Nonnull@CheckReturnValuepublic CompletableFuture<World> makeWorld(@Nonnull String name, @Nonnull Path savePath, @Nonnull WorldConfig worldConfig)Creates and adds a new World with explicit save path and configuration. This is the lower-level factory method that addWorld delegates to. Returns a future that completes when the world is initialized.
@Nonnull@CheckReturnValuepublic CompletableFuture<World> loadWorld(@Nonnull String name)Loads an existing World from disk by name. The world’s save directory and configuration are read from the server’s world storage. Returns a future that completes when the world is loaded and ready.
Querying Worlds
Section titled “Querying Worlds”@Nullablepublic World getWorld(@Nullable String worldName)Returns the World with the given name, or null if no such world exists. Returns null if worldName is null.
@Nullablepublic World getWorld(@Nonnull UUID uuid)Returns the World with the given UUID, or null if no such world exists.
@Nullablepublic World getDefaultWorld()Returns the default world (the world named "default"), or null if no default world has been created.
@Nonnullpublic Map<String, World> getWorlds()Returns an unmodifiable view of all worlds, keyed by name.
Removing Worlds
Section titled “Removing Worlds”public boolean removeWorld(@Nonnull String name)Removes a world by name. Players in the world should be drained first via World.drainPlayersTo(). Returns true if the world was found and removed.
Player Management
Section titled “Player Management”Connected players are stored in a ConcurrentHashMap<UUID, PlayerRef>.
Player Lookup
Section titled “Player Lookup”@Nonnullpublic List<PlayerRef> getPlayers()Returns a list of all currently connected PlayerRef instances.
@Nullablepublic PlayerRef getPlayer(@Nonnull UUID uuid)Returns the PlayerRef for the player with the given UUID, or null if the player is not connected.
@Nullablepublic PlayerRef getPlayer(@Nonnull String value, @Nonnull NameMatching matching)Returns the PlayerRef matching the given string value using the specified NameMatching strategy (exact match, case-insensitive, prefix, etc.). Returns null if no match is found.
public int getPlayerCount()Returns the number of currently connected players.
Player Lifecycle
Section titled “Player Lifecycle”public void removePlayer(@Nonnull PlayerRef playerRef)Disconnects a player from the server. Dispatches PlayerDisconnectEvent, removes the player from their current world, and cleans up the player’s state.
@Nonnullpublic CompletableFuture<PlayerRef> resetPlayer(@Nonnull PlayerRef oldPlayer)Resets a player’s state by creating a new PlayerRef with fresh ECS data while preserving the player’s network connection. The old player reference is invalidated and the new one takes its place. Returns a future that completes with the new PlayerRef.
Player Component Type
Section titled “Player Component Type”@Nonnullpublic ComponentType<EntityStore, PlayerRef> getPlayerRefComponentType()Returns the ComponentType used to store PlayerRef as a component on player entities in the entity store. This is the key for accessing a player’s PlayerRef through the ECS.
Messaging and Broadcasting
Section titled “Messaging and Broadcasting”@Overridepublic void sendMessage(@Nonnull Message message)Broadcasts a message to all connected players across all worlds. Implements IMessageReceiver. For world-scoped messaging, use World.sendMessage() instead.
public void broadcastPacket(@Nonnull Packet packet)Sends a raw network packet to all connected players. Lower-level than sendMessage — used for protocol-level broadcasts.
Storage
Section titled “Storage”public PlayerStorage getPlayerStorage()Returns the PlayerStorage instance responsible for persisting and loading player data.
public WorldConfigProvider getWorldConfigProvider()Returns the WorldConfigProvider that supplies world configuration data for world creation and loading.
Connection Flow
Section titled “Connection Flow”The complete player connection and disconnection sequence managed by Universe:
Connection
Section titled “Connection”Client connects --> Universe creates player entity (Holder<EntityStore>) --> PlayerSetupConnectEvent dispatched --> PlayerConnectEvent dispatched (world field is mutable) --> World.addPlayer(playerRef) called --> AddPlayerToWorldEvent dispatched --> PlayerReadyEvent dispatchedDisconnection
Section titled “Disconnection”Client disconnects (or server kicks) --> PlayerSetupDisconnectEvent dispatched --> PlayerDisconnectEvent dispatched --> Player removed from World --> DrainPlayerFromWorldEvent dispatched (if world transfer) --> Player state finalized and cleaned upRelated Types
Section titled “Related Types”- World — game world instances managed by Universe
- PlayerRef — persistent player reference managed per-connection
- PluginBase — base plugin class; Universe extends
JavaPluginwhich extendsPluginBase - Store — ECS store; each World has an EntityStore and ChunkStore
- ComponentType — type key for PlayerRef component access
- EventRegistry — event registration; Universe dispatches lifecycle events
PlayerConnectEvent— dispatched by Universe when a player connectsPlayerDisconnectEvent— dispatched by Universe when a player disconnectsPlayerSetupConnectEvent— dispatched early in connection before player entity existsPlayerSetupDisconnectEvent— dispatched early in disconnectionPrepareUniverseEvent— dispatched during Universe initializationAddPlayerToWorldEvent— dispatched when a player enters a worldDrainPlayerFromWorldEvent— dispatched when a player leaves a worldWorldConfig— configuration for world creationWorldConfigProvider— supplies world configurationsPlayerStorage— player data persistenceNameMatching— player lookup strategy enumPacket— network packet base typeJavaPlugin— concrete plugin base class that Universe extends