speeder needs to fuck off

This commit is contained in:
Zoryn Aaron 2016-03-27 07:13:16 -04:00
parent fac89e4c26
commit 36a3401e14
1 changed files with 35 additions and 0 deletions

View File

@ -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>();
}
}
}