endstone::Command
Represents a Command , which executes various tasks upon user input.
Functions:
Command
Command(std::string name, std::string description = "",
std::vector<std::string> usages = {},
std::vector<std::string> aliases = {},
std::vector<std::string> permissions = {}) asPluginCommand
PluginCommand *asPluginCommand() const execute
bool execute(CommandSender &sender, const std::vector<std::string> &args) constExecutes the command, returning its success
Parameters:
senderSource of the commandargsArguments passed to the command
Returns:
true if the execution was successful, otherwise false
getAliases
std::vector<std::string> getAliases() constReturns a list of aliases of this command
Returns:
List of aliases
getDescription
std::string getDescription() constGets a brief description of this command
Returns:
Description of this command
getName
std::string getName() constReturns the name of this command
Returns:
Name of this command
getPermissions
std::vector<std::string> getPermissions() constGets the permissions required by users to be able to perform this command
Returns:
List of permission names, or empty if none
getUsages
std::vector<std::string> getUsages() constReturns a list of usages of this command
Returns:
List of usages
isRegistered
bool isRegistered() constReturns the current registered state of this command
Returns:
true if this command is currently registered false otherwise
registerTo
bool registerTo(const CommandMap &command_map)Registers this command to a CommandMap.
Parameters:
command_mapthe CommandMap to register to
Returns:
true if the registration was successful, false otherwise
setAliases
template <typename... Alias> void setAliases(Alias... aliases)Sets the list of aliases to request on registration for this command.
Parameters:
aliasesaliases to register to this command
setDescription
void setDescription(std::string description)Sets a brief description of this command.
Parameters:
descriptionnew command description
setName
void setName(std::string name)Sets the name of this command.
May only be used before registering the command.
Parameters:
nameNew command name
setPermissions
template <typename... Permission> void setPermissions(Permission... permissions)Sets the permissions required by users to be able to perform this command
Parameters:
permissionsList of permission names
setUsages
template <typename... Usage> void setUsages(Usage... usages)Sets the usages of this command
Parameters:
usagesList of usages
testPermission
bool testPermission(const CommandSender &target) constTests the given CommandSender to see if they can perform this command. If they do not have permission, they will be informed that they cannot do this.
Parameters:
targetUser to test
Returns:
true if they can use it, otherwise false
testPermissionSilently
bool testPermissionSilently(const CommandSender &target) constTests the given CommandSender to see if they can perform this command. No error is sent to the sender.
Parameters:
targetUser to test
Returns:
true if they can use it, otherwise false
unregisterFrom
bool unregisterFrom(const CommandMap &command_map)Unregisters this command from a CommandMap
Parameters:
command_mapthe CommandMap to unregister from
Returns:
true if the unregistration was successful, false otherwise