🧔Parent commands
Every parent command must extend ParentCommand.
Parent command has three constructors.
First constructor
This constructor requires all parameters:
permission (first param)
hasArguments (second param)
onlyPlayers (third param)
usePermission (fourth param)
commandConfiguration (fifth param)
public MyCommand(CommandConfiguration commandConfiguration) {
super("minigame.admin", true, true, true, commandConfiguration);
}
Second constructor
This constructor requires four parameters:
permission (first param)
onlyPlayers (second param)
usePermission (third param)
commandConfiguration (fourth param)
hasArguments (in this constructor this field is set to false)
public MyCommand(CommandConfiguration commandConfiguration) {
super("minigame.admin", true, true, commandConfiguration);
}
Third constructor
This constructor doesn't have parameters,everything is set to default value like false, empty string and for configuration null.
The parent command class has three methods to implement:
excecuteCommand - executes command
getName - gets command name, this is so important for addons system
getTabCompleter - gets tab completer for command (Optional)
The whole implementation of the command class.
public class MyCommand extends ParentCommand {
public MyCommand (CommandConfiguration commandConfiguration) {
super("command.admin", true, true, true, commandConfiguration);
addSubCommand(new MySubCommand());
}
@Override
protected boolean executeCommand(CommandSender sender, String[] args) {
Player player = (Player) sender;
player.sendMessage("test");
return false;
}
@Override
public String getName() {
return "mycommand";
}
}