diff --git a/AriasServerUtils/Globals.cs b/AriasServerUtils/Globals.cs index 5da42ab..b0ed577 100644 --- a/AriasServerUtils/Globals.cs +++ b/AriasServerUtils/Globals.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Reflection.Metadata; using System.Runtime.ConstrainedExecution; using Vintagestory.API.Common; using Vintagestory.API.Server; @@ -23,7 +24,7 @@ namespace AriasServerUtils { CooldownType.RTP, "30s" }, { CooldownType.Back, "5s" } }; - private static readonly int CURRENT_VERSION = 6; + private static readonly int CURRENT_VERSION = 7; public int Version { get; set; } = 0; @@ -36,6 +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(); /// @@ -72,6 +74,29 @@ namespace AriasServerUtils 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 } + + // Sanity check costs config + bool checkCostDefaults = false; + if (costs == null) + { + costs = new Costs(); // Initialize a brand new costs object + checkCostDefaults = true; + } + else if (costs.costs.Count != Costs.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(); + } } @@ -122,7 +147,29 @@ namespace AriasServerUtils [Serializable] public class Costs { - public Dictionary costs = new Dictionary(); + public enum CostType + { + sethome, + home, + delhome, + sethomemount, + warp, + setwarp, + delwarp, + spawn + } + public Dictionary costs = new Dictionary(); + public static readonly Dictionary defaults = new Dictionary() + { + { CostType.sethome, 0 }, + { CostType.home, 0 }, + { CostType.delhome, 0 }, + { CostType.sethomemount, 10 }, + { CostType.setwarp, 5 }, + { CostType.warp, 1 }, + { CostType.delwarp, 5 }, + { CostType.spawn, 0 } + }; /// /// Checks if the player has the balance required to use the command @@ -130,7 +177,7 @@ namespace AriasServerUtils /// The command the player is trying to use /// The player /// True if the player has the required balance - public bool PlayerHasBalance(string cmd, EntityPlayer player) + public bool PlayerHasBalance(CostType cmd, EntityPlayer player) { int gears = 0; int required = 0; diff --git a/AriasServerUtils/modinfo.json b/AriasServerUtils/modinfo.json index 47b0a7a..69e7daf 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-05-2025 @ 4:44 PM MST", - "version": "1.1.0-dev.3", + "description": "A collection of server utilities\n\nBuild Date: 06-07-2025 @ 1:18 AM MST", + "version": "1.1.0-dev.4", "dependencies": { "game": "" }