using System.Linq; using Newtonsoft.Json; using StardewModdingAPI.Framework.Serialisation; namespace StardewModdingAPI.Framework.Models { /// Metadata about a mod from SMAPI's internal data. internal class ModDataRecord { /********* ** Accessors *********/ /// The unique mod identifier. [JsonConverter(typeof(SFieldConverter))] public ModDataID ID { get; set; } /// Default values for support fields to inject into the manifest. public ModDataDefaults Defaults { get; set; } /// The URL where the player can get an unofficial or alternative version of the mod if the official version isn't compatible. public string AlternativeUrl { get; set; } /// The compatibility of given mod versions (if any). [JsonConverter(typeof(SFieldConverter))] public ModCompatibility[] Compatibility { get; set; } = new ModCompatibility[0]; /********* ** Public methods *********/ /// Get the compatibility record for a given version, if any. /// The mod version to check. public ModCompatibility GetCompatibility(ISemanticVersion version) { return this.Compatibility.FirstOrDefault(p => p.MatchesVersion(version)); } } }