diff options
Diffstat (limited to 'src/StardewModdingAPI/Framework/Serialisation/SFieldConverter.cs')
-rw-r--r-- | src/StardewModdingAPI/Framework/Serialisation/SFieldConverter.cs | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/StardewModdingAPI/Framework/Serialisation/SFieldConverter.cs b/src/StardewModdingAPI/Framework/Serialisation/SFieldConverter.cs index 9dc62b6a..11ffdccb 100644 --- a/src/StardewModdingAPI/Framework/Serialisation/SFieldConverter.cs +++ b/src/StardewModdingAPI/Framework/Serialisation/SFieldConverter.cs @@ -24,7 +24,10 @@ namespace StardewModdingAPI.Framework.Serialisation /// <param name="objectType">The object type.</param> public override bool CanConvert(Type objectType) { - return objectType == typeof(ISemanticVersion) || objectType == typeof(IManifestDependency[]); + return + objectType == typeof(ISemanticVersion) + || objectType == typeof(IManifestDependency[]) + || objectType == typeof(ModCompatibilityID[]); } /// <summary>Reads the JSON representation of the object.</summary> @@ -83,6 +86,20 @@ namespace StardewModdingAPI.Framework.Serialisation return result.ToArray(); } + // mod compatibility ID + if (objectType == typeof(ModCompatibilityID[])) + { + List<ModCompatibilityID> result = new List<ModCompatibilityID>(); + foreach (JToken child in JArray.Load(reader).Children()) + { + result.Add(child is JValue value + ? new ModCompatibilityID(value.Value<string>()) + : child.ToObject<ModCompatibilityID>() + ); + } + return result.ToArray(); + } + // unknown throw new NotSupportedException($"Unknown type '{objectType?.FullName}'."); } |