diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2018-04-17 21:12:03 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2018-04-17 21:12:03 -0400 |
commit | 4af998024cf47ed90a2177c42b77217208685f50 (patch) | |
tree | 237e5dadaff00ae2d4b7349be3ca30038ea56f4d | |
parent | bb2c52386015829c161a56d418f3795335559d8a (diff) | |
download | SMAPI-4af998024cf47ed90a2177c42b77217208685f50.tar.gz SMAPI-4af998024cf47ed90a2177c42b77217208685f50.tar.bz2 SMAPI-4af998024cf47ed90a2177c42b77217208685f50.zip |
add warning in developer mode for mods with no update keys
-rw-r--r-- | docs/release-notes.md | 1 | ||||
-rw-r--r-- | src/SMAPI/Framework/IModMetadata.cs | 3 | ||||
-rw-r--r-- | src/SMAPI/Framework/ModLoading/ModMetadata.cs | 9 | ||||
-rw-r--r-- | src/SMAPI/Program.cs | 8 |
4 files changed, 21 insertions, 0 deletions
diff --git a/docs/release-notes.md b/docs/release-notes.md index e524ea65..cde7847e 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -10,6 +10,7 @@ * For modders: * Added code analysis to mod build config package to flag common issues as warnings. + * Added warning when a mod doesn't have update keys (currently only shown in developer mode). * Dropped some deprecated APIs. * Fixed assets loaded by temporary content managers not being editable. * Fixed issue where assets didn't reload correctly when the player switches language. diff --git a/src/SMAPI/Framework/IModMetadata.cs b/src/SMAPI/Framework/IModMetadata.cs index d1e8eb7d..248809df 100644 --- a/src/SMAPI/Framework/IModMetadata.cs +++ b/src/SMAPI/Framework/IModMetadata.cs @@ -64,5 +64,8 @@ namespace StardewModdingAPI.Framework /// <summary>Set the mod-provided API instance.</summary> /// <param name="api">The mod-provided API.</param> IModMetadata SetApi(object api); + + /// <summary>Whether the mod has at least one update key set.</summary> + bool HasUpdateKeys(); } } diff --git a/src/SMAPI/Framework/ModLoading/ModMetadata.cs b/src/SMAPI/Framework/ModLoading/ModMetadata.cs index 1a0f9994..af888b71 100644 --- a/src/SMAPI/Framework/ModLoading/ModMetadata.cs +++ b/src/SMAPI/Framework/ModLoading/ModMetadata.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using StardewModdingAPI.Framework.ModData; namespace StardewModdingAPI.Framework.ModLoading @@ -102,5 +103,13 @@ namespace StardewModdingAPI.Framework.ModLoading this.Api = api; return this; } + + /// <summary>Whether the mod has at least one update key set.</summary> + public bool HasUpdateKeys() + { + return + this.Manifest?.UpdateKeys != null + && this.Manifest.UpdateKeys.Any(key => !string.IsNullOrWhiteSpace(key)); + } } } diff --git a/src/SMAPI/Program.cs b/src/SMAPI/Program.cs index f70efb89..cf1c082a 100644 --- a/src/SMAPI/Program.cs +++ b/src/SMAPI/Program.cs @@ -722,6 +722,10 @@ namespace StardewModdingAPI continue; } + // show warnings + if (this.Settings.DeveloperMode && !metadata.HasUpdateKeys()) + this.Monitor.Log($" {metadata.DisplayName} has no {nameof(IManifest.UpdateKeys)} in its manifest. You may not see update alerts for this mod.", LogLevel.Warn); + // load mod as content pack IMonitor monitor = this.GetSecondaryMonitor(metadata.DisplayName); ContentManagerShim contentManager = this.ContentCore.CreateContentManager($"Mods.{metadata.Manifest.UniqueID}", metadata.DirectoryPath); @@ -766,6 +770,10 @@ namespace StardewModdingAPI continue; } + // show warnings + if (this.Settings.DeveloperMode && !metadata.HasUpdateKeys() && metadata.Manifest.UniqueID != "SMAPI.ConsoleCommands") + this.Monitor.Log($" {metadata.DisplayName} has no {nameof(IManifest.UpdateKeys)} in its manifest. You may not see update alerts for this mod.", LogLevel.Warn); + // load mod string assemblyPath = metadata.Manifest?.EntryDll != null ? Path.Combine(metadata.DirectoryPath, metadata.Manifest.EntryDll) |