Void includes a full command system with typed argument parsing, flag support, auto-generated usage strings, and client-side tab-completion via the Minecraft protocol command tree.
Build commands using the fluent CommandBuilder:
| Method | Description |
|---|---|
new(name) |
Create a command with the given name |
description(desc) |
Set the help description |
alias(alias) |
Add an alternative name (can be called multiple times) |
usage(usage) |
Set a custom usage string (overrides auto-generation) |
arg(name, parser) |
Add a required typed argument |
arg_optional(name, parser) |
Add an optional typed argument |
arg_variadic(name, parser) |
Add an optional variadic argument (consumes all remaining tokens; must be last) |
arg_variadic_required(name, parser) |
Add a required variadic argument (at least one token; must be last) |
flag(long, short, description) |
Add a boolean flag (--long / -s) |
flag_value(long, short, desc, parser) |
Add a flag that takes a typed value (--long value) |
handler(fn) |
Set the handler function |
build() |
Consume the builder and produce a Command |
The CommandContext is passed to every command handler, providing access to the ECS world and helper methods:
| Method | Return Type | Description |
|---|---|---|
get::<T>(name) |
Option<&T> |
Get a parsed argument by name and type |
has_arg(name) |
bool |
Check if an optional argument was provided |
flag(name) |
bool |
Check if a boolean flag is set |
flag_value::<T>(name) |
Option<&T> |
Get a typed flag value |
reply(message) |
() |
Send a white system message to the sender |
reply_error(message) |
() |
Send a red error message to the sender |
broadcast(message) |
() |
Send a system message to all ready players |
player_name() |
Option<String> |
Get the sender's player name |
is_operator() |
bool |
Check if the sender has the Operator component |
Built-in parsers that implement the ArgParser trait:
| Parser | Parsed Type | Protocol Hint | Description |
|---|---|---|---|
StringArg::single_word() |
String |
SingleWord |
Single whitespace-delimited word |
StringArg::quotable() |
String |
QuotablePhrase |
Quoted or single word |
StringArg::greedy() |
String |
GreedyPhrase |
All remaining input |
IntegerArg::new(min, max) |
i32 |
Integer { min, max } |
Bounded integer |
IntegerArg::unbounded() |
i32 |
Integer |
Unbounded integer |
LongArg::new(min, max) |
i64 |
Long { min, max } |
Bounded long integer |
LongArg::unbounded() |
i64 |
Long |
Unbounded long |
FloatArg::new(min, max) |
f32 |
Float { min, max } |
Bounded float |
FloatArg::unbounded() |
f32 |
Float |
Unbounded float |
DoubleArg::new(min, max) |
f64 |
Double { min, max } |
Bounded double |
DoubleArg::unbounded() |
f64 |
Double |
Unbounded double |
BoolArg |
bool |
Bool |
Accepts true/false/yes/no/1/0 |
GreedyStringArg |
String |
GreedyPhrase |
All remaining input as text |
GameProfileArg |
String |
GameProfile |
Player name with tab-completion (minecraft:ask_server) |
EntityArg::single_player() |
String |
Entity { single, players_only } |
Entity selector |
MessageArg |
String |
Message |
Chat message argument |
Implement the ArgParser trait to create custom argument types:
Flags are parsed in a pre-pass before positional arguments:
--flag — Boolean flag (sets to true)--flag value — Value flag (parsed with the flag's ArgParser)-f — Short boolean flag-f value — Short value flag (must be standalone, not combined)-- — Stop flag parsing; everything after is positionalExample:
Register all built-in commands with register_default_commands:
Pass command names in the exclude slice to skip specific defaults:
| Command | Aliases | Description | Arguments |
|---|---|---|---|
/help |
List commands or show command details | [command:string] |
|
/gamemode |
/gm |
Change game mode | <mode:integer(0..3)> |
/kick |
Kick a player | <player:player> [reason:text]... |
|
/ping |
Pong! | (none) | |
/plugins |
/pl |
List loaded plugins | (none) |
/tp |
Teleport to coordinates | <x:double> <y:double> <z:double> |
|
/broadcast |
Broadcast to all players | <message:text>... |
|
/tell |
/msg |
Private message a player | <player:player> <message:text>... |
/list |
Show online players | (none) | |
/say |
Send a message as yourself | <message:text>... |
The /plugins command reads from an optional PluginList resource. Insert it in your plugin to make plugin names visible:
The server automatically builds a Minecraft protocol command tree from the CommandRegistry and sends it to clients during the configuration phase. This provides:
/ shows all commands)GameProfileArg arguments (via minecraft:ask_server)The command tree is rebuilt from the registry each time a client joins.
Commands can be registered in two ways:
add_command on VoidServeradd_plugin with direct registry access