From 36a3401e14ce911e1c2a7855d2d4d9a709fbf526 Mon Sep 17 00:00:00 2001 From: Zoryn Aaron Date: Sun, 27 Mar 2016 07:13:16 -0400 Subject: [PATCH] speeder needs to fuck off --- StardewModdingAPI/Manifest.cs | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) 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() + { + if (File.Exists(ConfigLocation)) + { + try + { + Manifest m = JsonConvert.DeserializeObject(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(); + } } } \ No newline at end of file