Skip to content

CommandRegistration

Package: com.hypixel.hytale.server.core.command.system

public class CommandRegistration extends Registration

A registration handle for commands. Extends Registration with a reference to the AbstractCommand that was registered. Returned by CommandRegistry.registerCommand().

@Nonnull
private final AbstractCommand abstractCommand

The 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.

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).
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.

This class inherits the following from Registration:

  • unregister() — removes the command from the server’s CommandManager. Idempotent and shutdown-safe.
  • isRegistered() — returns true if not explicitly unregistered and the owning registry is still active.

See Registration — Lifecycle for the full state diagram.

@Override
protected 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();
}
  • Registration — base class providing lifecycle management (unregister(), isRegistered())
  • CommandRegistry — plugin-scoped registry whose registerCommand() returns CommandRegistration handles
  • 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