diff --git a/AriasServerUtils/ASUModSystem.cs b/AriasServerUtils/ASUModSystem.cs index f52be58..c688363 100644 --- a/AriasServerUtils/ASUModSystem.cs +++ b/AriasServerUtils/ASUModSystem.cs @@ -361,8 +361,8 @@ namespace AriasServerUtils config = API.LoadModConfig(GetConfigurationFile("global", ModConfigType.Global)); if (config == null) config = new ASUModConfig(); - // Step 2. Check if there are new or missing cooldowns - config.SanityCheckCooldowns(); + // Step 2. Check if config needs Migrations + config.SanityCheck(); // -> Step 3. Load Mod Warps <- serverWarps = API.LoadModConfig(GetConfigurationFile("warps", ModConfigType.Global)); diff --git a/AriasServerUtils/Globals.cs b/AriasServerUtils/Globals.cs index bf1dd29..1b8af8c 100644 --- a/AriasServerUtils/Globals.cs +++ b/AriasServerUtils/Globals.cs @@ -22,28 +22,24 @@ namespace AriasServerUtils { CooldownType.RTP, "30s" }, { CooldownType.Back, "5s" } }; + private static readonly int CURRENT_VERSION = 3; + + public int Version { get; set; } = 0; public int MaxHomes { get; set; } = 20; public bool AdminsBypassMaxHomes { get; set; } = true; public bool onlyAdminsCreateWarps { get; set; } = true; public int MaxBackCache { get; set; } = 10; public int PlayerSleepingPercentage { get; set; } = 50; public int MaxRTPBlockDistance { get; set; } = 5000; - public Dictionary Cooldowns { get; set; } = new Dictionary - { - { CooldownType.Home, "5s" }, - { CooldownType.Warp, "10s" }, - { CooldownType.Spawn, "5s" }, - { CooldownType.RTP, "30s" }, - { CooldownType.Back, "5s" } - }; + public Dictionary Cooldowns { get; set; } = new Dictionary(); public Dictionary GetDefaultCooldowns() { return m_defaultCD; } - public void SanityCheckCooldowns() + public void SanityCheck() { foreach (var cd in GetDefaultCooldowns()) { @@ -53,6 +49,12 @@ namespace AriasServerUtils ServerUtilities.MarkDirty(); } } + + if (Version < CURRENT_VERSION) + { + Version = CURRENT_VERSION; + ServerUtilities.MarkDirty(); // This is here to ensure that the config gets saved when there is a update. Whenever a new field is added to config, the CURRENT_VERSION should get bumped so that this SanityCheck can properly work + } } diff --git a/AriasServerUtils/modinfo.json b/AriasServerUtils/modinfo.json index 441bda3..b0c8d9b 100644 --- a/AriasServerUtils/modinfo.json +++ b/AriasServerUtils/modinfo.json @@ -3,8 +3,8 @@ "modid": "ariasserverutils", "name": "Aria's Server Utilities", "authors": ["zontreck"], - "description": "A collection of server utilities\n\nBuild Date: 03-07-2025 @ 1:17 AM MST", - "version": "1.0.5-dev.3", + "description": "A collection of server utilities\n\nBuild Date: 03-07-2025 @ 1:21 AM MST", + "version": "1.0.5-dev.4", "dependencies": { "game": "" }