summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/release-notes.md2
-rw-r--r--src/SMAPI/Framework/IModMetadata.cs3
-rw-r--r--src/SMAPI/Framework/ModLoading/ModMetadata.cs9
-rw-r--r--src/SMAPI/Program.cs38
4 files changed, 22 insertions, 30 deletions
diff --git a/docs/release-notes.md b/docs/release-notes.md
index 565ed58c..3cb048cd 100644
--- a/docs/release-notes.md
+++ b/docs/release-notes.md
@@ -3,13 +3,13 @@
* For players:
* Added support for Stardew Valley 1.3+; no longer compatible with earlier versions.
* Added `Context.IsMultiplayer` and `Context.IsMainPlayer` flags.
+ * Added warning for mods which don't have update checks configured.
* Fixed SMAPI update checks not showing newer beta versions when using a beta version.
* Fixed console color scheme on Mac or PowerShell, and added override option to `StardewModdingAPI.config.json`.
* Fixed `world_settime` console command sometimes breaking NPC schedules (e.g. so they stay in bed).
* 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).
* Fixed assets loaded by temporary content managers not being editable.
* Fixed issue where assets didn't reload correctly when the player switches language.
* Fixed `helper.ModRegistry.GetApi` interface validation errors not mentioning which interface caused the issue.
diff --git a/src/SMAPI/Framework/IModMetadata.cs b/src/SMAPI/Framework/IModMetadata.cs
index 248809df..b7972fe1 100644
--- a/src/SMAPI/Framework/IModMetadata.cs
+++ b/src/SMAPI/Framework/IModMetadata.cs
@@ -65,6 +65,9 @@ namespace StardewModdingAPI.Framework
/// <param name="api">The mod-provided API.</param>
IModMetadata SetApi(object api);
+ /// <summary>Whether the mod manifest was loaded (regardless of whether the mod itself was loaded).</summary>
+ bool HasManifest();
+
/// <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 af888b71..d3a33e7a 100644
--- a/src/SMAPI/Framework/ModLoading/ModMetadata.cs
+++ b/src/SMAPI/Framework/ModLoading/ModMetadata.cs
@@ -104,11 +104,18 @@ namespace StardewModdingAPI.Framework.ModLoading
return this;
}
+ /// <summary>Whether the mod manifest was loaded (regardless of whether the mod itself was loaded).</summary>
+ public bool HasManifest()
+ {
+ return this.Manifest != null;
+ }
+
/// <summary>Whether the mod has at least one update key set.</summary>
public bool HasUpdateKeys()
{
return
- this.Manifest?.UpdateKeys != null
+ this.HasManifest()
+ && 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 3c6b1cf6..9789cf85 100644
--- a/src/SMAPI/Program.cs
+++ b/src/SMAPI/Program.cs
@@ -582,25 +582,8 @@ namespace StardewModdingAPI
StringComparer.InvariantCultureIgnoreCase
);
- // report update keys
- {
- IModMetadata[] modsWithoutKeys = (
- from mod in mods
- where
- mod.Manifest != null
- && (mod.Manifest.UpdateKeys == null || !mod.Manifest.UpdateKeys.Any())
- && (mod.Manifest?.UniqueID != "SMAPI.ConsoleCommands" && mod.Manifest?.UniqueID != "SMAPI.TrainerMod")
- orderby mod.DisplayName
- select mod
- ).ToArray();
-
- string message = $"Checking {modsByKey.Count} mod update keys.";
- if (modsWithoutKeys.Any())
- message += $" {modsWithoutKeys.Length} mods have no update keys: {string.Join(", ", modsWithoutKeys.Select(p => p.DisplayName))}.";
- this.Monitor.Log($" {message}", LogLevel.Trace);
- }
-
// fetch results
+ this.Monitor.Log($" Checking {modsByKey.Count} mod update keys.", LogLevel.Trace);
var results =
(
from entry in client.GetModInfo(modsByKey.Keys.ToArray())
@@ -714,10 +697,12 @@ namespace StardewModdingAPI
// load content packs
foreach (IModMetadata metadata in mods.Where(p => p.IsContentPack))
{
- // get basic info
- IManifest manifest = metadata.Manifest;
this.Monitor.Log($" {metadata.DisplayName} (content pack, {PathUtilities.GetRelativePath(Constants.ModPath, metadata.DirectoryPath)})...", LogLevel.Trace);
+ // show warning for missing update key
+ if (metadata.HasManifest() && !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);
+
// validate status
if (metadata.Status == ModMetadataStatus.Failed)
{
@@ -726,11 +711,8 @@ 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
+ IManifest manifest = metadata.Manifest;
IMonitor monitor = this.GetSecondaryMonitor(metadata.DisplayName);
ContentManagerShim contentManager = this.ContentCore.CreateContentManager($"Mods.{metadata.Manifest.UniqueID}", metadata.DirectoryPath);
IContentHelper contentHelper = new ContentHelper(this.ContentCore, contentManager, metadata.DirectoryPath, manifest.UniqueID, metadata.DisplayName, monitor);
@@ -766,6 +748,10 @@ namespace StardewModdingAPI
? $" {metadata.DisplayName} ({PathUtilities.GetRelativePath(Constants.ModPath, metadata.DirectoryPath)}{Path.DirectorySeparatorChar}{metadata.Manifest.EntryDll})..." // don't use Path.Combine here, since EntryDLL might not be valid
: $" {metadata.DisplayName}...", LogLevel.Trace);
+ // show warnings
+ if (metadata.HasManifest() && !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);
+
// validate status
if (metadata.Status == ModMetadataStatus.Failed)
{
@@ -774,10 +760,6 @@ 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)