Documentation Index
Fetch the complete documentation index at: https://mintlify.com/SparkUniverse/Essential-Mod/llms.txt
Use this file to discover all available pages before exploring further.
Creating Your First Command
To create a custom command, create a class or object that extendsCommand:
Kotlin vs Java
The Command API works in both Kotlin and Java. Here’s the same command in both languages:In Kotlin, it’s recommended to use
object instead of class for commands to ensure a single instance.Default Handler
The@DefaultHandler annotation marks a function to be invoked when:
- The command has no subcommands, OR
- The user didn’t specify a subcommand
@DefaultHandler is specified and no subcommand is matched, the command’s usage will be printed instead.
Command with Arguments
Arguments are automatically parsed based on your function parameters:Usage Examples
| User Input | Result |
|---|---|
/mycommand 5 | handle(5, null) |
/mycommand 5 true | handle(5, true) |
/mycommand 5 false | handle(5, false) |
/mycommand abc true | Error: Usage printed |
Auto-Generated Usage Messages
When a user provides invalid arguments, Essential automatically generates helpful usage messages:<required>- Required parameters[optional]- Optional parameters
Custom Parameter Names
If your build process wipes parameter names, or you want custom names in the usage message, use the@DisplayName annotation:
Command Configuration
Constructor Parameters
name
The command name. Your command will be invoked as/$name.
autoHelpSubcommand
Whether to automatically generate a help subcommand (i.e.,/$name help) that shows all available subcommands, their usages, and descriptions.
Default: true
hideFromAutocomplete
Whether to hide this command from Minecraft’s command tab completion. Default:false
Command Aliases
Define global aliases using thecommandAliases property:
Alias can optionally be hidden from autocomplete:
Complete Example
Here’s a complete example with multiple features:Next Steps
Arguments
Learn about the argument parsing system
Subcommands
Create complex command structures