java.lang.Object
me.github.simonplays15.betterbansystem.core.command.BaseCommand
Direct Known Subclasses:
BanCommand, BanListCommand, DelWarnCommand, IpBanCommand, KickCommand, LookUpCommand, MuteCommand, TimeBanCommand, UnbanCommand, UnbanIpCommand, UnmuteCommand, WarnCommand

public abstract class BaseCommand extends Object
The BaseCommand class represents a base command that can be executed by a command sender. Subclasses should extend this abstract class to implement their own specific commands.
  • Constructor Details

    • BaseCommand

      public BaseCommand (String commandName)
      Represents a base command.
      Parameters:
      commandName - The name of the command.
      Throws:
      InvalidDescriptionException - if the command name cannot be found in the plugin.yml file.
  • Method Details

    • testPermission

      public boolean testPermission (@NotNull @NotNull BaseCommandSender sender)
      Tests if the specified command sender has the required permission to execute the command.
      Parameters:
      sender - The command sender to test.
      Returns:
      true if the command sender has the required permission, false otherwise.
    • getAliases

      public List<String> getAliases()
      Returns the list of aliases associated with the command.
      Returns:
      the list of aliases
    • testPermission

      public boolean testPermission (@NotNull @NotNull BaseCommandSender sender, @NotNull @NotNull String permission)
      This method checks if a given command sender has the specified permission.
      Parameters:
      sender - The BaseCommandSender to test the permission for.
      permission - The permission string to check.
      Returns:
      True if the sender has the permission, false otherwise.
    • runCommand

      public abstract boolean runCommand (BaseCommandSender sender, String[] args) throws CommandException
      Executes the command.
      Parameters:
      sender - The command sender.
      args - The command arguments.
      Returns:
      true if the command executed successfully, false otherwise.
      Throws:
      CommandException - if a command encounters an error or exception.
    • onTabComplete

      public List<String> onTabComplete (BaseCommandSender sender, String @NotNull [] args)
      Generates a list of tab completion options for the given command.
      Parameters:
      sender - The command sender initiating the tab completion.
      args - The arguments provided after the command.
      Returns:
      A list of tab completion options.
    • getCommandName

      public String getCommandName()
      Retrieves the name of the command.
      Returns:
      The name of the command.
    • setCommandName

      public void setCommandName (String commandName)
      Sets the name of the command.
      Parameters:
      commandName - The name of the command to set.
    • getPermission

      public String getPermission()
      Retrieves the permission associated with this command.
      Returns:
      the permission associated with this command as a string
    • setPermission

      public void setPermission (String permission)
      Sets the permission for the command.
      Parameters:
      permission - the permission to set
    • getUsage

      public String getUsage()
      Retrieves the usage string of the command.
      Returns:
      the usage string with the label of the command
    • setUsage

      public void setUsage (String usage)
      Sets the usage of the command.
      Parameters:
      usage - the usage of the command
    • sendUsage

      public void sendUsage (@NotNull @NotNull BaseCommandSender sender)
      Sends the usage of the command to the specified sender.
      Parameters:
      sender - The base command sender.
    • setLabel

      public void setLabel (String label)
      Sets the label for a command.
      Parameters:
      label - the label to set
    • getDescription

      public String getDescription()
      Returns the description of the command.
      Returns:
      the description of the command.
    • setDescription

      public void setDescription (String description)
      Sets the description of the method.
      Parameters:
      description - the description to be set
    • getPermManager

      public PermissionsManager getPermManager()
      Retrieves the PermissionsManager instance associated with this BaseCommand.
      Returns:
      The PermissionsManager instance.
    • equals

      @Contract(value="null -> false", pure=true) public boolean equals (Object o)
      Compares this BaseCommand object with the specified object for equality.
      Overrides:
      equals in class Object
      Parameters:
      o - the object to compare with
      Returns:
      true if the specified object is equal to this BaseCommand; false otherwise
    • hashCode

      public int hashCode()
      Computes the hash code for this object.
      Overrides:
      hashCode in class Object
      Returns:
      the hash code value for this object.
    • toString

      public String toString()
      Returns a string representation of the BaseCommand object. The string includes the values of the commandName, manager, aliases, permission, description, usage, and label fields.
      Overrides:
      toString in class Object
      Returns:
      a string representation of the BaseCommand object