summaryrefslogtreecommitdiff
path: root/src/SMAPI
diff options
context:
space:
mode:
Diffstat (limited to 'src/SMAPI')
-rw-r--r--src/SMAPI/Framework/IModMetadata.cs6
-rw-r--r--src/SMAPI/Framework/Logging/LogManager.cs10
-rw-r--r--src/SMAPI/Framework/ModLoading/ModMetadata.cs19
3 files changed, 20 insertions, 15 deletions
diff --git a/src/SMAPI/Framework/IModMetadata.cs b/src/SMAPI/Framework/IModMetadata.cs
index 70cf0036..5d2f352d 100644
--- a/src/SMAPI/Framework/IModMetadata.cs
+++ b/src/SMAPI/Framework/IModMetadata.cs
@@ -34,7 +34,7 @@ namespace StardewModdingAPI.Framework
/// <summary>The reason the mod failed to load, if applicable.</summary>
ModFailReason? FailReason { get; }
- /// <summary>Indicates non-error issues with the mod.</summary>
+ /// <summary>The non-error issues with the mod, ignoring those suppressed via <see cref="DataRecord"/>.</summary>
ModWarning Warnings { get; }
/// <summary>The reason the metadata is invalid, if any.</summary>
@@ -124,9 +124,9 @@ namespace StardewModdingAPI.Framework
/// <summary>Whether the mod has at least one valid update key set.</summary>
bool HasValidUpdateKeys();
- /// <summary>Get whether the mod has any of the given warnings which haven't been suppressed in the <see cref="DataRecord"/>.</summary>
+ /// <summary>Get whether the mod has any of the given warnings, ignoring those suppressed via <see cref="DataRecord"/>.</summary>
/// <param name="warnings">The warnings to check.</param>
- bool HasUnsuppressedWarnings(params ModWarning[] warnings);
+ bool HasWarnings(params ModWarning[] warnings);
/// <summary>Get a relative path which includes the root folder name.</summary>
string GetRelativePathWithRoot();
diff --git a/src/SMAPI/Framework/Logging/LogManager.cs b/src/SMAPI/Framework/Logging/LogManager.cs
index 2c7be399..f3656886 100644
--- a/src/SMAPI/Framework/Logging/LogManager.cs
+++ b/src/SMAPI/Framework/Logging/LogManager.cs
@@ -505,7 +505,7 @@ namespace StardewModdingAPI.Framework.Logging
{
this.LogModWarningGroup(
modsWithWarnings,
- match: mod => mod.HasUnsuppressedWarnings(ModWarning.AccessesConsole, ModWarning.AccessesFilesystem, ModWarning.AccessesShell),
+ match: mod => mod.HasWarnings(ModWarning.AccessesConsole, ModWarning.AccessesFilesystem, ModWarning.AccessesShell),
level: LogLevel.Debug,
heading: "Direct system access",
blurb: new[]
@@ -517,11 +517,11 @@ namespace StardewModdingAPI.Framework.Logging
modLabel: mod =>
{
List<string> labels = new List<string>();
- if (mod.HasUnsuppressedWarnings(ModWarning.AccessesConsole))
+ if (mod.HasWarnings(ModWarning.AccessesConsole))
labels.Add("console");
- if (mod.HasUnsuppressedWarnings(ModWarning.AccessesFilesystem))
+ if (mod.HasWarnings(ModWarning.AccessesFilesystem))
labels.Add("files");
- if (mod.HasUnsuppressedWarnings(ModWarning.AccessesShell))
+ if (mod.HasWarnings(ModWarning.AccessesShell))
labels.Add("shells/processes");
return $"{mod.DisplayName} ({string.Join(", ", labels)})";
@@ -582,7 +582,7 @@ namespace StardewModdingAPI.Framework.Logging
/// <param name="blurb">A detailed explanation of the warning, split into lines.</param>
private void LogModWarningGroup(IModMetadata[] mods, ModWarning warning, LogLevel level, string heading, params string[] blurb)
{
- this.LogModWarningGroup(mods, mod => mod.HasUnsuppressedWarnings(warning), level, heading, blurb);
+ this.LogModWarningGroup(mods, mod => mod.HasWarnings(warning), level, heading, blurb);
}
diff --git a/src/SMAPI/Framework/ModLoading/ModMetadata.cs b/src/SMAPI/Framework/ModLoading/ModMetadata.cs
index 18d2b112..b4de3d6c 100644
--- a/src/SMAPI/Framework/ModLoading/ModMetadata.cs
+++ b/src/SMAPI/Framework/ModLoading/ModMetadata.cs
@@ -14,6 +14,13 @@ namespace StardewModdingAPI.Framework.ModLoading
internal class ModMetadata : IModMetadata
{
/*********
+ ** Fields
+ *********/
+ /// <summary>The non-error issues with the mod, including warnings suppressed by the data record.</summary>
+ private ModWarning ActualWarnings = ModWarning.None;
+
+
+ /*********
** Accessors
*********/
/// <inheritdoc />
@@ -41,7 +48,7 @@ namespace StardewModdingAPI.Framework.ModLoading
public ModFailReason? FailReason { get; private set; }
/// <inheritdoc />
- public ModWarning Warnings { get; private set; }
+ public ModWarning Warnings => this.ActualWarnings & ~(this.DataRecord?.DataRecord.SuppressWarnings ?? ModWarning.None);
/// <inheritdoc />
public string Error { get; private set; }
@@ -116,7 +123,7 @@ namespace StardewModdingAPI.Framework.ModLoading
/// <inheritdoc />
public IModMetadata SetWarning(ModWarning warning)
{
- this.Warnings |= warning;
+ this.ActualWarnings |= warning;
return this;
}
@@ -218,12 +225,10 @@ namespace StardewModdingAPI.Framework.ModLoading
}
/// <inheritdoc />
- public bool HasUnsuppressedWarnings(params ModWarning[] warnings)
+ public bool HasWarnings(params ModWarning[] warnings)
{
- return warnings.Any(warning =>
- this.Warnings.HasFlag(warning)
- && (this.DataRecord?.DataRecord == null || !this.DataRecord.DataRecord.SuppressWarnings.HasFlag(warning))
- );
+ ModWarning curWarnings = this.Warnings;
+ return warnings.Any(warning => curWarnings.HasFlag(warning));
}
/// <inheritdoc />