summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2018-02-17 18:51:09 -0500
committerJesse Plamondon-Willard <github@jplamondonw.com>2018-02-17 18:51:09 -0500
commit0c1bca3db044b6f228538f1738d52c31e4481e48 (patch)
treee0bf7adaeacd84420ad6e7128bf79506a2c5f783
parent84330e86809dff4a3e70c3cbd59f0373f7017799 (diff)
downloadSMAPI-0c1bca3db044b6f228538f1738d52c31e4481e48.tar.gz
SMAPI-0c1bca3db044b6f228538f1738d52c31e4481e48.tar.bz2
SMAPI-0c1bca3db044b6f228538f1738d52c31e4481e48.zip
validate that mod APIs are public (#435)
-rw-r--r--docs/release-notes.md1
-rw-r--r--src/SMAPI/Program.cs6
2 files changed, 7 insertions, 0 deletions
diff --git a/docs/release-notes.md b/docs/release-notes.md
index 228fec82..f0a7a718 100644
--- a/docs/release-notes.md
+++ b/docs/release-notes.md
@@ -9,6 +9,7 @@
* For modders:
* Fixed deadlock in rare cases when injecting a file with an asset loader.
+ * Fixed unhelpful error when a mod exposes a non-public API.
* For SMAPI developers:
* Overhauled `StardewModdingApi.config.json`'s `ModData` format to be more concise, reduce the memory footprint, and support versioning/defaulting more fields.
diff --git a/src/SMAPI/Program.cs b/src/SMAPI/Program.cs
index 88e27768..fd2bb340 100644
--- a/src/SMAPI/Program.cs
+++ b/src/SMAPI/Program.cs
@@ -804,6 +804,12 @@ namespace StardewModdingAPI
try
{
object api = metadata.Mod.GetApi();
+ if (api != null && !api.GetType().IsPublic)
+ {
+ api = null;
+ this.Monitor.Log($"{metadata.DisplayName} provides an API instance with a non-public type. This isn't currently supported, so the API won't be available to other mods.", LogLevel.Warn);
+ }
+
if (api != null)
this.Monitor.Log($" Found mod-provided API ({api.GetType().FullName}).", LogLevel.Trace);
metadata.SetApi(api);