Command Basics
Adding to Your Project
Section titled “Adding to Your Project”To add this project as a dependency, include the code below in your pom.xml, build.gradle or build.gradle.kts file.
<dependency> <groupId>dev.despical</groupId> <artifactId>command-framework</artifactId> <version>1.6.4</version></dependency>dependencies { implementation 'dev.despical:command-framework:1.6.4'}dependencies { implementation("dev.despical:command-framework:1.6.4")}Basic Command Parameters
Section titled “Basic Command Parameters”This section outlines the essential parameters you can use to define commands within the Command Framework. Each parameter allows for customization of command behavior and usage.
| Parameter | Type | Optional | Description |
|---|---|---|---|
| name | String | No | Name of the command. |
| fallbackPrefix | String | Yes | A prefix which is prepended to the command with a : one or more times to make the command unique. |
| permission | String | Yes | Permission required to execute the command. |
| aliases | String[] | Yes | Alternative names for the command. |
| desc | String | Yes | Brief description of the command. |
| usage | String | Yes | Instruction on how to use the command. |
| min | Integer | Yes | Minimum number of required arguments. |
| max | Integer | Yes | Maximum number of allowed arguments. Use -1 for unlimited. |
| onlyOp | Boolean | Yes | Whether only operator players can run this command. |
| async | Boolean | Yes | If true, executes the command in a new thread. Be careful with Bukkit API calls. |
| senderType | SenderType | Yes | Type of sender allowed, such as BOTH, PLAYER, or CONSOLE. |
Command Name Rules
Section titled “Command Name Rules”Command and completer names are validated when they are registered. The same rules also apply to aliases and runtime command attribute updates.
Valid names may contain:
- letters
- numbers
- underscores
- dots for sub-command paths
@Command(name = "arena.create")public void createArena(CommandArguments arguments) { arguments.sendMessage("<green>Arena created.");}
@Completer(name = "arena.create", aliases = {"arena_new"})public List<String> createArenaCompletion() { return List.of("example");}Invalid names are rejected with a CommandException.
@Command(name = "arena..create") // invalid: empty path segmentpublic void invalidCommand(CommandArguments arguments) {}
@Completer(name = ".arena") // invalid: starts with a dotpublic List<String> invalidCompleter() { return List.of();}
@Command(name = "arena-create") // invalid: hyphen is not supportedpublic void unsupportedCharacters(CommandArguments arguments) {}