From 9d80f8a632d7d930d21eea487565c567ff5d32af Mon Sep 17 00:00:00 2001 From: DragonFire47 <46509577+DragonFire47@users.noreply.github.com> Date: Mon, 21 Nov 2022 18:58:52 -0800 Subject: [PATCH] -Readjusted config folder creation positioning for simplicity. --- PulsarModLoader/SaveData/PMLSaveData.cs | 2 +- PulsarModLoader/SaveValue.cs | 18 ++++++++---------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/PulsarModLoader/SaveData/PMLSaveData.cs b/PulsarModLoader/SaveData/PMLSaveData.cs index 7f0cede..f0346f6 100644 --- a/PulsarModLoader/SaveData/PMLSaveData.cs +++ b/PulsarModLoader/SaveData/PMLSaveData.cs @@ -6,6 +6,6 @@ public abstract class PMLSaveData public abstract string Identifier(); public virtual uint VersionID => 0; public abstract byte[] SaveData(); - public abstract void LoadData(byte[] Aata, uint VersionID); + public abstract void LoadData(byte[] Data, uint VersionID); } } diff --git a/PulsarModLoader/SaveValue.cs b/PulsarModLoader/SaveValue.cs index 880ca34..4176c26 100644 --- a/PulsarModLoader/SaveValue.cs +++ b/PulsarModLoader/SaveValue.cs @@ -11,8 +11,13 @@ internal class SaveValueManager { public static string GetConfigFolder() { - return Path.Combine(Directory.GetCurrentDirectory(), "ModConfigs"); - } + string ModConfigDir = Path.Combine(Directory.GetCurrentDirectory(), "ModConfigs"); + if (!Directory.Exists(ModConfigDir)) + { + Directory.CreateDirectory(ModConfigDir); + } + return ModConfigDir; + } private static JsonSerializerSettings serializerSettings; static SaveValueManager() @@ -56,15 +61,8 @@ internal static T GetValueFor(string id, Assembly mod, T @default) private static string GetConfigFile(Assembly mod) { - //Create ModConfigs Directory for SaveValue class - string ModConfigDir = GetConfigFolder(); - if (!Directory.Exists(ModConfigDir)) - { - Directory.CreateDirectory(ModConfigDir); - } - if (ModToConfigFile.ContainsKey(mod)) return ModToConfigFile[mod]; - string newFile = Path.Combine(ModConfigDir, mod.GetName().Name + ".json"); + string newFile = Path.Combine(GetConfigFolder(), mod.GetName().Name + ".json"); ModToConfigFile.Add(mod, newFile); if (!ModToCacheValues.ContainsKey(mod) && File.Exists(newFile)) ModToCacheValues.Add(mod, JsonConvert.DeserializeObject>(File.ReadAllText(newFile)));