Class Command<T>
java.lang.Object
me.lucko.luckperms.common.command.abstraction.Command<T>
- Type Parameters:
T- the argument type required by the command
- Direct Known Subclasses:
ChildCommand,ParentCommand,SingleCommand
An abstract command class
-
Constructor Summary
ConstructorsConstructorDescriptionCommand(@NonNull CommandSpec spec, @NonNull String name, @Nullable CommandPermission permission, @NonNull Predicate<Integer> argumentCheck) -
Method Summary
Modifier and TypeMethodDescriptionabstract voidexecute(LuckPermsPlugin plugin, Sender sender, T target, ArgumentList args, String label) getArgs()Gets the arguments required by this commandGets the predicate used to validate the number of arguments provided to the command on executionnet.kyori.adventure.text.ComponentGets the commands description.getName()Gets the short name of this commandGets the permission required by this command, if presentgetSpec()Gets the commands spec.getUsage()Gets the usage of this command.booleanisAuthorized(Sender sender) Returns true if the sender is authorised to use this command Commands with children are likely to override this method to check for permissions based upon whether a sender has access to any sub commands.abstract voidsendDetailedUsage(Sender sender, String label) Sends a detailed command usage message to the Sender.abstract voidSends a brief command usage message to the Sender.booleanGets if this command should be displayed in command listings, or "hidden"tabComplete(LuckPermsPlugin plugin, Sender sender, ArgumentList args)
-
Constructor Details
-
Command
public Command(@NonNull CommandSpec spec, @NonNull String name, @Nullable CommandPermission permission, @NonNull Predicate<Integer> argumentCheck)
-
-
Method Details
-
getSpec
Gets the commands spec.- Returns:
- the command spec
-
getName
Gets the short name of this commandThe result should be appropriately capitalised.
- Returns:
- the command name
-
getPermission
Gets the permission required by this command, if present- Returns:
- the command permission
-
getArgumentCheck
Gets the predicate used to validate the number of arguments provided to the command on execution- Returns:
- the argument checking predicate
-
getDescription
public net.kyori.adventure.text.Component getDescription()Gets the commands description.- Returns:
- the description
-
getUsage
Gets the usage of this command. Will only return a non empty result for main commands.- Returns:
- the usage of this command.
-
getArgs
Gets the arguments required by this command- Returns:
- the commands arguments
-
execute
public abstract void execute(LuckPermsPlugin plugin, Sender sender, T target, ArgumentList args, String label) throws CommandException - Throws:
CommandException
-
tabComplete
-
sendUsage
Sends a brief command usage message to the Sender. If this command has child commands, the children are listed. Otherwise, a basic usage message is sent.- Parameters:
sender- the sender to send the usage tolabel- the label used when executing the command
-
sendDetailedUsage
Sends a detailed command usage message to the Sender. If this command has child commands, nothing is sent. Otherwise, a detailed messaging containing a description and argument usage is sent.- Parameters:
sender- the sender to send the usage tolabel- the label used when executing the command
-
isAuthorized
Returns true if the sender is authorised to use this command Commands with children are likely to override this method to check for permissions based upon whether a sender has access to any sub commands.- Parameters:
sender- the sender- Returns:
- true if the sender has permission to use this command
-
shouldDisplay
public boolean shouldDisplay()Gets if this command should be displayed in command listings, or "hidden"- Returns:
- if the command should be displayed
-