To extend the Leaf CLI with custom functionality, implement the LeafSubcommand interface. This interface allows you to define the execution logic, permission requirements, and tab-completion behavior for a new subcommand.
When implementing this interface, you must provide implementations for:
execute: The core logic triggered when the subcommand is called.getPermission: The Permission object required to run the command.testPermission: A check to verify if the CommandSender has the necessary permissions.
Optional:
tabComplete: Provides suggestions for command arguments during tab-completion.
public interface LeafSubcommand {
boolean execute(CommandSender sender, String subCommand, String[] args);
default List<String> tabComplete(final CommandSender sender, final String subCommand, final String[] args) {
return Collections.emptyList();
}
boolean testPermission(CommandSender sender);
Permission getPermission();
}