Commands
Last updated
Last updated
The command system is very flexible and efficient. It allows you to create commands without registering them in a plugin.yml and a few cool features to reduce boilerplate.
To create a command, you will need to create a class which extends games.negative.alumina.command.Command
, which is easily mistaken for org.bukkit.command.Command
, so be sure you're importing the correct one!
CommandProperties
The CommandProperties class is a builder for the command system, which gives you a lot of flexibility when designing your command properties with a vast array of options!
Here is a detailed description of all CommandProperties methods:
Method | Description |
---|---|
There are two ways of making a subcommand, so we will display how to do both.
Injecting a SubCommand is an alternative to creating a class to add a SubCommand, especially if the SubCommand is very short in lines of code; it will save time compared to creating an entirely new class for five lines of code, for example.
In what is considered the "normal" way of creating SubCommands, you need to create an entirely separate class to run your command logic. Then, in the constructor of your main command class, you register the subcommand.
Creating a subcommand class is exactly like a regular command!
As stated before, to register a subcommand, you just invoke the addSubCommand method in the main command class. Fun fact: You can also add subcommands to subcommand classes! It's a subcommand ception!
If you wish to add your custom tab completion logic, you're able to do so by overriding the onTabComplete()
method!
To register a command, you must go to your main class and invoke the registerCommand()
method.
name()
The name of the command.
description()
The description of the command.
usage()
The usage of the command.
aliases()
The aliases of the command.
permissions()
A list of permissions that only require the executor to have at least one to be allowed to use the command.
params()
A list of required parameters, or "arguments," for the command to execute correctly. The command will fail to execute if the executor has not completed the required parameters in their command.
shortcuts()
Used in subcommands to allow the subcommand to also be a primary command. An example is Essentials with /gamemode creative
and /gmc
. /gmc
being a "shortcut".
playerOnly()
When true, the command becomes "player only," meaning it can only be executed by players.
consoleOnly()
When true, the command becomes "console-only," meaning it can only be executed by non-player objects like the Console.
smartTabComplete()
When true, the command automatically takes all subcommands, parameters, etc, into account and displays your command in tab-completion.