summaryrefslogtreecommitdiff
path: root/src/StardewModdingAPI/Program.cs
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2016-11-16 16:21:17 -0500
committerJesse Plamondon-Willard <github@jplamondonw.com>2016-11-16 16:21:17 -0500
commit785af919521124ea7f231aa1437525cf27f82d6c (patch)
tree7940b5edfd1a55510c3e945bf998af912cd0e4e7 /src/StardewModdingAPI/Program.cs
parent1ac930979a34c2fde4e0fb5ff5244ea18c68aa77 (diff)
downloadSMAPI-785af919521124ea7f231aa1437525cf27f82d6c.tar.gz
SMAPI-785af919521124ea7f231aa1437525cf27f82d6c.tar.bz2
SMAPI-785af919521124ea7f231aa1437525cf27f82d6c.zip
add optional 'minimum API version' field to manifest (#176)
Diffstat (limited to 'src/StardewModdingAPI/Program.cs')
-rw-r--r--src/StardewModdingAPI/Program.cs21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/StardewModdingAPI/Program.cs b/src/StardewModdingAPI/Program.cs
index 0e1a2527..ca45eba5 100644
--- a/src/StardewModdingAPI/Program.cs
+++ b/src/StardewModdingAPI/Program.cs
@@ -158,7 +158,7 @@ namespace StardewModdingAPI
{
GitRelease release = UpdateHelper.GetLatestVersionAsync(Constants.GitHubRepository).Result;
Version latestVersion = new Version(release.Tag);
- if (latestVersion.CompareTo(Constants.Version) > 0)
+ if (latestVersion.IsNewerThan(Constants.Version))
Program.Monitor.Log($"You can update SMAPI from version {Constants.Version} to {latestVersion}", LogLevel.Alert);
}
catch (Exception ex)
@@ -320,6 +320,25 @@ namespace StardewModdingAPI
continue;
}
+ // validate version
+ if (!string.IsNullOrWhiteSpace(manifest.MinimumApiVersion))
+ {
+ try
+ {
+ Version minVersion = new Version(manifest.MinimumApiVersion);
+ if (minVersion.IsNewerThan(Constants.Version))
+ {
+ Program.Monitor.Log($"{errorPrefix}: this mod requires SMAPI {minVersion} or later. Please update SMAPI to the latest version to use this mod.", LogLevel.Error);
+ continue;
+ }
+ }
+ catch (FormatException ex) when (ex.Message.Contains("not a semantic version"))
+ {
+ Program.Monitor.Log($"{errorPrefix}: the mod specified an invalid minimum SMAPI version '{manifest.MinimumApiVersion}'. This should be a semantic version number like {Constants.Version}.", LogLevel.Error);
+ continue;
+ }
+ }
+
// create per-save directory
if (manifest.PerSaveConfigs)
{