diff --git a/ReCodeItCLI/Commands/AutoMatcher.cs b/ReCodeItCLI/Commands/AutoMatcher.cs index cf598af..40cc589 100644 --- a/ReCodeItCLI/Commands/AutoMatcher.cs +++ b/ReCodeItCLI/Commands/AutoMatcher.cs @@ -25,8 +25,6 @@ public class AutoMatchCommand : ICommand public ValueTask ExecuteAsync(IConsole console) { - DataProvider.LoadAppSettings(); - Logger.LogSync("Finding match..."); var remaps = new List(); diff --git a/ReCodeItCLI/Commands/DeObfuscate.cs b/ReCodeItCLI/Commands/DeObfuscate.cs index c5be8ce..2630c0b 100644 --- a/ReCodeItCLI/Commands/DeObfuscate.cs +++ b/ReCodeItCLI/Commands/DeObfuscate.cs @@ -17,8 +17,6 @@ public class DeObfuscate : ICommand public ValueTask ExecuteAsync(IConsole console) { - DataProvider.LoadAppSettings(); - Logger.Log("Deobfuscating assembly..."); Deobfuscator.Deobfuscate(AssemblyPath, IsLauncher); diff --git a/ReCodeItCLI/Commands/Dumper.cs b/ReCodeItCLI/Commands/Dumper.cs index 5123e52..4a1c5e7 100644 --- a/ReCodeItCLI/Commands/Dumper.cs +++ b/ReCodeItCLI/Commands/Dumper.cs @@ -14,8 +14,6 @@ public class Dumper : ICommand public ValueTask ExecuteAsync(IConsole console) { - DataProvider.LoadAppSettings(); - Logger.Log("Creating DumperClass..."); var dumper = new DumperClass(ManagedDirectory); diff --git a/ReCodeItCLI/Commands/ReMap.cs b/ReCodeItCLI/Commands/ReMap.cs index a916256..f3e90c3 100644 --- a/ReCodeItCLI/Commands/ReMap.cs +++ b/ReCodeItCLI/Commands/ReMap.cs @@ -19,7 +19,6 @@ public class ReMap : ICommand public ValueTask ExecuteAsync(IConsole console) { - DataProvider.LoadAppSettings(); DataProvider.Settings.MappingPath = MappingJsonPath; var remaps = DataProvider.LoadMappingFile(MappingJsonPath); diff --git a/RecodeItLib/Remapper/AutoMatcher.cs b/RecodeItLib/Remapper/AutoMatcher.cs index 59843a7..9c33f66 100644 --- a/RecodeItLib/Remapper/AutoMatcher.cs +++ b/RecodeItLib/Remapper/AutoMatcher.cs @@ -10,7 +10,8 @@ public class AutoMatcher(List mappings, string mappingPath) private List? CandidateTypes { get; set; } - private static List _tokens = DataProvider.Settings!.TokensToMatch; + private static List _tokens = DataProvider.Settings.TypeNamesToMatch; + private static List _methodsToIgnore = DataProvider.Settings.TypeNamesToMatch; public void AutoMatch(string assemblyPath, string oldTypeName, string newTypeName) { diff --git a/RecodeItLib/Remapper/ReMapper.cs b/RecodeItLib/Remapper/ReMapper.cs index 229a835..8edbe82 100644 --- a/RecodeItLib/Remapper/ReMapper.cs +++ b/RecodeItLib/Remapper/ReMapper.cs @@ -164,7 +164,7 @@ public class ReMapper /// Mapping to score private void ScoreMapping(RemapModel mapping, IEnumerable types) { - var tokens = DataProvider.Settings?.TokensToMatch; + var tokens = DataProvider.Settings?.TypeNamesToMatch; if (mapping.UseForceRename) { diff --git a/RecodeItLib/Remapper/Renamer.cs b/RecodeItLib/Remapper/Renamer.cs index afa1875..07f18db 100644 --- a/RecodeItLib/Remapper/Renamer.cs +++ b/RecodeItLib/Remapper/Renamer.cs @@ -6,7 +6,7 @@ namespace ReCodeItLib.ReMapper; internal class Renamer { - private static List TokensToMatch => DataProvider.Settings!.TokensToMatch; + private static List TokensToMatch => DataProvider.Settings!.TypeNamesToMatch; /// /// Only used by the manual remapper, should probably be removed diff --git a/RecodeItLib/Utils/DataProvider.cs b/RecodeItLib/Utils/DataProvider.cs index 93a60e5..81cdf15 100644 --- a/RecodeItLib/Utils/DataProvider.cs +++ b/RecodeItLib/Utils/DataProvider.cs @@ -1,7 +1,6 @@ using dnlib.DotNet; using Newtonsoft.Json; using ReCodeItLib.Models; -using ReCodeItLib.Dumper; namespace ReCodeItLib.Utils; @@ -9,29 +8,15 @@ public static class DataProvider { static DataProvider() { - LoadItems(); + Settings = LoadAppSettings(); + ItemTemplates = LoadItems(); } - public static string DataPath => Path.Combine(AppContext.BaseDirectory, "Data"); - - public static List Remaps { get; set; } = []; - public static Dictionary? ItemTemplates { get; private set; } + public static Settings Settings { get; } - public static Settings? Settings { get; private set; } - - public static void LoadAppSettings() - { - var settingsPath = Path.Combine(DataPath, "Settings.jsonc"); - - var jsonText = File.ReadAllText(settingsPath); - - JsonSerializerSettings settings = new JsonSerializerSettings - { - NullValueHandling = NullValueHandling.Ignore - }; - - Settings = JsonConvert.DeserializeObject(jsonText, settings); - } + public static Dictionary ItemTemplates { get; private set; } + + private static readonly string DataPath = Path.Combine(AppContext.BaseDirectory, "Data"); public static List LoadMappingFile(string path) { @@ -83,11 +68,19 @@ public static class DataProvider return module; } - private static void LoadItems() + private static Settings LoadAppSettings() + { + var settingsPath = Path.Combine(DataPath, "Settings.jsonc"); + var jsonText = File.ReadAllText(settingsPath); + + return JsonConvert.DeserializeObject(jsonText); + } + + private static Dictionary LoadItems() { var itemsPath = Path.Combine(DataPath, "items.json"); var jsonText = File.ReadAllText(itemsPath); - ItemTemplates = JsonConvert.DeserializeObject>(jsonText); + return JsonConvert.DeserializeObject>(jsonText); } } \ No newline at end of file