11#ifndef MINESERVER_COMMANDS_H
12#define MINESERVER_COMMANDS_H
14#include <unordered_map>
55 static void loadLua(lua_State *state,
const char *namespaceName);
58#ifndef DOXYGEN_IGNORE_THIS
60struct luabridge::Stack<
ISender::SenderType>
61 : luabridge::Enum<ISender::SenderType,
62 ISender::SenderType::CONSOLE,
63 ISender::SenderType::PLAYER,
64 ISender::SenderType::COMMAND_BLOCK>
140 std::unordered_map<std::string, Command> commands;
167 const std::string &usage =
"",
168 const std::string &description =
"");
175 const std::unordered_map<std::string, Command> &
getCommands()
const
223 static void loadLua(lua_State *state,
const char *namespaceName);
236#ifndef DOXYGEN_IGNORE_THIS
239 : luabridge::Enum<CommandsManager::CallCommandError,
240 CommandsManager::CallCommandError::NONE,
241 CommandsManager::CallCommandError::FORMAT,
242 CommandsManager::CallCommandError::COMMAND_NOT_FOUND,
243 CommandsManager::CallCommandError::RUNTIME_ERROR>
The file containing minecraft chat message implementation.
Minecraft Chat Message implementation.
Definition chatmessage.h:28
Commands Manager.
Definition commands.h:138
void addCommand(const std::string &name, Command::HandlerType handler, const std::string &usage="", const std::string &description="")
Adds a command.
Definition commands.cpp:25
CommandsManager()
Construct a new Commands Manager object.
Definition commands.cpp:7
static void loadLua(lua_State *state, const char *namespaceName)
Register Lua things.
Definition commands.cpp:97
~CommandsManager()
Destroy the Commands Manager object.
Definition commands.cpp:17
CallCommandError
Call command return code.
Definition commands.h:185
@ COMMAND_NOT_FOUND
Command was not found.
Definition commands.h:200
@ NONE
No errors.
Definition commands.h:190
@ FORMAT
Errors while parsing the command.
Definition commands.h:195
@ RUNTIME_ERROR
Error while running the command.
Definition commands.h:205
CallCommandError callCommand(ISender::SenderType type, ISender *sender, std::string commandString)
Calls a command.
Definition commands.cpp:50
static CommandsManager & inst()
Gets Commands Manager instance.
Definition commands.h:230
const std::unordered_map< std::string, Command > & getCommands() const
Get all registered commands.
Definition commands.h:175
Sender Interface.
Definition commands.h:29
virtual void sendMessage(const ChatMessage &message)=0
Sends a message to the sender.
static void loadLua(lua_State *state, const char *namespaceName)
Register Lua things.
Definition commands.cpp:115
SenderType
Sender type.
Definition commands.h:38
Command struct.
Definition commands.h:76
std::function< void(const ISender::SenderType, ISender &, const std::vector< std::string > &) HandlerType)
Function handler type.
Definition commands.h:121
std::string usage
The usage of the command.
Definition commands.h:106
std::string description
The description of the command.
Definition commands.h:113
std::string name
The name of the command.
Definition commands.h:88
HandlerType handler
Command handler.
Definition commands.h:128