Skip to content

Class endstone::Command

ClassList > endstone > Command

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

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

Inherits the following classes: endstone::Object

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 bool execute (CommandSender & sender, const std::vector< std::string > & args) const
Executes the command, returning its success.
std::vector< std::string > getAliases () const
Returns a list of aliases of this command.
virtual const std::type_info & getClassTypeId () override const
std::string getDescription () const
Gets a brief description of this command.
std::string getName () const
Returns the name of this command.
std::vector< std::string > getPermissions () const
Gets the permissions required by users to be able to perform this command.
std::vector< std::string > getUsages () const
Returns a list of usages of this command.
virtual bool isInstanceOf (const std::type_info & target) override const
bool isRegistered () const
Returns the current registered state of this command.
bool registerTo (const CommandMap & command_map)
Registers this command to a CommandMap .
void setAliases (Alias... aliases)
Sets the list of aliases to request on registration for this command.
void setDescription (std::string description)
Sets a brief description of this command.
void setName (std::string name)
Sets the name of this command.
void setPermissions (Permission... permissions)
Sets the permissions required by users to be able to perform this command.
void setUsages (Usage... usages)
Sets the usages of this command.
bool testPermission (const CommandSender & target) const
Tests the given CommandSender to see if they can perform this command.
bool testPermissionSilently (const CommandSender & target) const
Tests the given CommandSender to see if they can perform this command.
bool unregisterFrom (const CommandMap & command_map)
Unregisters this command from a CommandMap .
virtual ~Command () = default

Public Functions inherited from endstone::Object

See endstone::Object

Type Name
T * as ()
Attempts to cast this object to the given type T.
const T * as () const
Attempts to cast this object to the given type T.
virtual const std::type_info & getClassTypeId () const = 0
bool is () const
Checks if this object is an instance of the given type T (or a subclass of T).
virtual bool isInstanceOf (const std::type_info & target) const = 0
virtual ~Object () = 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 execute

Executes the command, returning its success.

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

Parameters:

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

Returns:

true if the execution was successful, otherwise false


function getAliases

Returns a list of aliases of this command.

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

Returns:

List of aliases


function getClassTypeId

inline virtual const std::type_info & endstone::Command::getClassTypeId () override const

Implements endstone::Object::getClassTypeId


function getDescription

Gets a brief description of this command.

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

Returns:

Description of this command


function getName

Returns the name of this command.

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

Returns:

Name of this command


function getPermissions

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

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

Returns:

List of permission names, or empty if none


function getUsages

Returns a list of usages of this command.

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

Returns:

List of usages


function isInstanceOf

inline virtual bool endstone::Command::isInstanceOf (
    const std::type_info & target
) override const

Implements endstone::Object::isInstanceOf


function isRegistered

Returns the current registered state of this command.

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

Returns:

true if this command is currently registered false otherwise


function registerTo

Registers this command to a CommandMap .

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

Parameters:

Returns:

true if the registration was successful, false otherwise


function setAliases

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

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

Parameters:

  • aliases aliases to register to this command

function setDescription

Sets a brief description of this command.

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

Parameters:

  • description new command description

function setName

Sets the name of this command.

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

May only be used before registering the command.

Parameters:

  • name New command name

function setPermissions

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

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

Parameters:

  • permissions List of permission names

function setUsages

Sets the usages of this command.

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

Parameters:

  • usages List of usages

function testPermission

Tests the given CommandSender to see if they can perform this command.

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

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

Tests the given CommandSender to see if they can perform this command.

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

No error is sent to the sender.

Parameters:

  • target User to test

Returns:

true if they can use it, otherwise false


function unregisterFrom

Unregisters this command from a CommandMap .

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

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