summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--release-notes.md1
-rw-r--r--src/StardewModdingAPI/Program.cs12
2 files changed, 10 insertions, 3 deletions
diff --git a/release-notes.md b/release-notes.md
index 67286308..3b654ee3 100644
--- a/release-notes.md
+++ b/release-notes.md
@@ -44,6 +44,7 @@ For mod developers:
* The SMAPI log now shows the OS caption (like "Windows 10") instead of its internal version when available.
* The SMAPI log now always uses `\r\n` line endings to simplify crossplatform viewing.
* Fixed `SaveEvents.AfterLoad` being raised during the new-game intro before the player is initialised.
+* Fixed SMAPI not recognising `Mod` instances that don't subclass `Mod` directly.
* Several obsolete APIs have been removed (see [deprecation guide](http://canimod.com/guides/updating-a-smapi-mod)),
and all _notice_-level deprecations have been increased to _info_.
* Removed the experimental `IConfigFile`.
diff --git a/src/StardewModdingAPI/Program.cs b/src/StardewModdingAPI/Program.cs
index 25605148..276b66ce 100644
--- a/src/StardewModdingAPI/Program.cs
+++ b/src/StardewModdingAPI/Program.cs
@@ -450,9 +450,15 @@ namespace StardewModdingAPI
// validate assembly
try
{
- if (modAssembly.DefinedTypes.Count(x => x.BaseType == typeof(Mod)) == 0)
+ int modEntries = modAssembly.DefinedTypes.Count(type => typeof(Mod).IsAssignableFrom(type) && !type.IsAbstract);
+ if(modEntries == 0)
{
- this.Monitor.Log($"{skippedPrefix} because its DLL has no 'Mod' subclass.", LogLevel.Error);
+ this.Monitor.Log($"{skippedPrefix} because its DLL has no '{nameof(Mod)}' subclass.", LogLevel.Error);
+ continue;
+ }
+ if (modEntries > 1)
+ {
+ this.Monitor.Log($"{skippedPrefix} because its DLL contains multiple '{nameof(Mod)}' subclasses.", LogLevel.Error);
continue;
}
}
@@ -466,7 +472,7 @@ namespace StardewModdingAPI
try
{
// get implementation
- TypeInfo modEntryType = modAssembly.DefinedTypes.First(x => x.BaseType == typeof(Mod));
+ TypeInfo modEntryType = modAssembly.DefinedTypes.First(type => typeof(Mod).IsAssignableFrom(type) && !type.IsAbstract);
Mod mod = (Mod)modAssembly.CreateInstance(modEntryType.ToString());
if (mod == null)
{