Plugin Registries
Plugin Registries
Section titled “Plugin Registries”Hytale provides a registry system for plugins to register their components, events, commands, and other features. All registries are accessed through your plugin’s base class and automatically handle cleanup when your plugin is disabled.
Package Location
Section titled “Package Location”- Plugin base:
com.hypixel.hytale.server.core.plugin.PluginBase - Component registry:
com.hypixel.hytale.component.ComponentRegistryProxy - Event registry:
com.hypixel.hytale.event.EventRegistry - Command registry:
com.hypixel.hytale.server.core.command.system.CommandRegistry
Overview
Section titled “Overview”The following registries are available:
| Registry | Method | Purpose |
|---|---|---|
| Command Registry | getCommandRegistry() | Register commands |
| Event Registry | getEventRegistry() | Register event listeners |
| Entity Store Registry | getEntityStoreRegistry() | Register entity ECS components/systems |
| Chunk Store Registry | getChunkStoreRegistry() | Register chunk ECS components/systems |
| Block State Registry | getBlockStateRegistry() | Register custom block states |
| Entity Registry | getEntityRegistry() | Register entity types |
| Task Registry | getTaskRegistry() | Register scheduled tasks |
| Asset Registry | getAssetRegistry() | Register asset types |
| Client Feature Registry | getClientFeatureRegistry() | Register client feature flags |
| Codec Registry | getCodecRegistry(codec) | Register to codec maps |
For method tables, code examples, and details on each registry, see Existing Registries.
Plugin Utilities
Section titled “Plugin Utilities”In addition to registries, your plugin has access to these utility methods:
Logger
Section titled “Logger”HytaleLogger logger = getLogger();logger.at(Level.INFO).log("Plugin loaded!");logger.at(Level.WARNING).log("Something might be wrong");logger.at(Level.SEVERE).withCause(exception).log("Error occurred: %s", message);Data Directory
Section titled “Data Directory”Path dataDir = getDataDirectory();Path configFile = dataDir.resolve("custom-data.json");Identifier
Section titled “Identifier”PluginIdentifier id = getIdentifier();String fullId = id.toString(); // "Group/Name"Manifest
Section titled “Manifest”PluginManifest manifest = getManifest();String version = manifest.getVersion();String description = manifest.getDescription();Permissions
Section titled “Permissions”String basePerm = getBasePermission(); // "group.name"String myPerm = basePerm + ".myfeature"; // "group.name.myfeature"State Checking
Section titled “State Checking”if (isEnabled()) { // plugin is active (SETUP, START, or ENABLED states)}
if (isDisabled()) { // plugin is in NONE, SHUTDOWN, or DISABLED state}
PluginState state = getState();Automatic Cleanup
Section titled “Automatic Cleanup”All registrations are automatically cleaned up when your plugin shuts down, in reverse order of registration (LIFO). You don’t need to manually unregister event listeners, commands, ECS components, tasks, or codec registrations.
For details on the cleanup mechanism and shutdownAndCleanup(), see Creating Registries.
Best Practices
Section titled “Best Practices”- Register in
setup(): Perform all registrations in thesetup()method - Store references: Keep references to component/resource types for later use
- Use appropriate priorities: Choose event priorities based on your needs
- Let cleanup happen automatically: Don’t manually unregister unless necessary