Skip to content

Registry System

Package: com.hypixel.hytale.registry (base) + com.hypixel.hytale.server.core.plugin.registry (plugin registries)

Hytale uses a three-layer registry architecture for managing plugin registrations with automatic lifecycle cleanup.

Registry<T extends Registration> provides lifecycle-aware registration:

  • Precondition checking — Registration only allowed when conditions are met (e.g., plugin not disabled)
  • Shutdown cleanup — All registrations automatically unregistered in LIFO order on shutdown
  • Enable/disable — Registries can be enabled and disabled independently
  • Registration wrapping — Returned handles include lifecycle management

Registration is the base handle class with isEnabled() and unregister() methods.

Each subsystem has a registry class that wraps domain-specific APIs:

RegistryExtendsDelegates To
EventRegistryRegistry<EventRegistration>EventBus
CommandRegistryRegistry<CommandRegistration>CommandManager
BlockStateRegistryRegistry<BlockStateRegistration>BlockStateModule
ComponentRegistryProxyimplements IComponentRegistryComponentRegistry
CodecMapRegistryimplements IRegistryStringCodecMapCodec
MapKeyMapRegistryimplements IRegistryMapKeyMapCodec
AssetRegistrystatic AssetRegistry

All follow the same pattern: delegate registration to a global backend while tracking cleanup callbacks for plugin shutdown.

Static singleton registries that hold the actual data:

  • EventBus — Global event dispatch
  • CommandManager — Singleton command dispatcher
  • ComponentRegistry<EntityStore> — Static shared ECS registry for entity components
  • ComponentRegistry<ChunkStore> — Static shared ECS registry for chunk components
  • AssetRegistry (at com.hypixel.hytale.assetstore) — Global asset store mapping

All registries are accessed through PluginBase methods:

MethodReturnsDomain
getEventRegistry()EventRegistryEvent listeners
getCommandRegistry()CommandRegistryCommands
getBlockStateRegistry()BlockStateRegistryCustom block states
getEntityRegistry()EntityRegistryEntity types
getTaskRegistry()TaskRegistryScheduled tasks
getEntityStoreRegistry()ComponentRegistryProxy<EntityStore>Entity ECS
getChunkStoreRegistry()ComponentRegistryProxy<ChunkStore>Chunk ECS
getAssetRegistry()AssetRegistryAsset stores
getCodecRegistry(StringCodecMapCodec)CodecMapRegistryString-keyed codecs
getCodecRegistry(AssetCodecMapCodec)CodecMapRegistry.AssetsAsset codecs
getCodecRegistry(MapKeyMapCodec)MapKeyMapRegistryClass-keyed codecs
getClientFeatureRegistry()ClientFeatureRegistryClient features
withConfig(BuilderCodec<T>)Config<T>Plugin JSON config
// 1. Plugin calls registry method
CommandRegistration reg = getCommandRegistry().registerCommand(myCommand);
// 2. Registry checks precondition (plugin not disabled)
// 3. Registry delegates to global backend (CommandManager.get().register(command))
// 4. Registry wraps result with lifecycle tracking
// 5. On plugin shutdown, all tracked registrations are unregistered in LIFO order

Assets are game data loaded from JSON files in asset packs. Key types:

  • AssetMap<K, T> — Storage and indexing layer for assets with key-based lookup, path tracking, and tag-based grouping
  • AssetStore — Manages loading/unloading for one asset type
  • AssetRegistry (static) — Maps asset classes to AssetStore instances

Plugin access: PluginBase.getAssetRegistry().register(assetStore)