1
0

Console "reload" command implemented in MCServer, rather than in a plugin.

First part of #42.
This commit is contained in:
madmaxoft 2013-11-13 15:56:40 +01:00
parent 991f7d2315
commit 1701b628cb
2 changed files with 26 additions and 0 deletions

View File

@ -462,6 +462,18 @@ void cServer::ExecuteConsoleCommand(const AString & a_Cmd, cCommandOutputCallbac
return; return;
} }
// "help" and "reload" are to be handled by MCS, so that they work no matter what
if (split[0] == "help")
{
PrintHelp(split, a_Output);
return;
}
if (split[0] == "reload")
{
cPluginManager::Get()->ReloadPlugins();
return;
}
// There is currently no way a plugin can do these (and probably won't ever be): // There is currently no way a plugin can do these (and probably won't ever be):
if (split[0].compare("chunkstats") == 0) if (split[0].compare("chunkstats") == 0)
{ {
@ -500,9 +512,20 @@ void cServer::ExecuteConsoleCommand(const AString & a_Cmd, cCommandOutputCallbac
void cServer::PrintHelp(const AStringVector & a_Split, cCommandOutputCallback & a_Output)
{
// TODO
}
void cServer::BindBuiltInConsoleCommands(void) void cServer::BindBuiltInConsoleCommands(void)
{ {
cPluginManager * PlgMgr = cPluginManager::Get(); cPluginManager * PlgMgr = cPluginManager::Get();
PlgMgr->BindConsoleCommand("help", NULL, " - Shows the available commands");
PlgMgr->BindConsoleCommand("reload", NULL, " - Reloads all plugins");
PlgMgr->BindConsoleCommand("restart", NULL, " - Restarts the server cleanly"); PlgMgr->BindConsoleCommand("restart", NULL, " - Restarts the server cleanly");
PlgMgr->BindConsoleCommand("stop", NULL, " - Stops the server cleanly"); PlgMgr->BindConsoleCommand("stop", NULL, " - Stops the server cleanly");
PlgMgr->BindConsoleCommand("chunkstats", NULL, " - Displays detailed chunk memory statistics"); PlgMgr->BindConsoleCommand("chunkstats", NULL, " - Displays detailed chunk memory statistics");

View File

@ -57,6 +57,9 @@ public: // tolua_export
/// Executes the console command, sends output through the specified callback /// Executes the console command, sends output through the specified callback
void ExecuteConsoleCommand(const AString & a_Cmd, cCommandOutputCallback & a_Output); void ExecuteConsoleCommand(const AString & a_Cmd, cCommandOutputCallback & a_Output);
/// Lists all available console commands and their helpstrings
void PrintHelp(const AStringVector & a_Split, cCommandOutputCallback & a_Output);
/// Binds the built-in console commands with the plugin manager /// Binds the built-in console commands with the plugin manager
static void BindBuiltInConsoleCommands(void); static void BindBuiltInConsoleCommands(void);