CommandBase
CommandBase
Section titled “CommandBase”Package:
com.hypixel.hytale.server.core.command.system.basecommands
Synchronous command base class. Wraps execute(CommandContext) to call executeSync(CommandContext) and return null (no future). Most simple commands extend this class.
Class Signature
Section titled “Class Signature”public abstract class CommandBase extends AbstractCommandConstructors
Section titled “Constructors”public CommandBase(@Nonnull String name, @Nonnull String description)Standard constructor with command name and description translation key.
public CommandBase(@Nonnull String name, @Nonnull String description, boolean requiresConfirmation)Constructor with confirmation flag — adds a --confirm flag that must be provided.
public CommandBase(@Nonnull String description)Description-only constructor for usage variant commands.
Abstract Methods
Section titled “Abstract Methods”protected abstract void executeSync(@Nonnull CommandContext var1);Implement this to define the command’s behavior. Called synchronously on ForkJoinPool.commonPool(). Use CommandContext to access parsed arguments, the sender, and send responses.
Implementation Detail
Section titled “Implementation Detail”@Nullable@Overrideprotected final CompletableFuture<Void> execute(@Nonnull CommandContext context) { this.executeSync(context); return null;}The execute() method is final — it delegates to executeSync() and returns null, signaling synchronous completion to the command dispatcher.
Example
Section titled “Example”public class KickCommand extends CommandBase { private final RequiredArg<PlayerRef> playerArg;
public KickCommand() { super("kick", "server.commands.kick.description"); this.playerArg = withRequiredArg("player", "server.commands.kick.player", ArgumentType.PLAYER_REF); }
@Override protected void executeSync(@Nonnull CommandContext context) { PlayerRef player = context.get(playerArg); player.disconnect(Message.raw("Kicked by " + context.sender().getDisplayName())); }}Related
Section titled “Related”- AbstractCommand — Parent class with full builder API
- CommandContext — Execution context
- Command System Overview — Full command system documentation