From 1c2140dd4de149e55ece23b64f845d30d22b6653 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 15 Aug 2013 17:18:17 +0200 Subject: Fixed the Reload and Save-all console commands. They were broken by the PerWorldThreads update removing cServer:BroadcastMessage() and cServer:SendMessage() --- MCServer/Plugins/Core/console.lua | 81 +++++++++++++++++++++++++++++++++++---- 1 file changed, 74 insertions(+), 7 deletions(-) (limited to 'MCServer') diff --git a/MCServer/Plugins/Core/console.lua b/MCServer/Plugins/Core/console.lua index 669d7c9cb..8ae8cb675 100644 --- a/MCServer/Plugins/Core/console.lua +++ b/MCServer/Plugins/Core/console.lua @@ -21,9 +21,12 @@ function InitConsoleCommands() PluginMgr:BindConsoleCommand("setversion", HandleConsoleVersion, " ~ Sets server version reported to 1.4+ clients"); PluginMgr:BindConsoleCommand("unban", HandleConsoleUnban, " ~ Unbans a player by name"); PluginMgr:BindConsoleCommand("unload", HandleConsoleUnload, " - Unloads all unused chunks"); - end + + + + function HandleConsoleGive(Split) -- Make sure there are a correct number of arguments. @@ -80,9 +83,12 @@ function HandleConsoleGive(Split) end return true - end + + + + function HandleConsoleBan(Split) if (#Split < 2) then return true, "Usage: ban [Player] "; @@ -108,6 +114,10 @@ function HandleConsoleBan(Split) return true end + + + + function HandleConsoleUnban(Split) if #Split < 2 then @@ -123,9 +133,12 @@ function HandleConsoleUnban(Split) local Server = cRoot:Get():GetServer() return true, "Unbanned " .. Split[2] - end + + + + function HandleConsoleBanList(Split) if (#Split == 1) then return true, BanListByName(); @@ -138,6 +151,10 @@ function HandleConsoleBanList(Split) return true, "Unknown banlist subcommand"; end + + + + function HandleConsoleHelp(Split) local Commands = {}; -- {index => {"Command", "HelpString"} } local MaxLength = 0; @@ -166,6 +183,10 @@ function HandleConsoleHelp(Split) return true, Out; end + + + + function HandleConsoleList(Split) -- Get a list of all players, one playername per line local Out = ""; @@ -181,6 +202,10 @@ function HandleConsoleList(Split) return true, Out; end + + + + function HandleConsoleListGroups(Split) -- Read the groups.ini file: local GroupsIni = cIniFile("groups.ini"); @@ -201,6 +226,10 @@ function HandleConsoleListGroups(Split) return true, Out; end + + + + function HandleConsoleNumChunks(Split) local Output = {}; local AddNumChunks = function(World) @@ -220,6 +249,10 @@ function HandleConsoleNumChunks(Split) return true, Out; end + + + + function HandleConsolePlayers(Split) local PlayersInWorlds = {}; -- "WorldName" => [players array] local AddToTable = function(Player) @@ -243,6 +276,10 @@ function HandleConsolePlayers(Split) return true, Out; end + + + + function HandleConsoleVersion(Split) if (#Split == 1) then -- Display current version: @@ -256,6 +293,10 @@ function HandleConsoleVersion(Split) return true, "Primary server version is now #" .. Version .. ", " .. cRoot:GetProtocolVersionTextFromInt(Version); end + + + + function HandleConsoleRank(Split) if (Split[2] == nil) or (Split[3] == nil) then return true, "Usage: /rank [Player] [Group]"; @@ -301,20 +342,38 @@ function HandleConsoleRank(Split) return true, Out .. "Player " .. Split[2] .. " was moved to " .. Split[3]; end + + + + function HandleConsoleReload(Split) - Server = cRoot:Get():GetServer(); - Server:SendMessage(cChatColor.Rose .. "[WARNING] " .. cChatColor.White .. "Reloading all plugins!"); + cRoot:Get():ForEachWorld( + function (a_World) + a_World:BroadcastChat(cChatColor.Rose .. "[WARNING] " .. cChatColor.White .. "Reloading all plugins!"); + end + ) cPluginManager:Get():ReloadPlugins(); return true; end + + + + function HandleConsoleSaveAll(Split) - Server = cRoot:Get():GetServer(); - Server:SendMessage(cChatColor.Rose .. "[WARNING] " .. cChatColor.White .. "Saving all chunks!"); + cRoot:Get():ForEachWorld( + function (a_World) + a_World:BroadcastChat(cChatColor.Rose .. "[WARNING] " .. cChatColor.White .. "Saving all chunks!"); + end + ) cRoot:Get():SaveAllChunks(); return true; end + + + + function HandleConsoleSay(Split) table.remove(Split, 1); local Message = ""; @@ -326,6 +385,10 @@ function HandleConsoleSay(Split) return true; end + + + + function HandleConsoleUnload(Split) local UnloadChunks = function(World) World:UnloadUnusedChunks(); @@ -336,3 +399,7 @@ function HandleConsoleUnload(Split) Out = Out .. "Num loaded chunks after: " .. cRoot:Get():GetTotalChunkCount(); return true, Out; end + + + + -- cgit v1.2.3