From 07d607a9b616092aa185c391d5c1ca1e62cd61a4 Mon Sep 17 00:00:00 2001 From: ricky Date: Thu, 16 Jun 2011 10:18:22 +1000 Subject: [PATCH] Fixed json config file changes made while server is running lost if reload is not performed before restart Fixed unban not saving to file until server shutdown --- TShockAPI/BanManager.cs | 1 + TShockAPI/FileTools.cs | 2 ++ TShockAPI/TShock.cs | 11 ++--------- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/TShockAPI/BanManager.cs b/TShockAPI/BanManager.cs index f7905914..7d67bdf1 100644 --- a/TShockAPI/BanManager.cs +++ b/TShockAPI/BanManager.cs @@ -74,6 +74,7 @@ namespace TShockAPI public void RemoveBan(Ban ban) { Bans.Remove(ban); + SaveBans(); } /// diff --git a/TShockAPI/FileTools.cs b/TShockAPI/FileTools.cs index 773691b1..a87f94af 100644 --- a/TShockAPI/FileTools.cs +++ b/TShockAPI/FileTools.cs @@ -66,6 +66,8 @@ namespace TShockAPI if (File.Exists(ConfigPath)) { ConfigurationManager.ReadJsonConfiguration(); + // Add all the missing config properties in the json file + ConfigurationManager.WriteJsonConfiguration(); } else { diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 078de510..ae11f7e4 100755 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -139,14 +139,8 @@ namespace TShockAPI public override void Initialize() { - try - { - FileTools.SetupConfig(); - } - catch (Exception ex) - { - Console.WriteLine(ex.ToString()); - } + FileTools.SetupConfig(); + string version = string.Format("TShock Version {0} ({1}) now running.", Version, VersionCodename); Console.WriteLine(version); @@ -179,7 +173,6 @@ namespace TShockAPI public override void DeInitialize() { Bans.SaveBans(); - ConfigurationManager.WriteJsonConfiguration(); GameHooks.PostInitialize -= OnPostInit; GameHooks.Update -= OnUpdate; ServerHooks.Chat -= OnChat;