From b7907293349e95f84583e682f38e0eb491ac2e5d Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 11 Aug 2018 20:33:21 -0400 Subject: add support for loading unpacked .json files through content API (#576) --- src/StardewModdingAPI.Toolkit/Framework/ModScanning/ModScanner.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/StardewModdingAPI.Toolkit/Framework') diff --git a/src/StardewModdingAPI.Toolkit/Framework/ModScanning/ModScanner.cs b/src/StardewModdingAPI.Toolkit/Framework/ModScanning/ModScanner.cs index de8d0f02..f1cce4a4 100644 --- a/src/StardewModdingAPI.Toolkit/Framework/ModScanning/ModScanner.cs +++ b/src/StardewModdingAPI.Toolkit/Framework/ModScanning/ModScanner.cs @@ -51,8 +51,7 @@ namespace StardewModdingAPI.Toolkit.Framework.ModScanning { try { - manifest = this.JsonHelper.ReadJsonFile(manifestFile.FullName); - if (manifest == null) + if (!this.JsonHelper.ReadJsonFileIfExists(manifestFile.FullName, out manifest)) manifestError = "its manifest is invalid."; } catch (SParseException ex) -- cgit From 3299d25ee3d112d14475361eae294f64b9859efa Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Tue, 14 Aug 2018 12:07:15 -0400 Subject: drop backwards compatibility in update-check API Update checks from older versions of SMAPI are never useful now that Stardew Valley 1.3 is released: older versions of SMAPI won't launch in Stardew Valley 1.3 (so they won't check for updates), and newer versions of SMAPI/mods won't work with older versions of the game. --- docs/release-notes.md | 4 ++ src/SMAPI.Web/Controllers/ModsApiController.cs | 41 +++----------------- .../Framework/Clients/WebApi/ModEntryModel.cs | 44 ---------------------- .../Framework/Clients/WebApi/ModSeachModel.cs | 5 --- 4 files changed, 10 insertions(+), 84 deletions(-) (limited to 'src/StardewModdingAPI.Toolkit/Framework') diff --git a/docs/release-notes.md b/docs/release-notes.md index ab47b5c7..0ffcc591 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -23,6 +23,10 @@ * Fixed `.ToSButton()` methods not being public. * Updated compatibility list. +* For SMAPI developers: + * Dropped support for pre-SMAPI-2.6 update checks in the web API. + _These are no longer useful, even if the player still has earlier versions of SMAPI. Older versions of SMAPI won't launch in Stardew Valley 1.3 (so they won't check for updates), and newer versions of SMAPI/mods won't work with older versions of the game._ + ## 2.6 * For players: * Updated for Stardew Valley 1.3. diff --git a/src/SMAPI.Web/Controllers/ModsApiController.cs b/src/SMAPI.Web/Controllers/ModsApiController.cs index b500e19d..18d55665 100644 --- a/src/SMAPI.Web/Controllers/ModsApiController.cs +++ b/src/SMAPI.Web/Controllers/ModsApiController.cs @@ -83,31 +83,25 @@ namespace StardewModdingAPI.Web.Controllers /// Fetch version metadata for the given mods. /// The mod search criteria. [HttpPost] - public async Task PostAsync([FromBody] ModSearchModel model) + public async Task> PostAsync([FromBody] ModSearchModel model) { - // parse request data - ISemanticVersion apiVersion = this.GetApiVersion(); - ModSearchEntryModel[] searchMods = this.GetSearchMods(model, apiVersion).ToArray(); + if (model?.Mods == null) + return new ModEntryModel[0]; // fetch wiki data WikiCompatibilityEntry[] wikiData = await this.GetWikiDataAsync(); - - // fetch data IDictionary mods = new Dictionary(StringComparer.CurrentCultureIgnoreCase); - foreach (ModSearchEntryModel mod in searchMods) + foreach (ModSearchEntryModel mod in model.Mods) { if (string.IsNullOrWhiteSpace(mod.ID)) continue; ModEntryModel result = await this.GetModData(mod, wikiData, model.IncludeExtendedMetadata); - result.SetBackwardsCompatibility(apiVersion); mods[mod.ID] = result; } - // return in expected structure - return apiVersion.IsNewerThan("2.6-beta.18") - ? mods.Values - : (object)mods; + // return data + return mods.Values; } @@ -231,29 +225,6 @@ namespace StardewModdingAPI.Web.Controllers return current != null && (other == null || other.IsOlderThan(current)); } - /// Get the mods for which the API should return data. - /// The search model. - /// The requested API version. - private IEnumerable GetSearchMods(ModSearchModel model, ISemanticVersion apiVersion) - { - if (model == null) - yield break; - - // yield standard entries - if (model.Mods != null) - { - foreach (ModSearchEntryModel mod in model.Mods) - yield return mod; - } - - // yield mod update keys if backwards compatible - if (model.ModKeys != null && model.ModKeys.Any() && !apiVersion.IsNewerThan("2.6-beta.17")) - { - foreach (string updateKey in model.ModKeys.Distinct()) - yield return new ModSearchEntryModel(updateKey, new[] { updateKey }); - } - } - /// Get mod data from the wiki compatibility list. private async Task GetWikiDataAsync() { diff --git a/src/StardewModdingAPI.Toolkit/Framework/Clients/WebApi/ModEntryModel.cs b/src/StardewModdingAPI.Toolkit/Framework/Clients/WebApi/ModEntryModel.cs index f3f22b93..2aafe199 100644 --- a/src/StardewModdingAPI.Toolkit/Framework/Clients/WebApi/ModEntryModel.cs +++ b/src/StardewModdingAPI.Toolkit/Framework/Clients/WebApi/ModEntryModel.cs @@ -1,6 +1,3 @@ -using System; -using Newtonsoft.Json; - namespace StardewModdingAPI.Toolkit.Framework.Clients.WebApi { /// Metadata about a mod. @@ -26,46 +23,5 @@ namespace StardewModdingAPI.Toolkit.Framework.Clients.WebApi /// The errors that occurred while fetching update data. public string[] Errors { get; set; } = new string[0]; - - /**** - ** Backwards-compatible fields - ****/ - /// The mod's latest version number. - [Obsolete("Use " + nameof(ModEntryModel.Main))] - [JsonProperty] - internal string Version { get; private set; } - - /// The mod's web URL. - [Obsolete("Use " + nameof(ModEntryModel.Main))] - [JsonProperty] - internal string Url { get; private set; } - - /// The mod's latest optional release, if newer than . - [Obsolete("Use " + nameof(ModEntryModel.Optional))] - [JsonProperty] - internal string PreviewVersion { get; private set; } - - /// The web URL to the mod's latest optional release, if newer than . - [Obsolete("Use " + nameof(ModEntryModel.Optional))] - [JsonProperty] - internal string PreviewUrl { get; private set; } - - - /********* - ** Public methods - *********/ - /// Set backwards-compatible fields. - /// The requested API version. - public void SetBackwardsCompatibility(ISemanticVersion version) - { - if (version.IsOlderThan("2.6-beta.19")) - { - this.Version = this.Main?.Version?.ToString(); - this.Url = this.Main?.Url; - - this.PreviewVersion = this.Optional?.Version?.ToString(); - this.PreviewUrl = this.Optional?.Url; - } - } } } diff --git a/src/StardewModdingAPI.Toolkit/Framework/Clients/WebApi/ModSeachModel.cs b/src/StardewModdingAPI.Toolkit/Framework/Clients/WebApi/ModSeachModel.cs index df0d8457..e352e1cc 100644 --- a/src/StardewModdingAPI.Toolkit/Framework/Clients/WebApi/ModSeachModel.cs +++ b/src/StardewModdingAPI.Toolkit/Framework/Clients/WebApi/ModSeachModel.cs @@ -1,4 +1,3 @@ -using System; using System.Linq; namespace StardewModdingAPI.Toolkit.Framework.Clients.WebApi @@ -9,10 +8,6 @@ namespace StardewModdingAPI.Toolkit.Framework.Clients.WebApi /********* ** Accessors *********/ - /// The namespaced mod keys to search. - [Obsolete] - public string[] ModKeys { get; set; } - /// The mods for which to find data. public ModSearchEntryModel[] Mods { get; set; } -- cgit