From a8c4641743bd5053814bc45223c5864fd3864094 Mon Sep 17 00:00:00 2001 From: Magnus Date: Sun, 4 Aug 2024 13:32:15 -0700 Subject: [PATCH] Fix documentation error and add log for future debuging --- NewHorizons/NewHorizonsApi.cs | 8 +++++--- docs/src/content/docs/guides/extending-configs.md | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/NewHorizons/NewHorizonsApi.cs b/NewHorizons/NewHorizonsApi.cs index 6a165fa2..dea9f8eb 100644 --- a/NewHorizons/NewHorizonsApi.cs +++ b/NewHorizons/NewHorizonsApi.cs @@ -143,9 +143,11 @@ namespace NewHorizons public object QueryBody(Type outType, string bodyName, string jsonPath) { var planet = Main.BodyDict[Main.Instance.CurrentStarSystem].Find((b) => b.Config.name == bodyName); - return planet == null - ? null - : QueryJson(outType, Path.Combine(planet.Mod.ModHelper.Manifest.ModFolderPath, planet.RelativePath), jsonPath); + if (planet == null){ + NHLogger.LogError($"Could not find planet with body name {bodyName}.") + return null; + } + return QueryJson(outType, Path.Combine(planet.Mod.ModHelper.Manifest.ModFolderPath, planet.RelativePath), jsonPath); } public T QueryBody(string bodyName, string jsonPath) diff --git a/docs/src/content/docs/guides/extending-configs.md b/docs/src/content/docs/guides/extending-configs.md index 0d3ee903..63b39fc5 100644 --- a/docs/src/content/docs/guides/extending-configs.md +++ b/docs/src/content/docs/guides/extending-configs.md @@ -49,7 +49,7 @@ Then, use the `QueryBody` method: var api = ModHelper.Interactions.TryGetModApi("xen.NewHorizons"); api.GetBodyLoadedEvent().AddListener((name) => { ModHelper.Console.WriteLine($"Body: {name} Loaded!"); - var data = api.QueryBody("$.extras.myCoolExtensionData", name); + var data = api.QueryBody(name, "$.extras.myCoolExtensionData"); // Makes sure the module is not null if (data != null) { ModHelper.Console.WriteLine($"myCoolExtensionProperty for {name} is {data.myCoolExtensionProperty}!");