Mineserver
A rewrite of Minecraft 1.8.9 in C++ !
|
Commands Manager. More...
#include <commands.h>
Public Types | |
enum | CallCommandError { NONE , FORMAT , COMMAND_NOT_FOUND , RUNTIME_ERROR } |
Call command return code. More... | |
Public Member Functions | |
CommandsManager () | |
Construct a new Commands Manager object. | |
~CommandsManager () | |
Destroy the Commands Manager object. | |
void | addCommand (const std::string &name, Command::HandlerType handler, const std::string &usage="", const std::string &description="") |
Adds a command. | |
const std::unordered_map< std::string, Command > & | getCommands () const |
Get all registered commands. | |
CallCommandError | callCommand (ISender::SenderType type, ISender *sender, std::string commandString) |
Calls a command. | |
Static Public Member Functions | |
static void | loadLua (lua_State *state, const char *namespaceName) |
Register Lua things. | |
static CommandsManager & | inst () |
Gets Commands Manager instance. | |
Commands Manager.
The manager class for handling all commands logic.
Call command return code.
Enumerator | |
---|---|
NONE | No errors. |
FORMAT | Errors while parsing the command. |
COMMAND_NOT_FOUND | Command was not found. |
RUNTIME_ERROR | Error while running the command. |
void CommandsManager::addCommand | ( | const std::string & | name, |
Command::HandlerType | handler, | ||
const std::string & | usage = "", | ||
const std::string & | description = "" ) |
Adds a command.
Adds it by struct fields values.
name | see Command::name |
handler | Command::handler |
usage | Command::usage |
description | Command::description |
CommandsManager::CallCommandError CommandsManager::callCommand | ( | ISender::SenderType | type, |
ISender * | sender, | ||
std::string | commandString ) |
Calls a command.
type | the type of the sender that asked for the command |
sender | the sender |
commandString | the command string such as '/test info' |
Get all registered commands.
|
inlinestatic |
Gets Commands Manager instance.
Register Lua things.
state | state to register to |
namespaceName | namespace name |