CommandRegistration
CommandRegistration
Section titled “CommandRegistration”Package: com.hypixel.hytale.server.core.command.system
public class CommandRegistration extends RegistrationA registration handle for commands. Extends Registration with a reference to the AbstractCommand that was registered. Returned by CommandRegistry.registerCommand().
Fields
Section titled “Fields”@Nonnullprivate final AbstractCommand abstractCommandThe command instance that this registration wraps. Set during construction and not publicly accessible — the handle is used for lifecycle management (unregister(), isRegistered()), not for accessing the command.
Constructors
Section titled “Constructors”Primary constructor
Section titled “Primary constructor”public CommandRegistration(@Nonnull AbstractCommand command, @Nonnull BooleanSupplier isEnabled, @Nonnull Runnable unregister)Creates a new command registration for the given command.
- command — the AbstractCommand instance being registered.
- isEnabled — the owning registry’s enabled state supplier (from Registration).
- unregister — the callback that removes the command from the
CommandManager(from Registration).
Copy constructor
Section titled “Copy constructor”public CommandRegistration(@Nonnull CommandRegistration registration, @Nonnull BooleanSupplier isEnabled, @Nonnull Runnable unregister)Creates a new registration that copies the command reference from an existing CommandRegistration but uses new lifecycle callbacks. Used internally by CommandRegistry when wrapping a registration in the plugin-scoped lifecycle.
Inherited from Registration
Section titled “Inherited from Registration”This class inherits the following from Registration:
unregister()— removes the command from the server’sCommandManager. Idempotent and shutdown-safe.isRegistered()— returnstrueif not explicitly unregistered and the owning registry is still active.
See Registration — Lifecycle for the full state diagram.
Usage Example
Section titled “Usage Example”@Overrideprotected void setup() { CommandRegistry commands = getCommandRegistry();
// registerCommand() returns a CommandRegistration handle CommandRegistration reg = commands.registerCommand(new SpawnCommand());
// Check if still active if (reg.isRegistered()) { getLogger().info("Spawn command is registered."); }
// Manually unregister (optional -- auto-cleaned on plugin shutdown) reg.unregister();}Related Types
Section titled “Related Types”- Registration — base class providing lifecycle management (
unregister(),isRegistered()) - CommandRegistry — plugin-scoped registry whose
registerCommand()returnsCommandRegistrationhandles - AbstractCommand — base class for defining commands
- CommandBase — synchronous command convenience base class
- Registry — abstract registry managing registration lifecycle
- PluginBase — provides
getCommandRegistry() CommandManager— server-level command dispatcher- Command System Overview — full command system documentation