summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/StardewModdingAPI.Tests/Core/ModResolverTests.cs6
-rw-r--r--src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs40
-rw-r--r--src/StardewModdingAPI/Framework/Models/DisabledMod.cs22
-rw-r--r--src/StardewModdingAPI/Framework/Models/ModStatus.cs9
-rw-r--r--src/StardewModdingAPI/Framework/Models/SConfig.cs3
-rw-r--r--src/StardewModdingAPI/Program.cs2
-rw-r--r--src/StardewModdingAPI/StardewModdingAPI.config.json76
-rw-r--r--src/StardewModdingAPI/StardewModdingAPI.csproj1
8 files changed, 68 insertions, 91 deletions
diff --git a/src/StardewModdingAPI.Tests/Core/ModResolverTests.cs b/src/StardewModdingAPI.Tests/Core/ModResolverTests.cs
index bc3a0c8c..198ce190 100644
--- a/src/StardewModdingAPI.Tests/Core/ModResolverTests.cs
+++ b/src/StardewModdingAPI.Tests/Core/ModResolverTests.cs
@@ -30,7 +30,7 @@ namespace StardewModdingAPI.Tests.Core
Directory.CreateDirectory(rootFolder);
// act
- IModMetadata[] mods = new ModResolver().ReadManifests(rootFolder, new JsonHelper(), new ModCompatibility[0], new DisabledMod[0]).ToArray();
+ IModMetadata[] mods = new ModResolver().ReadManifests(rootFolder, new JsonHelper(), new ModCompatibility[0]).ToArray();
// assert
Assert.AreEqual(0, mods.Length, 0, $"Expected to find zero manifests, found {mods.Length} instead.");
@@ -45,7 +45,7 @@ namespace StardewModdingAPI.Tests.Core
Directory.CreateDirectory(modFolder);
// act
- IModMetadata[] mods = new ModResolver().ReadManifests(rootFolder, new JsonHelper(), new ModCompatibility[0], new DisabledMod[0]).ToArray();
+ IModMetadata[] mods = new ModResolver().ReadManifests(rootFolder, new JsonHelper(), new ModCompatibility[0]).ToArray();
IModMetadata mod = mods.FirstOrDefault();
// assert
@@ -84,7 +84,7 @@ namespace StardewModdingAPI.Tests.Core
File.WriteAllText(filename, JsonConvert.SerializeObject(original));
// act
- IModMetadata[] mods = new ModResolver().ReadManifests(rootFolder, new JsonHelper(), new ModCompatibility[0], new DisabledMod[0]).ToArray();
+ IModMetadata[] mods = new ModResolver().ReadManifests(rootFolder, new JsonHelper(), new ModCompatibility[0]).ToArray();
IModMetadata mod = mods.FirstOrDefault();
// assert
diff --git a/src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs b/src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs
index 6a971c15..02fd85ea 100644
--- a/src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs
+++ b/src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs
@@ -18,12 +18,10 @@ namespace StardewModdingAPI.Framework.ModLoading
/// <param name="rootPath">The root path to search for mods.</param>
/// <param name="jsonHelper">The JSON helper with which to read manifests.</param>
/// <param name="compatibilityRecords">Metadata about mods that SMAPI should assume is compatible or broken, regardless of whether it detects incompatible code.</param>
- /// <param name="disabledMods">Metadata about mods that SMAPI should consider obsolete and not load.</param>
/// <returns>Returns the manifests by relative folder.</returns>
- public IEnumerable<IModMetadata> ReadManifests(string rootPath, JsonHelper jsonHelper, IEnumerable<ModCompatibility> compatibilityRecords, IEnumerable<DisabledMod> disabledMods)
+ public IEnumerable<IModMetadata> ReadManifests(string rootPath, JsonHelper jsonHelper, IEnumerable<ModCompatibility> compatibilityRecords)
{
compatibilityRecords = compatibilityRecords.ToArray();
- disabledMods = disabledMods.ToArray();
foreach (DirectoryInfo modDir in this.GetModFolders(rootPath))
{
@@ -62,18 +60,13 @@ namespace StardewModdingAPI.Framework.ModLoading
// get unique key for lookups
string key = !string.IsNullOrWhiteSpace(manifest.UniqueID) ? manifest.UniqueID : manifest.EntryDll;
- // check if mod should be disabled
- DisabledMod disabledMod = disabledMods.FirstOrDefault(mod => mod.ID.Contains(key, StringComparer.InvariantCultureIgnoreCase));
- if (disabledMod != null)
- error = $"it's obsolete: {disabledMod.ReasonPhrase}";
-
// get compatibility record
compatibility = (
from mod in compatibilityRecords
where
mod.ID.Any(p => p.Matches(key, manifest))
&& (mod.LowerVersion == null || !manifest.Version.IsOlderThan(mod.LowerVersion))
- && !manifest.Version.IsNewerThan(mod.UpperVersion)
+ && (mod.UpperVersion == null || !manifest.Version.IsNewerThan(mod.UpperVersion))
select mod
).FirstOrDefault();
}
@@ -107,18 +100,25 @@ namespace StardewModdingAPI.Framework.ModLoading
// validate compatibility
{
ModCompatibility compatibility = mod.Compatibility;
- if (compatibility?.Status == ModStatus.AssumeBroken)
+ switch (compatibility?.Status)
{
- string reasonPhrase = compatibility.ReasonPhrase ?? "it's no longer compatible";
- string error = $"{reasonPhrase}. Please check for a ";
- if (mod.Manifest.Version.Equals(compatibility.UpperVersion) && compatibility.UpperVersionLabel == null)
- error += "newer version";
- else
- error += $"version newer than {compatibility.UpperVersionLabel ?? compatibility.UpperVersion.ToString()}";
- error += " at " + string.Join(" or ", compatibility.UpdateUrls);
-
- mod.SetStatus(ModMetadataStatus.Failed, error);
- continue;
+ case ModStatus.Obsolete:
+ mod.SetStatus(ModMetadataStatus.Failed, $"it's obsolete: {compatibility.ReasonPhrase}");
+ continue;
+
+ case ModStatus.AssumeBroken:
+ {
+ string reasonPhrase = compatibility.ReasonPhrase ?? "it's no longer compatible";
+ string error = $"{reasonPhrase}. Please check for a ";
+ if (mod.Manifest.Version.Equals(compatibility.UpperVersion) && compatibility.UpperVersionLabel == null)
+ error += "newer version";
+ else
+ error += $"version newer than {compatibility.UpperVersionLabel ?? compatibility.UpperVersion.ToString()}";
+ error += " at " + string.Join(" or ", compatibility.UpdateUrls);
+
+ mod.SetStatus(ModMetadataStatus.Failed, error);
+ continue;
+ }
}
}
diff --git a/src/StardewModdingAPI/Framework/Models/DisabledMod.cs b/src/StardewModdingAPI/Framework/Models/DisabledMod.cs
deleted file mode 100644
index 170fa760..00000000
--- a/src/StardewModdingAPI/Framework/Models/DisabledMod.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-namespace StardewModdingAPI.Framework.Models
-{
- /// <summary>Metadata about for a mod that should never be loaded.</summary>
- internal class DisabledMod
- {
- /*********
- ** Accessors
- *********/
- /****
- ** From config
- ****/
- /// <summary>The unique mod IDs.</summary>
- public string[] ID { get; set; }
-
- /// <summary>The mod name.</summary>
- public string Name { get; set; }
-
- /// <summary>The reason phrase to show in the warning, or <c>null</c> to use the default value.</summary>
- /// <example>"this mod is no longer supported or used"</example>
- public string ReasonPhrase { get; set; }
- }
-}
diff --git a/src/StardewModdingAPI/Framework/Models/ModStatus.cs b/src/StardewModdingAPI/Framework/Models/ModStatus.cs
index 4ab0b790..343ccb7e 100644
--- a/src/StardewModdingAPI/Framework/Models/ModStatus.cs
+++ b/src/StardewModdingAPI/Framework/Models/ModStatus.cs
@@ -4,12 +4,15 @@ namespace StardewModdingAPI.Framework.Models
internal enum ModStatus
{
/// <summary>Don't override the status.</summary>
- None = 0,
+ None,
+
+ /// <summary>The mod is obsolete and shouldn't be used, regardless of version.</summary>
+ Obsolete,
/// <summary>Assume the mod is not compatible, even if SMAPI doesn't detect any incompatible code.</summary>
- AssumeBroken = 0,
+ AssumeBroken,
/// <summary>Assume the mod is compatible, even if SMAPI detects incompatible code.</summary>
- AssumeCompatible = 1
+ AssumeCompatible
}
}
diff --git a/src/StardewModdingAPI/Framework/Models/SConfig.cs b/src/StardewModdingAPI/Framework/Models/SConfig.cs
index 36799400..720d4a6d 100644
--- a/src/StardewModdingAPI/Framework/Models/SConfig.cs
+++ b/src/StardewModdingAPI/Framework/Models/SConfig.cs
@@ -23,8 +23,5 @@ namespace StardewModdingAPI.Framework.Models
/// <summary>A list of mod versions which should be considered compatible or incompatible regardless of whether SMAPI detects incompatible code.</summary>
public ModCompatibility[] ModCompatibility { get; set; }
-
- /// <summary>A list of mods which should be considered obsolete and not loaded.</summary>
- public DisabledMod[] DisabledMods { get; set; }
}
}
diff --git a/src/StardewModdingAPI/Program.cs b/src/StardewModdingAPI/Program.cs
index 234572a6..b22fb02a 100644
--- a/src/StardewModdingAPI/Program.cs
+++ b/src/StardewModdingAPI/Program.cs
@@ -347,7 +347,7 @@ namespace StardewModdingAPI
ModResolver resolver = new ModResolver();
// load manifests
- IModMetadata[] mods = resolver.ReadManifests(Constants.ModPath, new JsonHelper(), this.Settings.ModCompatibility, this.Settings.DisabledMods).ToArray();
+ IModMetadata[] mods = resolver.ReadManifests(Constants.ModPath, new JsonHelper(), this.Settings.ModCompatibility).ToArray();
resolver.ValidateManifests(mods, Constants.ApiVersion);
// process dependencies
diff --git a/src/StardewModdingAPI/StardewModdingAPI.config.json b/src/StardewModdingAPI/StardewModdingAPI.config.json
index e5c42391..7c20a9d9 100644
--- a/src/StardewModdingAPI/StardewModdingAPI.config.json
+++ b/src/StardewModdingAPI/StardewModdingAPI.config.json
@@ -28,7 +28,8 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha
/**
* The base URL for SMAPI's web API, used to perform update checks.
- * Note: the protocol will be changed to http:// on Linux/Mac due to OpenSSL issues with the game's bundled Mono.
+ * Note: the protocol will be changed to http:// on Linux/Mac due to OpenSSL issues with the
+ * game's bundled Mono.
*/
"WebApiBaseUrl": "https://api.smapi.io",
@@ -38,43 +39,6 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha
"VerboseLogging": false,
/**
- * A list of mods SMAPI should consider obsolete and not load. Changing this field is not
- * recommended and may destabilise your game.
- */
- "DisabledMods": [
- {
- "Name": "Animal Mood Fix",
- "ID": [ "GPeters-AnimalMoodFix" ],
- "ReasonPhrase": "the animal mood bugs were fixed in Stardew Valley 1.2."
- },
- {
- "Name": "Colored Chests",
- "ID": [ "4befde5c-731c-4853-8e4b-c5cdf946805f" ],
- "ReasonPhrase": "colored chests were added in Stardew Valley 1.1."
- },
- {
- "Name": "Modder Serialization Utility",
- "ID": [ "SerializerUtils-0-1" ],
- "ReasonPhrase": "it's no longer maintained or used."
- },
- {
- "Name": "No Debug Mode",
- "ID": [ "NoDebugMode" ],
- "ReasonPhrase": "debug mode was removed in SMAPI 1.0."
- },
- {
- "Name": "StarDustCore",
- "ID": [ "StarDustCore" ],
- "ReasonPhrase": "it was only used by earlier versions of Save Anywhere, and is no longer used or maintained."
- },
- {
- "Name": "XmlSerializerRetool",
- "ID": [ "XmlSerializerRetool.dll" ],
- "ReasonPhrase": "it's no longer maintained or used."
- }
- ],
-
- /**
* A list of mod versions SMAPI should consider compatible or broken regardless of whether it
* detects incompatible code. The default for each record is to assume broken; to force SMAPI to
* load a mod regardless of compatibility checks, add a "Compatibility": "AssumeCompatible" field.
@@ -118,6 +82,12 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha
"Notes": "Broke in SDV 1.2."
},
{
+ "Name": "Animal Mood Fix",
+ "ID": [ "GPeters-AnimalMoodFix" ],
+ "Status": "Obsolete",
+ "ReasonPhrase": "the animal mood bugs were fixed in Stardew Valley 1.2."
+ },
+ {
"Name": "Animal Sitter",
"ID": [ "AnimalSitter.dll" ],
"UpperVersion": "1.0.8",
@@ -244,6 +214,12 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha
"Notes": "Broke in SMAPI 2.0."
},
{
+ "Name": "Colored Chests",
+ "ID": [ "4befde5c-731c-4853-8e4b-c5cdf946805f" ],
+ "Status": "Obsolete",
+ "ReasonPhrase": "colored chests were added in Stardew Valley 1.1."
+ },
+ {
"Name": "Combat with Farm Implements",
"ID": [ "SPDFarmingImplementsInCombat" ],
"UpperVersion": "1.0",
@@ -524,6 +500,12 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha
"Notes": "Broke in SMAPI 2.0."
},
{
+ "Name": "Modder Serialization Utility",
+ "ID": [ "SerializerUtils-0-1" ],
+ "Status": "Obsolete",
+ "ReasonPhrase": "it's no longer maintained or used."
+ },
+ {
"Name": "More Artifact Spots",
"ID": [ "451" ],
"UpperVersion": "1.0.1",
@@ -573,6 +555,12 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha
"Notes": "Broke in SMAPI 2.0."
},
{
+ "Name": "No Debug Mode",
+ "ID": [ "NoDebugMode" ],
+ "Status": "Obsolete",
+ "ReasonPhrase": "debug mode was removed in SMAPI 1.0."
+ },
+ {
"Name": "NoSoilDecay",
"ID": [ "289dee03-5f38-4d8e-8ffc-e440198e8610" ],
"UpperVersion": "0.5",
@@ -854,6 +842,12 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha
"Notes": "Broke in SMAPI 2.0."
},
{
+ "Name": "StarDustCore",
+ "ID": [ "StarDustCore" ],
+ "Status": "Obsolete",
+ "ReasonPhrase": "it was only used by earlier versions of Save Anywhere, and is no longer used or maintained."
+ },
+ {
"Name": "StashItemsToChest",
"ID": [ "BlueMod_StashItemsToChest" ],
"UpperVersion": "1.0.1",
@@ -939,6 +933,12 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha
"Notes": "Broke in SDV 1.1 or 1.11."
},
{
+ "Name": "XmlSerializerRetool",
+ "ID": [ "XmlSerializerRetool.dll" ],
+ "Status": "Obsolete",
+ "ReasonPhrase": "it's no longer maintained or used."
+ },
+ {
"Name": "Xnb Loader",
"ID": [ "Entoarox.XnbLoader" ],
"UpperVersion": "1.0.6",
diff --git a/src/StardewModdingAPI/StardewModdingAPI.csproj b/src/StardewModdingAPI/StardewModdingAPI.csproj
index 46f2ffb1..818e7263 100644
--- a/src/StardewModdingAPI/StardewModdingAPI.csproj
+++ b/src/StardewModdingAPI/StardewModdingAPI.csproj
@@ -142,7 +142,6 @@
<Compile Include="Framework\Utilities\Countdown.cs" />
<Compile Include="Framework\GameVersion.cs" />
<Compile Include="Framework\IModMetadata.cs" />
- <Compile Include="Framework\Models\DisabledMod.cs" />
<Compile Include="Framework\Models\ModCompatibilityID.cs" />
<Compile Include="Framework\ModHelpers\BaseHelper.cs" />
<Compile Include="Framework\ModHelpers\CommandHelper.cs" />