Skip to content

Class endstone::Command

ClassList > endstone > Command

Represents a Command , which executes various tasks upon user input.

  • #include <endstone/command/command.h>

Inherited by the following classes: endstone::PluginCommand

Public Functions

Type Name
Command (std::string name, std::string description="", std::vector< std::string > usages={}, std::vector< std::string > aliases={}, std::vector< std::string > permissions={})
virtual PluginCommand * asPluginCommand () const
virtual bool execute (CommandSender & sender, const std::vector< std::string > & args) const
std::vector< std::string > getAliases () const
std::string getDescription () const
std::string getName () const
std::vector< std::string > getPermissions () const
std::vector< std::string > getUsages () const
bool isRegistered () const
bool registerTo (CommandMap & command_map)
void setAliases (Alias... aliases)
void setDescription (std::string description)
void setName (std::string name)
void setPermissions (Permission... permissions)
void setUsages (Usage... usages)
bool testPermission (const CommandSender & target) const
bool testPermissionSilently (const CommandSender & target) const
bool unregisterFrom (const CommandMap & command_map)
virtual ~Command () = default

Public Functions Documentation

function Command

inline explicit endstone::Command::Command (
    std::string name,
    std::string description="",
    std::vector< std::string > usages={},
    std::vector< std::string > aliases={},
    std::vector< std::string > permissions={}
) 

function asPluginCommand

inline virtual PluginCommand * endstone::Command::asPluginCommand () const

function execute

inline virtual bool endstone::Command::execute (
    CommandSender & sender,
    const std::vector< std::string > & args
) const

Executes the command, returning its success

Parameters:

  • sender Source of the command
  • args Arguments passed to the command

Returns:

true if the execution was successful, otherwise false


function getAliases

inline std::vector< std::string > endstone::Command::getAliases () const

Returns a list of aliases of this command

Returns:

List of aliases


function getDescription

inline std::string endstone::Command::getDescription () const

Gets a brief description of this command

Returns:

Description of this command


function getName

inline std::string endstone::Command::getName () const

Returns the name of this command

Returns:

Name of this command


function getPermissions

inline std::vector< std::string > endstone::Command::getPermissions () const

Gets the permissions required by users to be able to perform this command

Returns:

List of permission names, or empty if none


function getUsages

inline std::vector< std::string > endstone::Command::getUsages () const

Returns a list of usages of this command

Returns:

List of usages


function isRegistered

inline bool endstone::Command::isRegistered () const

Returns the current registered state of this command

Returns:

true if this command is currently registered false otherwise


function registerTo

inline bool endstone::Command::registerTo (
    CommandMap & command_map
) 

Registers this command to a CommandMap.

Parameters:

Returns:

true if the registration was successful, false otherwise


function setAliases

template<typename... Alias>
inline void endstone::Command::setAliases (
    Alias... aliases
) 

Sets the list of aliases to request on registration for this command.

Parameters:

  • aliases aliases to register to this command

function setDescription

inline void endstone::Command::setDescription (
    std::string description
) 

Sets a brief description of this command.

Parameters:

  • description new command description

function setName

inline void endstone::Command::setName (
    std::string name
) 

Sets the name of this command.

May only be used before registering the command.

Parameters:

  • name New command name

function setPermissions

template<typename... Permission>
inline void endstone::Command::setPermissions (
    Permission... permissions
) 

Sets the permissions required by users to be able to perform this command

Parameters:

  • permissions List of permission names

function setUsages

template<typename... Usage>
inline void endstone::Command::setUsages (
    Usage... usages
) 

Sets the usages of this command

Parameters:

  • usages List of usages

function testPermission

inline bool endstone::Command::testPermission (
    const CommandSender & target
) const

Tests 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:

  • target User to test

Returns:

true if they can use it, otherwise false


function testPermissionSilently

inline bool endstone::Command::testPermissionSilently (
    const CommandSender & target
) const

Tests the given CommandSender to see if they can perform this command. No error is sent to the sender.

Parameters:

  • target User to test

Returns:

true if they can use it, otherwise false


function unregisterFrom

inline bool endstone::Command::unregisterFrom (
    const CommandMap & command_map
) 

Unregisters this command from a CommandMap

Parameters:

Returns:

true if the unregistration was successful, false otherwise


function ~Command

virtual endstone::Command::~Command () = default


The documentation for this class was generated from the following file include/endstone/command/command.h