Skip to content

Command System

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

A builder-pattern command system with typed argument parsing, automatic permission generation, tab completion suggestions, usage variants, and subcommand support. Commands run on ForkJoinPool.commonPool().

Commands are defined by extending a base class and declaring arguments as fields using builder methods:

public class MyPlugin extends PluginBase {
@Override
protected void setup() {
getCommandRegistry().registerCommand(new MyCommand());
}
}
public class MyCommand extends CommandBase {
private final RequiredArg<PlayerRef> targetArg =
this.withRequiredArg("target", "Target player", ArgTypes.PLAYER_REF);
private final DefaultArg<Integer> countArg =
this.withDefaultArg("count", "Number of times", ArgTypes.INTEGER, 1, "1");
private final OptionalArg<String> reasonArg =
this.withOptionalArg("reason", "Optional reason", ArgTypes.STRING);
public MyCommand() {
super("mycommand", "Does something cool");
this.addAliases("mc");
}
@Override
protected void executeSync(CommandContext context) {
PlayerRef target = this.targetArg.get(context);
int count = this.countArg.get(context);
if (this.reasonArg.provided(context)) {
String reason = this.reasonArg.get(context);
}
context.sendMessage(Message.translation("myplugin.mycommand.success"));
}
}
ClassUse Case
CommandBaseMost commands — synchronous executeSync(CommandContext)
AbstractAsyncCommandAsync commands — executeAsync(CommandContext) returns CompletableFuture<Void>
AbstractPlayerCommandPlayer-only commands — auto-resolves sender to PlayerRef, Ref<EntityStore>, World
AbstractCommandCollectionSubcommand groups — shows usage listing when invoked without a subcommand
AbstractCommandCore base class — provides the builder API for all argument types

Declared as fields on the command class. Available on AbstractCommand:

MethodReturnsDescription
withRequiredArg(name, desc, ArgumentType<T>)RequiredArg<T>Must be provided
withOptionalArg(name, desc, ArgumentType<T>)OptionalArg<T>May be omitted
withDefaultArg(name, desc, ArgumentType<T>, T default, String defaultDesc)DefaultArg<T>Uses default if omitted
withFlagArg(name, desc)FlagArgBoolean flag
withListRequiredArg(name, desc, ArgumentType<T>)ListRequiredArg<T>Required list [a, b, c]
withListOptionalArg(name, desc, ArgumentType<T>)ListOptionalArg<T>Optional list
withListDefaultArg(name, desc, ArgumentType<T>, List<T> default, String defaultDesc)ListDefaultArg<T>Default list
NameJava TypeExamples
BOOLEANBooleantrue, false
INTEGERInteger-1, 0, 56346
STRINGString"Hytale is really cool!"
FLOATFloat3.14159, -2.5
DOUBLEDouble-3.14, 0.0
UUIDUUID<UUID>
COLORInteger (ARGB)#FF0000, 0xFF0000, 16711680
NameJava TypeDescription
PLAYER_UUIDUUIDResolves username to UUID
PLAYER_REFPlayerRefResolves username to PlayerRef
GAME_PROFILE_LOOKUPPublicGameProfileSync profile lookup
GAME_PROFILE_LOOKUP_ASYNCCompletableFuture<PublicGameProfile>Async profile lookup
NameJava TypeParamsDescription
RELATIVE_DOUBLE_COORDCoord1Single coordinate, ~ prefix for relative
RELATIVE_INT_COORDIntCoord1Integer coordinate, ~ prefix
RELATIVE_INTEGERRelativeInteger1Relative integer value, ~ prefix
RELATIVE_FLOATRelativeFloat1Relative float value, ~ prefix
VECTOR2IVector2i2Two integers (x z)
VECTOR3IVector3i3Three integers (x y z)
RELATIVE_VECTOR3IRelativeVector3i3Three optionally relative integers
RELATIVE_BLOCK_POSITIONRelativeIntPosition3Block position with ~ support
RELATIVE_POSITIONRelativeDoublePosition3Entity position with ~ support
RELATIVE_CHUNK_POSITIONRelativeChunkPosition2Chunk position with ~ support
ROTATIONVector3f3Pitch/yaw/roll
NameJava Type
BLOCK_TYPE_ASSETBlockType
ITEM_ASSETItem
MODEL_ASSETModelAsset
WEATHER_ASSETWeather
INTERACTION_ASSETInteraction
ROOT_INTERACTION_ASSETRootInteraction
EFFECT_ASSETEntityEffect
ENVIRONMENT_ASSETEnvironment
PARTICLE_SYSTEMParticleSystem
HITBOX_COLLISION_CONFIGHitboxCollisionConfig
REPULSION_CONFIGRepulsionConfig
SOUND_EVENT_ASSETSoundEvent
AMBIENCE_FX_ASSETAmbienceFX
NameJava TypeDescription
BLOCK_TYPE_KEYStringBlock type key (e.g., Wood_Drywood_Planks_Half)
BLOCK_IDIntegerBlock type key -> integer ID
WEIGHTED_BLOCK_TYPEPair<Integer, String>Weight + block type key
BLOCK_PATTERNBlockPatternWeighted block list [20%Rock_Stone, 80%Rock_Shale]
BLOCK_MASKBlockMaskBlock mask list [!Fluid_Water, >Grass_Full]
NameJava TypeDescription
INT_RANGEPair<Integer, Integer>Min max pair
RELATIVE_INT_RANGERelativeIntegerRangeRelative min max pair
INTEGER_COMPARISON_OPERATORIntegerComparisonOperator>, <, >=, <=, %, !%, =, !=
INTEGER_OPERATIONIntegerOperation+, -, *, /, %, =
NameJava TypeDescription
GAME_MODEGameModeGame mode enum
SOUND_CATEGORYSoundCategorySound category enum
ArgTypes.forEnum(name, Class<E>)EFactory for any enum type
TICK_RATEInteger (tps)Accepts 30tps, 33ms, or raw integer
ENTITY_IDUUIDEntity UUID reference

Permissions are auto-generated when a command is registered:

  • Plugin commands: plugin.getBasePermission() + ".command." + commandName
  • Built-in commands: "hytale.system.command." + commandName

Commands can declare additional permissions:

this.requirePermission("mycommand.admin");
this.setPermissionGroups("admin", "moderator");
this.setPermissionGroup(GameMode.Adventure); // available in adventure mode

hasPermission(CommandSender) checks sender.hasPermission(permission) and recurses up the parent command chain. All parents must also pass their permission checks.

Commands support multiple usage patterns via addUsageVariant(). Each variant is a separate AbstractCommand subclass with its own arguments and permissions:

/kill — kills self (AbstractPlayerCommand)
/kill <player> — kills target (CommandBase with RequiredArg<PlayerRef>)
/gamemode <mode> — sets own game mode
/gamemode <mode> <player> — sets another player's game mode

Commands can have named subcommands via addSubCommand(). AbstractCommandCollection is a convenience base that shows all subcommands when invoked without arguments.

58 built-in commands organized by category:

CategoryCommands
Playergamemode (gm), kill, give, sudo, refer, player (zone, camera), toggleblockplacementoverride, sleep
Serverkick, stop, who, maxplayers, auth (login, logout, status), update (Status, Cancel, Patchline, Download, Apply, Check), network, version
World/Entityentity (clone, remove, effect, count, dump, invulnerable, intangible, etc.), spawn, repulsion
World/Chunkchunk (load, unload, regenerate, info, lighting, etc.), stopnetworkchunksending
World Genworldgen (benchmark, reload)
Utilityhelp (?), teleport (tp), time, weather, say, message (msg), scoreboard, commands, bindings, tagpattern
Debugping, log, server (stats, gc, dump), packetstats, stresstest, assets, packs, hitdetection, debugplayerposition, messagetranslationtest, hudmanagertest, showbuildertoolshud, git
Builder Toolsfill, copy, paste, undo, redo, selection