From ced16d9fb94455b5ea07c81ad9f7c992daa3eee3 Mon Sep 17 00:00:00 2001 From: zontreck Date: Sat, 7 Jun 2025 12:17:04 -0700 Subject: [PATCH] Refactor Costs to ComandCosts --- AriasServerUtils/Globals.cs | 39 ++++++++++++++++++++--------------- AriasServerUtils/modinfo.json | 4 ++-- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/AriasServerUtils/Globals.cs b/AriasServerUtils/Globals.cs index b0ed577..ac6287f 100644 --- a/AriasServerUtils/Globals.cs +++ b/AriasServerUtils/Globals.cs @@ -37,7 +37,7 @@ namespace AriasServerUtils public int PlayerSleepingPercentage { get; set; } = 50; public int MaxRTPBlockDistance { get; set; } = 50000; public Dictionary Cooldowns { get; set; } = new Dictionary(); - public Costs costs { get; set; } = new Costs(); + public CommandCosts cmdCosts { get; set; } = new CommandCosts(); /// @@ -75,27 +75,18 @@ namespace AriasServerUtils 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 } - // Sanity check costs config + // Sanity check CommandCosts config bool checkCostDefaults = false; - if (costs == null) + if (cmdCosts == null) { - costs = new Costs(); // Initialize a brand new costs object + cmdCosts = new CommandCosts(); // Initialize a brand new CommandCosts object checkCostDefaults = true; } - else if (costs.costs.Count != Costs.defaults.Count) checkCostDefaults = true; + else if (cmdCosts.costs.Count != CommandCosts.defaults.Count) checkCostDefaults = true; if (checkCostDefaults) { - - foreach (var def in Costs.defaults) - { - if (!costs.costs.ContainsKey(def.Key)) - { - costs.costs.Add(def.Key, def.Value); - } - } - - ServerUtilities.MarkDirty(); + cmdCosts.SanityCheck(); } } @@ -141,11 +132,11 @@ namespace AriasServerUtils } /// - /// This contains per command costs, as well as helper functions that can refund a player, or check if the player has the required balance, or payment + /// This contains per command CommandCosts, as well as helper functions that can refund a player, or check if the player has the required balance, or payment /// /// [Serializable] - public class Costs + public class CommandCosts { public enum CostType { @@ -195,6 +186,20 @@ namespace AriasServerUtils if (gears >= required) return true; return false; } + + public void SanityCheck() + { + + foreach (var def in defaults) + { + if (!costs.ContainsKey(def.Key)) + { + costs.Add(def.Key, def.Value); + } + } + + ServerUtilities.MarkDirty(); + } } diff --git a/AriasServerUtils/modinfo.json b/AriasServerUtils/modinfo.json index 69e7daf..8fb4cc3 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: 06-07-2025 @ 1:18 AM MST", - "version": "1.1.0-dev.4", + "description": "A collection of server utilities\n\nBuild Date: 06-07-2025 @ 12:16 PM MST", + "version": "1.1.0-dev.5", "dependencies": { "game": "" }