summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--StardewModdingAPI/Manifest.cs35
1 files changed, 35 insertions, 0 deletions
diff --git a/StardewModdingAPI/Manifest.cs b/StardewModdingAPI/Manifest.cs
index 162ab399..e2526cf3 100644
--- a/StardewModdingAPI/Manifest.cs
+++ b/StardewModdingAPI/Manifest.cs
@@ -1,4 +1,8 @@
using System;
+using System.IO;
+using System.Linq;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
namespace StardewModdingAPI
{
@@ -50,5 +54,36 @@ namespace StardewModdingAPI
EntryDll = "";
return this as T;
}
+
+ public override T LoadConfig<T>()
+ {
+ if (File.Exists(ConfigLocation))
+ {
+ try
+ {
+ Manifest m = JsonConvert.DeserializeObject<Manifest>(File.ReadAllText(ConfigLocation));
+ }
+ catch
+ {
+ //Invalid json blob. Try to remove version?
+ try
+ {
+ JObject j = JObject.Parse(File.ReadAllText(ConfigLocation));
+ if (!j.GetValue("Version").Contains("{"))
+ {
+ Log.AsyncC("INVALID JSON VERSION. TRYING TO REMOVE SO A NEW CAN BE AUTO-GENERATED");
+ j.Remove("Version");
+ File.WriteAllText(ConfigLocation, j.ToString());
+ }
+ }
+ catch
+ {
+ //Idgaf speeder can go fuck himself
+ }
+ }
+ }
+
+ return base.LoadConfig<T>();
+ }
}
} \ No newline at end of file