summaryrefslogtreecommitdiff
path: root/src/SMAPI
diff options
context:
space:
mode:
Diffstat (limited to 'src/SMAPI')
-rw-r--r--src/SMAPI/Framework/ModLoading/ModMetadata.cs19
-rw-r--r--src/SMAPI/Framework/ModLoading/ModResolver.cs2
-rw-r--r--src/SMAPI/Framework/SCore.cs19
3 files changed, 20 insertions, 20 deletions
diff --git a/src/SMAPI/Framework/ModLoading/ModMetadata.cs b/src/SMAPI/Framework/ModLoading/ModMetadata.cs
index 17e6d59a..b703f74c 100644
--- a/src/SMAPI/Framework/ModLoading/ModMetadata.cs
+++ b/src/SMAPI/Framework/ModLoading/ModMetadata.cs
@@ -195,7 +195,10 @@ namespace StardewModdingAPI.Framework.ModLoading
/// <inheritdoc />
public IEnumerable<UpdateKey> GetUpdateKeys(bool validOnly = false)
{
- foreach (string rawKey in this.Manifest?.UpdateKeys ?? new string[0])
+ if (this.Manifest == null)
+ yield break;
+
+ foreach (string rawKey in this.Manifest.UpdateKeys)
{
UpdateKey updateKey = UpdateKey.Parse(rawKey);
if (updateKey.LooksValid || !validOnly)
@@ -251,16 +254,16 @@ namespace StardewModdingAPI.Framework.ModLoading
{
var ids = new Dictionary<string, bool>(StringComparer.OrdinalIgnoreCase);
- // yield dependencies
- if (this.Manifest?.Dependencies != null)
+ if (this.Manifest != null)
{
- foreach (var entry in this.Manifest?.Dependencies)
+ // yield dependencies
+ foreach (IManifestDependency entry in this.Manifest.Dependencies)
ids[entry.UniqueID] = entry.IsRequired;
- }
- // yield content pack parent
- if (this.Manifest?.ContentPackFor?.UniqueID != null)
- ids[this.Manifest.ContentPackFor.UniqueID] = true;
+ // yield content pack parent
+ if (this.Manifest.ContentPackFor?.UniqueID != null)
+ ids[this.Manifest.ContentPackFor.UniqueID] = true;
+ }
return ids;
}
diff --git a/src/SMAPI/Framework/ModLoading/ModResolver.cs b/src/SMAPI/Framework/ModLoading/ModResolver.cs
index 7761a567..3bf2b0a1 100644
--- a/src/SMAPI/Framework/ModLoading/ModResolver.cs
+++ b/src/SMAPI/Framework/ModLoading/ModResolver.cs
@@ -82,7 +82,7 @@ namespace StardewModdingAPI.Framework.ModLoading
// get update URLs
List<string> updateUrls = new List<string>();
- foreach (string key in mod.Manifest.UpdateKeys ?? new string[0])
+ foreach (string key in mod.Manifest.UpdateKeys)
{
string url = getUpdateUrl(key);
if (url != null)
diff --git a/src/SMAPI/Framework/SCore.cs b/src/SMAPI/Framework/SCore.cs
index 5862b112..8b2c7544 100644
--- a/src/SMAPI/Framework/SCore.cs
+++ b/src/SMAPI/Framework/SCore.cs
@@ -1593,19 +1593,16 @@ namespace StardewModdingAPI.Framework
// validate dependencies
// Although dependencies are validated before mods are loaded, a dependency may have failed to load.
- if (mod.Manifest.Dependencies?.Any() == true)
+ foreach (IManifestDependency dependency in mod.Manifest.Dependencies.Where(p => p.IsRequired))
{
- foreach (IManifestDependency dependency in mod.Manifest.Dependencies.Where(p => p.IsRequired))
+ if (this.ModRegistry.Get(dependency.UniqueID) == null)
{
- if (this.ModRegistry.Get(dependency.UniqueID) == null)
- {
- string dependencyName = mods
- .FirstOrDefault(otherMod => otherMod.HasID(dependency.UniqueID))
- ?.DisplayName ?? dependency.UniqueID;
- errorReasonPhrase = $"it needs the '{dependencyName}' mod, which couldn't be loaded.";
- failReason = ModFailReason.MissingDependencies;
- return false;
- }
+ string dependencyName = mods
+ .FirstOrDefault(otherMod => otherMod.HasID(dependency.UniqueID))
+ ?.DisplayName ?? dependency.UniqueID;
+ errorReasonPhrase = $"it needs the '{dependencyName}' mod, which couldn't be loaded.";
+ failReason = ModFailReason.MissingDependencies;
+ return false;
}
}