Refactored server stop and world save operations fixing race conditions so as to ensure operations always happen in a predicable order. This fixes output not appearing in the console / log for example. This adds TShock.Utils.StopServer method used by IGA, rcon and the RestAPI.
Fixed console title set not working Optimised command line parsing Made Utils a singleton to enforce the fact that only one copy should ever exist Added name to /v2/user/read output as users can be found by id
This commit is contained in:
parent
84789ff4d5
commit
d34199b17d
7 changed files with 228 additions and 121 deletions
|
|
@ -102,16 +102,10 @@ namespace TShockAPI
|
|||
if (!GetBool(parameters["confirm"], false))
|
||||
return RestInvalidParam("confirm");
|
||||
|
||||
if (!GetBool(parameters["nosave"], false))
|
||||
WorldGen.saveWorld();
|
||||
Netplay.disconnect = true;
|
||||
|
||||
// Inform players the server is shutting down
|
||||
var msg = string.IsNullOrWhiteSpace(parameters["message"]) ? "Server is shutting down" : parameters["message"];
|
||||
foreach (TSPlayer player in TShock.Players.Where(p => null != p))
|
||||
{
|
||||
TShock.Utils.ForceKick(player, msg);
|
||||
}
|
||||
TShock.Utils.StopServer(!GetBool(parameters["nosave"], false), msg);
|
||||
|
||||
return RestResponse("The server is shutting down");
|
||||
}
|
||||
|
||||
|
|
@ -304,8 +298,8 @@ namespace TShockAPI
|
|||
if (ret is RestObject)
|
||||
return ret;
|
||||
|
||||
User user = (User)ret;
|
||||
return new RestObject() { { "group", user.Group }, { "id", user.ID.ToString() } };
|
||||
User user = (User)ret;
|
||||
return new RestObject() { { "group", user.Group }, { "id", user.ID.ToString() }, { "name", user.Name } };
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
@ -411,7 +405,7 @@ namespace TShockAPI
|
|||
|
||||
private object WorldSave(RestVerbs verbs, IParameterCollection parameters)
|
||||
{
|
||||
TShock.Utils.SaveWorld();
|
||||
SaveManager.Instance.SaveWorld();
|
||||
|
||||
return RestResponse("World saved");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue