summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2017-07-10 14:43:52 -0400
committerJesse Plamondon-Willard <github@jplamondonw.com>2017-07-10 14:43:52 -0400
commit234b6403423523d7bfc0333404d0361ad200ff8d (patch)
tree31557b8bb2f193a613b2719397751f137ad422de
parentd82e57d3060c96923ba9a8efe3c9eb839abffe59 (diff)
downloadSMAPI-234b6403423523d7bfc0333404d0361ad200ff8d.tar.gz
SMAPI-234b6403423523d7bfc0333404d0361ad200ff8d.tar.bz2
SMAPI-234b6403423523d7bfc0333404d0361ad200ff8d.zip
normalise unique IDs in mod registry lookups, update release notes
-rw-r--r--release-notes.md3
-rw-r--r--src/StardewModdingAPI/Framework/ModRegistry.cs14
2 files changed, 15 insertions, 2 deletions
diff --git a/release-notes.md b/release-notes.md
index 179b31c4..84b42c8b 100644
--- a/release-notes.md
+++ b/release-notes.md
@@ -14,6 +14,9 @@ For mod developers:
* In `manifest.json`:
* Dependencies can now be optional.
* The version can now be a string like `"1.0-alpha"` instead of a structure.
+ * The `Name`, `Version,` and `UniqueID` fields are no longer optional.
+ * The `UniqueID` field must now be unique (case-insensitive). If two installed mods have the same ID, SMAPI will show an error and load neither.
+* The mod registry now matches unique IDs case-insensitively.
* Removed all deprecated code.
For SMAPI developers:
diff --git a/src/StardewModdingAPI/Framework/ModRegistry.cs b/src/StardewModdingAPI/Framework/ModRegistry.cs
index a427bdb7..8f30d813 100644
--- a/src/StardewModdingAPI/Framework/ModRegistry.cs
+++ b/src/StardewModdingAPI/Framework/ModRegistry.cs
@@ -36,14 +36,24 @@ namespace StardewModdingAPI.Framework
/// <returns>Returns the matching mod's metadata, or <c>null</c> if not found.</returns>
public IManifest Get(string uniqueID)
{
- return this.GetAll().FirstOrDefault(p => p.UniqueID == uniqueID);
+ // normalise search ID
+ if (string.IsNullOrWhiteSpace(uniqueID))
+ return null;
+ uniqueID = uniqueID.Trim();
+
+ // find match
+ return this.GetAll().FirstOrDefault(p =>
+#if SMAPI_1_x
+ p.UniqueID != null &&
+#endif
+ p.UniqueID.Trim().Equals(uniqueID, StringComparison.InvariantCultureIgnoreCase));
}
/// <summary>Get whether a mod has been loaded.</summary>
/// <param name="uniqueID">The mod's unique ID.</param>
public bool IsLoaded(string uniqueID)
{
- return this.GetAll().Any(p => p.UniqueID == uniqueID);
+ return this.Get(uniqueID) != null;
}
/****