diff options
author | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2014-08-29 15:43:49 +0200 |
---|---|---|
committer | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2014-08-29 15:43:49 +0200 |
commit | 618741f78e2e840552663590fd0d6eab03aa874e (patch) | |
tree | f5302c5c648ee888479e350a85cf5e809152ed3d /src/Server.cpp | |
parent | Improved explosion damage (diff) | |
download | cuberite-618741f78e2e840552663590fd0d6eab03aa874e.tar cuberite-618741f78e2e840552663590fd0d6eab03aa874e.tar.gz cuberite-618741f78e2e840552663590fd0d6eab03aa874e.tar.bz2 cuberite-618741f78e2e840552663590fd0d6eab03aa874e.tar.lz cuberite-618741f78e2e840552663590fd0d6eab03aa874e.tar.xz cuberite-618741f78e2e840552663590fd0d6eab03aa874e.tar.zst cuberite-618741f78e2e840552663590fd0d6eab03aa874e.zip |
Diffstat (limited to 'src/Server.cpp')
-rw-r--r-- | src/Server.cpp | 59 |
1 files changed, 42 insertions, 17 deletions
diff --git a/src/Server.cpp b/src/Server.cpp index 42ad133f1..4524ece76 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -457,33 +457,34 @@ void cServer::ExecuteConsoleCommand(const AString & a_Cmd, cCommandOutputCallbac return; } - // Special handling: "stop" and "restart" are built in - if ((split[0].compare("stop") == 0) || (split[0].compare("restart") == 0)) - { - return; - } + // "stop" and "restart" are handled in cRoot::ExecuteConsoleCommand, our caller, due to its access to controlling variables // "help" and "reload" are to be handled by MCS, so that they work no matter what if (split[0] == "help") { PrintHelp(split, a_Output); + a_Output.Finished(); return; } if (split[0] == "reload") { cPluginManager::Get()->ReloadPlugins(); cRoot::Get()->ReloadGroups(); + a_Output.Out("Plugins and groups reloaded"); + a_Output.Finished(); return; } if (split[0] == "reloadplugins") { cPluginManager::Get()->ReloadPlugins(); + a_Output.Out("Plugins reloaded"); + a_Output.Finished(); return; } if (split[0] == "reloadgroups") { cRoot::Get()->ReloadGroups(); - a_Output.Out("Groups reloaded!"); + a_Output.Out("Groups reloaded"); a_Output.Finished(); return; } @@ -491,31 +492,54 @@ void cServer::ExecuteConsoleCommand(const AString & a_Cmd, cCommandOutputCallbac { if (split.size() > 1) { - cPluginManager::Get()->LoadPlugin(split[1]); - - return; + a_Output.Out(cPluginManager::Get()->LoadPlugin(split[1]) ? "Plugin loaded" : "Error occurred loading plugin"); } else { - a_Output.Out("No plugin given! Command: load <pluginname>"); - a_Output.Finished(); - return; + a_Output.Out("Usage: load <pluginname>"); } + a_Output.Finished(); + return; } - if (split[0] == "unload") { if (split.size() > 1) { cPluginManager::Get()->RemovePlugin(cPluginManager::Get()->GetPlugin(split[1])); - return; + a_Output.Out("Plugin unloaded"); } else { - a_Output.Out("No plugin given! Command: unload <pluginname>"); - a_Output.Finished(); - return; + a_Output.Out("Usage: unload <pluginname>"); } + a_Output.Finished(); + return; + } + if (split[0] == "destroyentities") + { + class WorldCallback : public cWorldListCallback + { + virtual bool Item(cWorld * a_World) override + { + class EntityCallback : public cEntityCallback + { + virtual bool Item(cEntity * a_Entity) override + { + if (!a_Entity->IsPlayer()) + { + a_Entity->Destroy(); + } + return false; + } + } EC; + a_World->ForEachEntity(EC); + return false; + } + } WC; + cRoot::Get()->ForEachWorld(WC); + a_Output.Out("Destroyed all entities"); + a_Output.Finished(); + return; } // There is currently no way a plugin can do these (and probably won't ever be): @@ -610,6 +634,7 @@ void cServer::BindBuiltInConsoleCommands(void) PlgMgr->BindConsoleCommand("chunkstats", NULL, " - Displays detailed chunk memory statistics"); PlgMgr->BindConsoleCommand("load <pluginname>", NULL, " - Adds and enables the specified plugin"); PlgMgr->BindConsoleCommand("unload <pluginname>", NULL, " - Disables the specified plugin"); + PlgMgr->BindConsoleCommand("destroyentities", NULL, " - Destroys all entities in all worlds"); #if defined(_MSC_VER) && defined(_DEBUG) && defined(ENABLE_LEAK_FINDER) PlgMgr->BindConsoleCommand("dumpmem", NULL, " - Dumps all used memory blocks together with their callstacks into memdump.xml"); |