Class BaseCommand
java.lang.Object
com.github.cyberryan1.cybercore.spigot.command.settings.CommandSettings
com.github.cyberryan1.cybercore.spigot.command.settings.BaseCommand
- Direct Known Subclasses:
CyberCommand
,CyberSubCommand
,CyberSuperCommand
The base structure of all other command classes.
Used to validate argument types, send messages, etc.
-
Constructor Summary
ConstructorsConstructorDescriptionBaseCommand
(String name, String usage) BaseCommand
(String name, String permission, String usage) BaseCommand
(String name, String permission, String permissionMsg, String usage) -
Method Summary
Modifier and TypeMethodDescriptiongetArgIndexes
(ArgType type) final ArgType
getArgType
(int index) final int
getStringArgOptions
(int index) final boolean
final boolean
void
sendInvalidDoubleArg
(org.bukkit.command.CommandSender sender, String arg) Sends that the argument provided isn't a doublevoid
sendInvalidIntegerArg
(org.bukkit.command.CommandSender sender, String arg) Sends that the argument provided isn't an integervoid
sendInvalidPlayerArg
(org.bukkit.command.CommandSender sender, String name) Sends that the name provided isn't any player's namevoid
sendPermissionMsg
(org.bukkit.command.CommandSender sender) Sends the permission message to the sendervoid
sendPermMsg
(org.bukkit.command.CommandSender sender) Sends the permission message to the sendervoid
sendUsage
(org.bukkit.command.CommandSender sender) Sends the usage message to the senderfinal void
setArgType
(int index, ArgType type) final void
setMinArgLength
(int length) final void
setSendValidationMsg
(boolean send) final void
setStringArgOptions
(int index, List<String> options) Important Notes: The index must be set toArgType.STRING
via thesetArgType(int, ArgType)
method, otherwise nothing will happen If the argument provided is invalid when checking via thevalidateArgument(CommandSender, String, int)
) method and theisSendingValidationMsg()
is true, then the usage of the command will be sentfinal void
setValidateArgs
(boolean validate) final boolean
validateArgument
(org.bukkit.command.CommandSender sender, String arg, int index) Validates that the argument provided is of the correct typeMethods inherited from class com.github.cyberryan1.cybercore.spigot.command.settings.CommandSettings
demandConsole, demandPermission, demandPlayer, getInvalidDoubleMsg, getInvalidIntegerMsg, getInvalidPlayerMsg, getName, getPermission, getPermissionMsg, getUsage, isDemandConsole, isDemandPermission, isDemandPlayer, isTabCompleteEnabled, permissionsAllowed, permsAllowed, runAsync, setDemandConsole, setDemandPermission, setDemandPlayer, setInvalidDoubleMsg, setInvalidIntegerMsg, setInvalidPlayerMsg, setRunAsync, setTabCompleteEnabled
-
Constructor Details
-
BaseCommand
-
BaseCommand
-
BaseCommand
-
-
Method Details
-
validateArgument
public final boolean validateArgument(org.bukkit.command.CommandSender sender, String arg, int index) Validates that the argument provided is of the correct type- Parameters:
sender
- The command senderarg
- The argumentindex
- The index of the argument- Returns:
- True if the argument is valid or if the argument is not of a type, false otherwise
-
sendPermissionMsg
public void sendPermissionMsg(org.bukkit.command.CommandSender sender) Sends the permission message to the sender- Parameters:
sender
- the sender of the command
-
sendPermMsg
public void sendPermMsg(org.bukkit.command.CommandSender sender) Sends the permission message to the sender- Parameters:
sender
- the sender of the command
-
sendUsage
public void sendUsage(org.bukkit.command.CommandSender sender) Sends the usage message to the sender- Parameters:
sender
- the sender of the command
-
sendInvalidPlayerArg
Sends that the name provided isn't any player's name- Parameters:
sender
- The person to send this message toname
- The attempted username
-
sendInvalidIntegerArg
Sends that the argument provided isn't an integer- Parameters:
sender
- The person to send this message toarg
- The attempted argument
-
sendInvalidDoubleArg
Sends that the argument provided isn't a double- Parameters:
sender
- The person to send this message toarg
- The attempted argument
-
getArgTypes
-
getArgType
- Parameters:
index
- The index of the argument to get- Returns:
- The
ArgType
of the argument at the given index
-
getArgIndexes
-
getStringArgOptions
- Returns:
- The
Map
of arg indexes that have been set asArgType.STRING
to the list of options for that argument
-
getStringArgOptions
- Parameters:
index
- The index of the argument to get- Returns:
- The
List
of strings that are valid for the argument at the given index
-
getMinArgLength
public final int getMinArgLength()- Returns:
- The minimum length of the arguments
-
isValidatingArgs
public final boolean isValidatingArgs()- Returns:
- True if the arguments are validated, false otherwise
-
isSendingValidationMsg
public final boolean isSendingValidationMsg()- Returns:
- True if the sender is sent a message when the arguments are invalid, false otherwise
-
setArgType
- Parameters:
index
- The index of the argument to settype
- TheArgType
to set the argument to
-
setStringArgOptions
Important Notes:-
The index must be set to
ArgType.STRING
via thesetArgType(int, ArgType)
method, otherwise nothing will happen -
If the argument provided is invalid when checking
via the
validateArgument(CommandSender, String, int)
) method and theisSendingValidationMsg()
is true, then the usage of the command will be sent
- Parameters:
index
- The index of the argument to setoptions
- TheList
of strings that are valid for that argument
-
The index must be set to
-
setMinArgLength
public final void setMinArgLength(int length) - Parameters:
length
- The minimum length of the arguments
-
setValidateArgs
public final void setValidateArgs(boolean validate) - Parameters:
validate
- True if the arguments are validated, false otherwise
-
setSendValidationMsg
public final void setSendValidationMsg(boolean send) - Parameters:
send
- True if the sender is sent a message when the arguments are invalid, false otherwise
-