Skip to content

Command Basics

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>

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.

ParameterTypeOptionalDescription
nameStringNoName of the command.
fallbackPrefixStringYesA prefix which is prepended to the command with a : one or more times to make the command unique.
permissionStringYesPermission required to execute the command.
aliasesString[]YesAlternative names for the command.
descStringYesBrief description of the command.
usageStringYesInstruction on how to use the command.
minIntegerYesMinimum number of required arguments.
maxIntegerYesMaximum number of allowed arguments. Use -1 for unlimited.
onlyOpBooleanYesWhether only operator players can run this command.
asyncBooleanYesIf true, executes the command in a new thread. Be careful with Bukkit API calls.
senderTypeSenderTypeYesType of sender allowed, such as BOTH, PLAYER, or CONSOLE.

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 segment
public void invalidCommand(CommandArguments arguments) {
}
@Completer(name = ".arena") // invalid: starts with a dot
public List<String> invalidCompleter() {
return List.of();
}
@Command(name = "arena-create") // invalid: hyphen is not supported
public void unsupportedCharacters(CommandArguments arguments) {
}