Class BaseCommand
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
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Compares thisBaseCommand
object with the specified object for equality.Returns the list of aliases associated with the command.Retrieves the name of the command.Returns the description of the command.Retrieves the permission associated with this command.Retrieves the PermissionsManager instance associated with this BaseCommand.getUsage()
Retrieves the usage string of the command.int
hashCode()
Computes the hash code for this object.onTabComplete
(BaseCommandSender sender, String @NotNull [] args) Generates a list of tab completion options for the given command.abstract boolean
runCommand
(BaseCommandSender sender, String[] args) Executes the command.void
sendUsage
(@NotNull BaseCommandSender sender) Sends the usage of the command to the specified sender.void
setCommandName
(String commandName) Sets the name of the command.void
setDescription
(String description) Sets the description of the method.void
Sets the label for a command.void
setPermission
(String permission) Sets the permission for the command.void
Sets the usage of the command.boolean
testPermission
(@NotNull BaseCommandSender sender) Tests if the specified command sender has the required permission to execute the command.boolean
testPermission
(@NotNull BaseCommandSender sender, @NotNull String permission) This method checks if a given command sender has the specified permission.toString()
Returns a string representation of the BaseCommand object.
-
Constructor Details
-
BaseCommand
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
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
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
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
Retrieves the name of the command.- Returns:
- The name of the command.
-
setCommandName
Sets the name of the command.- Parameters:
commandName
- The name of the command to set.
-
getPermission
Retrieves the permission associated with this command.- Returns:
- the permission associated with this command as a string
-
setPermission
Sets the permission for the command.- Parameters:
permission
- the permission to set
-
getUsage
Retrieves the usage string of the command.- Returns:
- the usage string with the label of the command
-
setUsage
Sets the usage of the command.- Parameters:
usage
- the usage of the command
-
sendUsage
Sends the usage of the command to the specified sender.- Parameters:
sender
- The base command sender.
-
setLabel
Sets the label for a command.- Parameters:
label
- the label to set
-
getDescription
Returns the description of the command.- Returns:
- the description of the command.
-
setDescription
Sets the description of the method.- Parameters:
description
- the description to be set
-
getPermManager
Retrieves the PermissionsManager instance associated with this BaseCommand.- Returns:
- The PermissionsManager instance.
-
equals
Compares thisBaseCommand
object with the specified object for equality. -
hashCode
public int hashCode()Computes the hash code for this object. -
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.
-