summaryrefslogtreecommitdiff
path: root/src/SMAPI/Framework
diff options
context:
space:
mode:
Diffstat (limited to 'src/SMAPI/Framework')
-rw-r--r--src/SMAPI/Framework/IModMetadata.cs4
-rw-r--r--src/SMAPI/Framework/ModLoading/AssemblyLoader.cs1
-rw-r--r--src/SMAPI/Framework/ModLoading/ModMetadata.cs9
-rw-r--r--src/SMAPI/Framework/ModLoading/ModWarning.cs37
-rw-r--r--src/SMAPI/Framework/SCore.cs4
5 files changed, 17 insertions, 38 deletions
diff --git a/src/SMAPI/Framework/IModMetadata.cs b/src/SMAPI/Framework/IModMetadata.cs
index 7ada7dea..38514959 100644
--- a/src/SMAPI/Framework/IModMetadata.cs
+++ b/src/SMAPI/Framework/IModMetadata.cs
@@ -98,5 +98,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 a given warning and it hasn't been suppressed in the <see cref="DataRecord"/>.</summary>
+ /// <param name="warning">The warning to check.</param>
+ bool HasUnsuppressWarning(ModWarning warning);
}
}
diff --git a/src/SMAPI/Framework/ModLoading/AssemblyLoader.cs b/src/SMAPI/Framework/ModLoading/AssemblyLoader.cs
index 5e0571a0..878b3148 100644
--- a/src/SMAPI/Framework/ModLoading/AssemblyLoader.cs
+++ b/src/SMAPI/Framework/ModLoading/AssemblyLoader.cs
@@ -8,6 +8,7 @@ using Mono.Cecil.Cil;
using StardewModdingAPI.Framework.Exceptions;
using StardewModdingAPI.Internal;
using StardewModdingAPI.Metadata;
+using StardewModdingAPI.Toolkit.Framework.ModData;
namespace StardewModdingAPI.Framework.ModLoading
{
diff --git a/src/SMAPI/Framework/ModLoading/ModMetadata.cs b/src/SMAPI/Framework/ModLoading/ModMetadata.cs
index 0cb62a75..4ff021b7 100644
--- a/src/SMAPI/Framework/ModLoading/ModMetadata.cs
+++ b/src/SMAPI/Framework/ModLoading/ModMetadata.cs
@@ -179,5 +179,14 @@ namespace StardewModdingAPI.Framework.ModLoading
{
return this.GetUpdateKeys(validOnly: true).Any();
}
+
+ /// <summary>Get whether the mod has a given warning and it hasn't been suppressed in the <see cref="DataRecord"/>.</summary>
+ /// <param name="warning">The warning to check.</param>
+ public bool HasUnsuppressWarning(ModWarning warning)
+ {
+ return
+ this.Warnings.HasFlag(warning)
+ && (this.DataRecord?.DataRecord == null || !this.DataRecord.DataRecord.SuppressWarnings.HasFlag(warning));
+ }
}
}
diff --git a/src/SMAPI/Framework/ModLoading/ModWarning.cs b/src/SMAPI/Framework/ModLoading/ModWarning.cs
deleted file mode 100644
index e643cb05..00000000
--- a/src/SMAPI/Framework/ModLoading/ModWarning.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-using System;
-using StardewModdingAPI.Events;
-
-namespace StardewModdingAPI.Framework.ModLoading
-{
- /// <summary>Indicates a detected non-error mod issue.</summary>
- [Flags]
- internal enum ModWarning
- {
- /// <summary>No issues detected.</summary>
- None = 0,
-
- /// <summary>SMAPI detected incompatible code in the mod, but was configured to load it anyway.</summary>
- BrokenCodeLoaded = 1,
-
- /// <summary>The mod affects the save serializer in a way that may make saves unloadable without the mod.</summary>
- ChangesSaveSerialiser = 2,
-
- /// <summary>The mod patches the game in a way that may impact stability.</summary>
- PatchesGame = 4,
-
- /// <summary>The mod uses the <c>dynamic</c> keyword which won't work on Linux/Mac.</summary>
- UsesDynamic = 8,
-
- /// <summary>The mod references <see cref="ISpecialisedEvents.UnvalidatedUpdateTicking"/> or <see cref="ISpecialisedEvents.UnvalidatedUpdateTicked"/> which may impact stability.</summary>
- UsesUnvalidatedUpdateTick = 16,
-
- /// <summary>The mod has no update keys set.</summary>
- NoUpdateKeys = 32,
-
- /// <summary>Uses .NET APIs for filesystem access.</summary>
- AccessesFilesystem = 64,
-
- /// <summary>Uses .NET APIs for shell or process access.</summary>
- AccessesShell = 128
- }
-}
diff --git a/src/SMAPI/Framework/SCore.cs b/src/SMAPI/Framework/SCore.cs
index e0347eb2..9ffa46a5 100644
--- a/src/SMAPI/Framework/SCore.cs
+++ b/src/SMAPI/Framework/SCore.cs
@@ -1107,7 +1107,9 @@ namespace StardewModdingAPI.Framework
// issue block format logic
void LogWarningGroup(ModWarning warning, LogLevel logLevel, string heading, params string[] blurb)
{
- IModMetadata[] matches = modsWithWarnings.Where(p => p.Warnings.HasFlag(warning)).ToArray();
+ IModMetadata[] matches = modsWithWarnings
+ .Where(mod => mod.HasUnsuppressWarning(warning))
+ .ToArray();
if (!matches.Any())
return;