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

public abstract class Command<T> extends Object
An abstract command class
  • Constructor Details

  • Method Details

    • getSpec

      public @NonNull CommandSpec getSpec()
      Gets the commands spec.
      Returns:
      the command spec
    • getName

      public @NonNull String getName()
      Gets the short name of this command

      The result should be appropriately capitalised.

      Returns:
      the command name
    • getPermission

      public @NonNull Optional<CommandPermission> getPermission()
      Gets the permission required by this command, if present
      Returns:
      the command permission
    • getArgumentCheck

      public @NonNull Predicate<Integer> 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

      public String getUsage()
      Gets the usage of this command. Will only return a non empty result for main commands.
      Returns:
      the usage of this command.
    • getArgs

      public Optional<List<Argument>> 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

      public List<String> tabComplete(LuckPermsPlugin plugin, Sender sender, ArgumentList args)
    • sendUsage

      public abstract void sendUsage(Sender sender, String label)
      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 to
      label - the label used when executing the command
    • sendDetailedUsage

      public abstract void sendDetailedUsage(Sender sender, String label)
      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 to
      label - the label used when executing the command
    • isAuthorized

      public boolean isAuthorized(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.
      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