From 50244b727a3d38d310a9057eff86750cad4b26bf Mon Sep 17 00:00:00 2001 From: RileyPrince Date: Sun, 21 Jan 2024 00:45:05 +1030 Subject: [PATCH] Removed SimpleJSON for NewtonSoft.JSON --- Counters+/Utils/VersionUtility.cs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/Counters+/Utils/VersionUtility.cs b/Counters+/Utils/VersionUtility.cs index c1fa188..b9c9b2b 100644 --- a/Counters+/Utils/VersionUtility.cs +++ b/Counters+/Utils/VersionUtility.cs @@ -1,8 +1,8 @@ using Hive.Versioning; using IPA.Loader; -using SimpleJSON; using System.Collections; using UnityEngine.Networking; +using Newtonsoft.Json; namespace CountersPlus.Utils { @@ -17,7 +17,7 @@ public VersionUtility() // I could grab this straight from PluginMetadata but this is for cleanness. PluginVersion = PluginManager.GetPlugin("Counters+").HVersion; - Utils.SharedCoroutineStarter.instance.StartCoroutine(GetBeatModsVersion()); + SharedCoroutineStarter.instance.StartCoroutine(GetBeatModsVersion()); } private IEnumerator GetBeatModsVersion() @@ -30,15 +30,22 @@ private IEnumerator GetBeatModsVersion() Plugin.Logger.Error("Failed to download version info."); yield break; } - JSONNode node = JSON.Parse(www.downloadHandler.text); - foreach (JSONNode child in node) + BeatmodsResult[] results = JsonConvert.DeserializeObject(www.downloadHandler.text); + foreach (BeatmodsResult result in results) { - if (child["status"] != "approved") continue; - BeatModsVersion = new Version(child["version"].Value); + if (result.status != "approved") continue; + BeatModsVersion = new Version(result.version); break; } } if (!HasLatestVersion) Plugin.Logger.Warn("Uh oh! We aren't up to date!"); } + + + } + class BeatmodsResult + { + [JsonProperty("status")] internal string status; + [JsonProperty("version")] internal string version; } }