summaryrefslogtreecommitdiff
path: root/src/StardewModdingAPI
diff options
context:
space:
mode:
Diffstat (limited to 'src/StardewModdingAPI')
-rw-r--r--src/StardewModdingAPI/Framework/IModMetadata.cs6
-rw-r--r--src/StardewModdingAPI/Framework/ModLoading/ModMetadata.cs12
-rw-r--r--src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs30
-rw-r--r--src/StardewModdingAPI/Framework/Models/ModDataID.cs (renamed from src/StardewModdingAPI/Framework/Models/ModCompatibilityID.cs)12
-rw-r--r--src/StardewModdingAPI/Framework/Models/ModDataRecord.cs (renamed from src/StardewModdingAPI/Framework/Models/ModCompatibility.cs)6
-rw-r--r--src/StardewModdingAPI/Framework/Models/SConfig.cs4
-rw-r--r--src/StardewModdingAPI/Framework/Serialisation/SFieldConverter.cs10
-rw-r--r--src/StardewModdingAPI/Program.cs4
-rw-r--r--src/StardewModdingAPI/StardewModdingAPI.config.json2
-rw-r--r--src/StardewModdingAPI/StardewModdingAPI.csproj4
10 files changed, 45 insertions, 45 deletions
diff --git a/src/StardewModdingAPI/Framework/IModMetadata.cs b/src/StardewModdingAPI/Framework/IModMetadata.cs
index 56ac25f1..c21734a7 100644
--- a/src/StardewModdingAPI/Framework/IModMetadata.cs
+++ b/src/StardewModdingAPI/Framework/IModMetadata.cs
@@ -1,4 +1,4 @@
-using StardewModdingAPI.Framework.Models;
+using StardewModdingAPI.Framework.Models;
using StardewModdingAPI.Framework.ModLoading;
namespace StardewModdingAPI.Framework
@@ -18,8 +18,8 @@ namespace StardewModdingAPI.Framework
/// <summary>The mod manifest.</summary>
IManifest Manifest { get; }
- /// <summary>Optional metadata about a mod version that SMAPI should assume is compatible or broken, regardless of whether it detects incompatible code.</summary>
- ModCompatibility Compatibility { get; }
+ /// <summary>>Metadata about the mod from SMAPI's internal data (if any).</summary>
+ ModDataRecord DataRecord { get; }
/// <summary>The metadata resolution status.</summary>
ModMetadataStatus Status { get; }
diff --git a/src/StardewModdingAPI/Framework/ModLoading/ModMetadata.cs b/src/StardewModdingAPI/Framework/ModLoading/ModMetadata.cs
index ab590e10..5055da75 100644
--- a/src/StardewModdingAPI/Framework/ModLoading/ModMetadata.cs
+++ b/src/StardewModdingAPI/Framework/ModLoading/ModMetadata.cs
@@ -1,4 +1,4 @@
-using StardewModdingAPI.Framework.Models;
+using StardewModdingAPI.Framework.Models;
namespace StardewModdingAPI.Framework.ModLoading
{
@@ -17,8 +17,8 @@ namespace StardewModdingAPI.Framework.ModLoading
/// <summary>The mod manifest.</summary>
public IManifest Manifest { get; }
- /// <summary>Optional metadata about a mod version that SMAPI should assume is compatible or broken, regardless of whether it detects incompatible code.</summary>
- public ModCompatibility Compatibility { get; }
+ /// <summary>Metadata about the mod from SMAPI's internal data (if any).</summary>
+ public ModDataRecord DataRecord { get; }
/// <summary>The metadata resolution status.</summary>
public ModMetadataStatus Status { get; private set; }
@@ -37,13 +37,13 @@ namespace StardewModdingAPI.Framework.ModLoading
/// <param name="displayName">The mod's display name.</param>
/// <param name="directoryPath">The mod's full directory path.</param>
/// <param name="manifest">The mod manifest.</param>
- /// <param name="compatibility">Optional metadata about a mod version that SMAPI should assume is compatible or broken, regardless of whether it detects incompatible code.</param>
- public ModMetadata(string displayName, string directoryPath, IManifest manifest, ModCompatibility compatibility)
+ /// <param name="dataRecord">Metadata about the mod from SMAPI's internal data (if any).</param>
+ public ModMetadata(string displayName, string directoryPath, IManifest manifest, ModDataRecord dataRecord)
{
this.DisplayName = displayName;
this.DirectoryPath = directoryPath;
this.Manifest = manifest;
- this.Compatibility = compatibility;
+ this.DataRecord = dataRecord;
}
/// <summary>Set the mod status.</summary>
diff --git a/src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs b/src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs
index 02fd85ea..2da10348 100644
--- a/src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs
+++ b/src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs
@@ -17,11 +17,11 @@ namespace StardewModdingAPI.Framework.ModLoading
/// <summary>Get manifest metadata for each folder in the given root path.</summary>
/// <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="dataRecords">Metadata about mods from SMAPI's internal data.</param>
/// <returns>Returns the manifests by relative folder.</returns>
- public IEnumerable<IModMetadata> ReadManifests(string rootPath, JsonHelper jsonHelper, IEnumerable<ModCompatibility> compatibilityRecords)
+ public IEnumerable<IModMetadata> ReadManifests(string rootPath, JsonHelper jsonHelper, IEnumerable<ModDataRecord> dataRecords)
{
- compatibilityRecords = compatibilityRecords.ToArray();
+ dataRecords = dataRecords.ToArray();
foreach (DirectoryInfo modDir in this.GetModFolders(rootPath))
{
@@ -54,15 +54,15 @@ namespace StardewModdingAPI.Framework.ModLoading
}
// validate metadata
- ModCompatibility compatibility = null;
+ ModDataRecord dataRecord = null;
if (manifest != null)
{
// get unique key for lookups
string key = !string.IsNullOrWhiteSpace(manifest.UniqueID) ? manifest.UniqueID : manifest.EntryDll;
- // get compatibility record
- compatibility = (
- from mod in compatibilityRecords
+ // get data record
+ dataRecord = (
+ from mod in dataRecords
where
mod.ID.Any(p => p.Matches(key, manifest))
&& (mod.LowerVersion == null || !manifest.Version.IsOlderThan(mod.LowerVersion))
@@ -79,7 +79,7 @@ namespace StardewModdingAPI.Framework.ModLoading
? ModMetadataStatus.Found
: ModMetadataStatus.Failed;
- yield return new ModMetadata(displayName, modDir.FullName, manifest, compatibility).SetStatus(status, error);
+ yield return new ModMetadata(displayName, modDir.FullName, manifest, dataRecord).SetStatus(status, error);
}
}
@@ -99,22 +99,22 @@ namespace StardewModdingAPI.Framework.ModLoading
// validate compatibility
{
- ModCompatibility compatibility = mod.Compatibility;
- switch (compatibility?.Status)
+ ModDataRecord dataRecord = mod.DataRecord;
+ switch (dataRecord?.Status)
{
case ModStatus.Obsolete:
- mod.SetStatus(ModMetadataStatus.Failed, $"it's obsolete: {compatibility.ReasonPhrase}");
+ mod.SetStatus(ModMetadataStatus.Failed, $"it's obsolete: {dataRecord.ReasonPhrase}");
continue;
case ModStatus.AssumeBroken:
{
- string reasonPhrase = compatibility.ReasonPhrase ?? "it's no longer compatible";
+ string reasonPhrase = dataRecord.ReasonPhrase ?? "it's no longer compatible";
string error = $"{reasonPhrase}. Please check for a ";
- if (mod.Manifest.Version.Equals(compatibility.UpperVersion) && compatibility.UpperVersionLabel == null)
+ if (mod.Manifest.Version.Equals(dataRecord.UpperVersion) && dataRecord.UpperVersionLabel == null)
error += "newer version";
else
- error += $"version newer than {compatibility.UpperVersionLabel ?? compatibility.UpperVersion.ToString()}";
- error += " at " + string.Join(" or ", compatibility.UpdateUrls);
+ error += $"version newer than {dataRecord.UpperVersionLabel ?? dataRecord.UpperVersion.ToString()}";
+ error += " at " + string.Join(" or ", dataRecord.UpdateUrls);
mod.SetStatus(ModMetadataStatus.Failed, error);
continue;
diff --git a/src/StardewModdingAPI/Framework/Models/ModCompatibilityID.cs b/src/StardewModdingAPI/Framework/Models/ModDataID.cs
index 98e70116..5b45b507 100644
--- a/src/StardewModdingAPI/Framework/Models/ModCompatibilityID.cs
+++ b/src/StardewModdingAPI/Framework/Models/ModDataID.cs
@@ -1,10 +1,10 @@
-using System;
+using System;
using Newtonsoft.Json;
namespace StardewModdingAPI.Framework.Models
{
- /// <summary>Uniquely identifies a mod for compatibility checks.</summary>
- internal class ModCompatibilityID
+ /// <summary>Uniquely identifies a mod in SMAPI's internal data.</summary>
+ internal class ModDataID
{
/*********
** Accessors
@@ -23,11 +23,11 @@ namespace StardewModdingAPI.Framework.Models
** Public methods
*********/
/// <summary>Construct an instance.</summary>
- public ModCompatibilityID() { }
+ public ModDataID() { }
/// <summary>Construct an instance.</summary>
- /// <param name="data">The mod ID or a JSON string matching the <see cref="ModCompatibilityID"/> fields.</param>
- public ModCompatibilityID(string data)
+ /// <param name="data">The mod ID or a JSON string matching the <see cref="ModDataID"/> fields.</param>
+ public ModDataID(string data)
{
// JSON can be stuffed into the ID string as a convenience hack to keep JSON mod lists
// formatted readably. The tradeoff is that the format is a bit more magical, but that's
diff --git a/src/StardewModdingAPI/Framework/Models/ModCompatibility.cs b/src/StardewModdingAPI/Framework/Models/ModDataRecord.cs
index 7489a306..d40f2c78 100644
--- a/src/StardewModdingAPI/Framework/Models/ModCompatibility.cs
+++ b/src/StardewModdingAPI/Framework/Models/ModDataRecord.cs
@@ -3,15 +3,15 @@ using StardewModdingAPI.Framework.Serialisation;
namespace StardewModdingAPI.Framework.Models
{
- /// <summary>Metadata about a mod version that SMAPI should assume is compatible or broken, regardless of whether it detects incompatible code.</summary>
- internal class ModCompatibility
+ /// <summary>Metadata about a mod from SMAPI's internal data.</summary>
+ internal class ModDataRecord
{
/*********
** Accessors
*********/
/// <summary>The unique mod IDs.</summary>
[JsonConverter(typeof(SFieldConverter))]
- public ModCompatibilityID[] ID { get; set; }
+ public ModDataID[] ID { get; set; }
/// <summary>The mod name.</summary>
public string Name { get; set; }
diff --git a/src/StardewModdingAPI/Framework/Models/SConfig.cs b/src/StardewModdingAPI/Framework/Models/SConfig.cs
index 720d4a6d..401e1a3a 100644
--- a/src/StardewModdingAPI/Framework/Models/SConfig.cs
+++ b/src/StardewModdingAPI/Framework/Models/SConfig.cs
@@ -21,7 +21,7 @@ namespace StardewModdingAPI.Framework.Models
/// <summary>Whether SMAPI should log more information about the game context.</summary>
public bool VerboseLogging { get; set; }
- /// <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>Extra metadata about mods.</summary>
+ public ModDataRecord[] ModData { get; set; }
}
}
diff --git a/src/StardewModdingAPI/Framework/Serialisation/SFieldConverter.cs b/src/StardewModdingAPI/Framework/Serialisation/SFieldConverter.cs
index 5419896f..59cc1582 100644
--- a/src/StardewModdingAPI/Framework/Serialisation/SFieldConverter.cs
+++ b/src/StardewModdingAPI/Framework/Serialisation/SFieldConverter.cs
@@ -27,7 +27,7 @@ namespace StardewModdingAPI.Framework.Serialisation
return
objectType == typeof(ISemanticVersion)
|| objectType == typeof(IManifestDependency[])
- || objectType == typeof(ModCompatibilityID[]);
+ || objectType == typeof(ModDataID[]);
}
/// <summary>Reads the JSON representation of the object.</summary>
@@ -83,14 +83,14 @@ namespace StardewModdingAPI.Framework.Serialisation
}
// mod compatibility ID
- if (objectType == typeof(ModCompatibilityID[]))
+ if (objectType == typeof(ModDataID[]))
{
- List<ModCompatibilityID> result = new List<ModCompatibilityID>();
+ List<ModDataID> result = new List<ModDataID>();
foreach (JToken child in JArray.Load(reader).Children())
{
result.Add(child is JValue value
- ? new ModCompatibilityID(value.Value<string>())
- : child.ToObject<ModCompatibilityID>()
+ ? new ModDataID(value.Value<string>())
+ : child.ToObject<ModDataID>()
);
}
return result.ToArray();
diff --git a/src/StardewModdingAPI/Program.cs b/src/StardewModdingAPI/Program.cs
index b22fb02a..63176dd1 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).ToArray();
+ IModMetadata[] mods = resolver.ReadManifests(Constants.ModPath, new JsonHelper(), this.Settings.ModData).ToArray();
resolver.ValidateManifests(mods, Constants.ApiVersion);
// process dependencies
@@ -640,7 +640,7 @@ namespace StardewModdingAPI
Assembly modAssembly;
try
{
- modAssembly = modAssemblyLoader.Load(metadata, assemblyPath, assumeCompatible: metadata.Compatibility?.Status == ModStatus.AssumeCompatible);
+ modAssembly = modAssemblyLoader.Load(metadata, assemblyPath, assumeCompatible: metadata.DataRecord?.Status == ModStatus.AssumeCompatible);
}
catch (IncompatibleInstructionException ex)
{
diff --git a/src/StardewModdingAPI/StardewModdingAPI.config.json b/src/StardewModdingAPI/StardewModdingAPI.config.json
index 7c20a9d9..aa6df389 100644
--- a/src/StardewModdingAPI/StardewModdingAPI.config.json
+++ b/src/StardewModdingAPI/StardewModdingAPI.config.json
@@ -44,7 +44,7 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha
* load a mod regardless of compatibility checks, add a "Compatibility": "AssumeCompatible" field.
* Changing this field is not recommended and may destabilise your game.
*/
- "ModCompatibility": [
+ "ModData": [
{
"Name": "AccessChestAnywhere",
"ID": [ "AccessChestAnywhere" ],
diff --git a/src/StardewModdingAPI/StardewModdingAPI.csproj b/src/StardewModdingAPI/StardewModdingAPI.csproj
index 818e7263..38064f98 100644
--- a/src/StardewModdingAPI/StardewModdingAPI.csproj
+++ b/src/StardewModdingAPI/StardewModdingAPI.csproj
@@ -142,7 +142,7 @@
<Compile Include="Framework\Utilities\Countdown.cs" />
<Compile Include="Framework\GameVersion.cs" />
<Compile Include="Framework\IModMetadata.cs" />
- <Compile Include="Framework\Models\ModCompatibilityID.cs" />
+ <Compile Include="Framework\Models\ModDataID.cs" />
<Compile Include="Framework\ModHelpers\BaseHelper.cs" />
<Compile Include="Framework\ModHelpers\CommandHelper.cs" />
<Compile Include="Framework\ModHelpers\ContentHelper.cs" />
@@ -194,7 +194,7 @@
<Compile Include="Framework\DeprecationLevel.cs" />
<Compile Include="Framework\DeprecationManager.cs" />
<Compile Include="Framework\InternalExtensions.cs" />
- <Compile Include="Framework\Models\ModCompatibility.cs" />
+ <Compile Include="Framework\Models\ModDataRecord.cs" />
<Compile Include="Framework\ModLoading\AssemblyLoader.cs" />
<Compile Include="Framework\Reflection\CacheEntry.cs" />
<Compile Include="Framework\Reflection\PrivateField.cs" />