summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/StardewModdingAPI/Framework/Models/IncompatibleMod.cs23
-rw-r--r--src/StardewModdingAPI/Program.cs18
-rw-r--r--src/StardewModdingAPI/StardewModdingAPI.data.json12
3 files changed, 40 insertions, 13 deletions
diff --git a/src/StardewModdingAPI/Framework/Models/IncompatibleMod.cs b/src/StardewModdingAPI/Framework/Models/IncompatibleMod.cs
index f3ee7d0b..9bf06552 100644
--- a/src/StardewModdingAPI/Framework/Models/IncompatibleMod.cs
+++ b/src/StardewModdingAPI/Framework/Models/IncompatibleMod.cs
@@ -1,3 +1,5 @@
+using System.Text.RegularExpressions;
+
namespace StardewModdingAPI.Framework.Models
{
/// <summary>Contains abstract metadata about an incompatible mod.</summary>
@@ -20,5 +22,26 @@ namespace StardewModdingAPI.Framework.Models
/// <summary>The URL the user can check for an unofficial updated version.</summary>
public string UnofficialUpdateUrl { get; set; }
+
+ /// <summary>A regular expression matching version strings to consider compatible, even if they technically precede <see cref="Version"/>.</summary>
+ public string ForceCompatibleVersion { get; set; }
+
+
+ /*********
+ ** Public methods
+ *********/
+ /// <summary>Get whether the specified version is compatible according to this metadata.</summary>
+ /// <param name="version">The current version of the matching mod.</param>
+ public bool IsCompatible(ISemanticVersion version)
+ {
+ ISemanticVersion incompatibleVersion = new SemanticVersion(this.Version);
+
+ // allow newer versions
+ if (version.IsNewerThan(incompatibleVersion))
+ return true;
+
+ // allow versions matching override
+ return !string.IsNullOrWhiteSpace(this.ForceCompatibleVersion) && Regex.IsMatch(version.ToString(), this.ForceCompatibleVersion, RegexOptions.IgnoreCase);
+ }
}
} \ No newline at end of file
diff --git a/src/StardewModdingAPI/Program.cs b/src/StardewModdingAPI/Program.cs
index c3bd1646..0c232b1d 100644
--- a/src/StardewModdingAPI/Program.cs
+++ b/src/StardewModdingAPI/Program.cs
@@ -384,23 +384,23 @@ namespace StardewModdingAPI
}
// validate known incompatible mods
- IncompatibleMod incompatible;
- if (incompatibleMods.TryGetValue(manifest.UniqueID ?? $"{manifest.Name}|{manifest.Author}|{manifest.EntryDll}", out incompatible))
+ IncompatibleMod compatibility;
+ if (incompatibleMods.TryGetValue(manifest.UniqueID ?? $"{manifest.Name}|{manifest.Author}|{manifest.EntryDll}", out compatibility))
{
- if (!manifest.Version.IsNewerThan(new SemanticVersion(incompatible.Version)))
+ if (!compatibility.IsCompatible(manifest.Version))
{
- string warning = $"Skipped {incompatible.Name} ≤v{incompatible.Version} because this version is not compatible with the latest version of the game. Please check for a newer version of the mod here:";
- if (!string.IsNullOrWhiteSpace(incompatible.UpdateUrl))
- warning += $"{Environment.NewLine}- official mod: {incompatible.UpdateUrl}";
- if (!string.IsNullOrWhiteSpace(incompatible.UnofficialUpdateUrl))
- warning += $"{Environment.NewLine}- unofficial update: {incompatible.UnofficialUpdateUrl}";
+ string warning = $"Skipped {compatibility.Name} ≤v{compatibility.Version} because this version is not compatible with the latest version of the game. Please check for a newer version of the mod here:";
+ if (!string.IsNullOrWhiteSpace(compatibility.UpdateUrl))
+ warning += $"{Environment.NewLine}- official mod: {compatibility.UpdateUrl}";
+ if (!string.IsNullOrWhiteSpace(compatibility.UnofficialUpdateUrl))
+ warning += $"{Environment.NewLine}- unofficial update: {compatibility.UnofficialUpdateUrl}";
Program.Monitor.Log(warning, LogLevel.Error);
continue;
}
}
- // validate version
+ // validate SMAPI version
if (!string.IsNullOrWhiteSpace(manifest.MinimumApiVersion))
{
try
diff --git a/src/StardewModdingAPI/StardewModdingAPI.data.json b/src/StardewModdingAPI/StardewModdingAPI.data.json
index 2f1d67e8..49b45018 100644
--- a/src/StardewModdingAPI/StardewModdingAPI.data.json
+++ b/src/StardewModdingAPI/StardewModdingAPI.data.json
@@ -11,27 +11,31 @@ This file contains advanced metadata for SMAPI. You shouldn't change this file.
"Name": "Better Sprinklers",
"Version": "2.1",
"UpdateUrl": "http://www.nexusmods.com/stardewvalley/mods/41",
- "UnofficialUpdateUrl": "http://community.playstarbound.com/threads/125031"
+ "UnofficialUpdateUrl": "http://community.playstarbound.com/threads/125031",
+ "ForceCompatibleVersion": "^2.1-EntoPatch"
},
{
"ID": "SPDChestLabel",
"Name": "Chest Label System",
"Version": "1.5",
"UpdateUrl": "http://www.nexusmods.com/stardewvalley/mods/242",
- "UnofficialUpdateUrl": "http://community.playstarbound.com/threads/125031"
+ "UnofficialUpdateUrl": "http://community.playstarbound.com/threads/125031",
+ "ForceCompatibleVersion": "^1.5-EntoPatch"
},
{
"ID": "CJBCheatsMenu",
"Name": "CJB Cheats Menu",
"Version": "1.12",
"UpdateUrl": "http://www.nexusmods.com/stardewvalley/mods/4",
- "UnofficialUpdateUrl": "http://community.playstarbound.com/threads/125031"
+ "UnofficialUpdateUrl": "http://community.playstarbound.com/threads/125031",
+ "ForceCompatibleVersion": "^1.12-EntoPatch"
},
{
"ID": "CJBItemSpawner",
"Name": "CJB Item Spawner",
"Version": "1.5",
"UpdateUrl": "http://www.nexusmods.com/stardewvalley/mods/93",
- "UnofficialUpdateUrl": "http://community.playstarbound.com/threads/125031"
+ "UnofficialUpdateUrl": "http://community.playstarbound.com/threads/125031",
+ "ForceCompatibleVersion": "^1.5-EntoPatch"
}
]