summaryrefslogtreecommitdiff
path: root/src/SMAPI/Framework
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2018-03-04 18:46:05 -0500
committerJesse Plamondon-Willard <github@jplamondonw.com>2018-03-04 18:46:05 -0500
commit99023f94871e1f9bad5ee5f5db0ff041a02e9ed5 (patch)
treeed5a44b3199cd6c8dc1a20781dd6b071b4254900 /src/SMAPI/Framework
parent90c8593ba9a0828a4d3f563c6f08fc90933cd2ff (diff)
downloadSMAPI-99023f94871e1f9bad5ee5f5db0ff041a02e9ed5.tar.gz
SMAPI-99023f94871e1f9bad5ee5f5db0ff041a02e9ed5.tar.bz2
SMAPI-99023f94871e1f9bad5ee5f5db0ff041a02e9ed5.zip
add support for mapping non-semantic remote mod versions
Diffstat (limited to 'src/SMAPI/Framework')
-rw-r--r--src/SMAPI/Framework/ModData/ModDataRecord.cs11
-rw-r--r--src/SMAPI/Framework/ModData/ParsedModDataRecord.cs2
-rw-r--r--src/SMAPI/Framework/WebApiClient.cs2
3 files changed, 10 insertions, 5 deletions
diff --git a/src/SMAPI/Framework/ModData/ModDataRecord.cs b/src/SMAPI/Framework/ModData/ModDataRecord.cs
index 79a954f7..56275f53 100644
--- a/src/SMAPI/Framework/ModData/ModDataRecord.cs
+++ b/src/SMAPI/Framework/ModData/ModDataRecord.cs
@@ -106,10 +106,10 @@ namespace StardewModdingAPI.Framework.ModData
/// <summary>Get a semantic local version for update checks.</summary>
/// <param name="version">The remote version to normalise.</param>
- public string GetLocalVersionForUpdateChecks(string version)
+ public ISemanticVersion GetLocalVersionForUpdateChecks(ISemanticVersion version)
{
- return this.MapLocalVersions != null && this.MapLocalVersions.TryGetValue(version, out string newVersion)
- ? newVersion
+ return this.MapLocalVersions != null && this.MapLocalVersions.TryGetValue(version.ToString(), out string newVersion)
+ ? new SemanticVersion(newVersion)
: version;
}
@@ -117,6 +117,11 @@ namespace StardewModdingAPI.Framework.ModData
/// <param name="version">The remote version to normalise.</param>
public string GetRemoteVersionForUpdateChecks(string version)
{
+ // normalise version if possible
+ if (SemanticVersion.TryParse(version, out ISemanticVersion parsed))
+ version = parsed.ToString();
+
+ // fetch remote version
return this.MapRemoteVersions != null && this.MapRemoteVersions.TryGetValue(version, out string newVersion)
? newVersion
: version;
diff --git a/src/SMAPI/Framework/ModData/ParsedModDataRecord.cs b/src/SMAPI/Framework/ModData/ParsedModDataRecord.cs
index 7f49790d..deb12bdc 100644
--- a/src/SMAPI/Framework/ModData/ParsedModDataRecord.cs
+++ b/src/SMAPI/Framework/ModData/ParsedModDataRecord.cs
@@ -33,7 +33,7 @@ namespace StardewModdingAPI.Framework.ModData
*********/
/// <summary>Get a semantic local version for update checks.</summary>
/// <param name="version">The remote version to normalise.</param>
- public string GetLocalVersionForUpdateChecks(string version)
+ public ISemanticVersion GetLocalVersionForUpdateChecks(ISemanticVersion version)
{
return this.DataRecord.GetLocalVersionForUpdateChecks(version);
}
diff --git a/src/SMAPI/Framework/WebApiClient.cs b/src/SMAPI/Framework/WebApiClient.cs
index e78ac14b..7f0122cf 100644
--- a/src/SMAPI/Framework/WebApiClient.cs
+++ b/src/SMAPI/Framework/WebApiClient.cs
@@ -40,7 +40,7 @@ namespace StardewModdingAPI.Framework
{
return this.Post<ModSearchModel, Dictionary<string, ModInfoModel>>(
$"v{this.Version}/mods",
- new ModSearchModel(modKeys)
+ new ModSearchModel(modKeys, allowInvalidVersions: true)
);
}