summaryrefslogtreecommitdiff
path: root/src/StardewModdingAPI/Framework
diff options
context:
space:
mode:
Diffstat (limited to 'src/StardewModdingAPI/Framework')
-rw-r--r--src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs29
-rw-r--r--src/StardewModdingAPI/Framework/Models/ModDataDefaults.cs18
-rw-r--r--src/StardewModdingAPI/Framework/Models/ModDataRecord.cs7
3 files changed, 47 insertions, 7 deletions
diff --git a/src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs b/src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs
index 31ba5bc5..4d20e7c8 100644
--- a/src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs
+++ b/src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs
@@ -53,17 +53,22 @@ namespace StardewModdingAPI.Framework.ModLoading
error = $"parsing its manifest failed:\n{ex.GetLogSummary()}";
}
- // validate metadata
+ // get internal data record (if any)
ModDataRecord dataRecord = null;
if (manifest != null)
{
- // get unique key for lookups
string key = !string.IsNullOrWhiteSpace(manifest.UniqueID) ? manifest.UniqueID : manifest.EntryDll;
-
- // get data record
dataRecord = dataRecords.FirstOrDefault(record => record.ID.Matches(key, manifest));
}
+ // apply defaults
+ if (dataRecord?.Defaults != null)
+ {
+ manifest.ChucklefishID = manifest.ChucklefishID ?? dataRecord.Defaults.ChucklefishID;
+ manifest.GitHubProject = manifest.GitHubProject ?? dataRecord.Defaults.GitHubProject;
+ manifest.NexusID = manifest.NexusID ?? dataRecord.Defaults.NexusID;
+ }
+
// build metadata
string displayName = !string.IsNullOrWhiteSpace(manifest?.Name)
? manifest.Name
@@ -100,13 +105,27 @@ namespace StardewModdingAPI.Framework.ModLoading
case ModStatus.AssumeBroken:
{
+ // get reason
string reasonPhrase = compatibility.ReasonPhrase ?? "it's no longer compatible";
+
+ // get update URLs
+ List<string> updateUrls = new List<string>();
+ if (!string.IsNullOrWhiteSpace(mod.Manifest.ChucklefishID))
+ updateUrls.Add($"https://community.playstarbound.com/resources/{mod.Manifest.ChucklefishID}");
+ if (!string.IsNullOrWhiteSpace(mod.Manifest.NexusID))
+ updateUrls.Add($"http://nexusmods.com/stardewvalley/mods/{mod.Manifest.NexusID}");
+ if (!string.IsNullOrWhiteSpace(mod.Manifest.GitHubProject))
+ updateUrls.Add($"https://github.com/{mod.Manifest.GitHubProject}/releases");
+ if (mod.DataRecord.AlternativeUrl != null)
+ updateUrls.Add(mod.DataRecord.AlternativeUrl);
+
+ // build error
string error = $"{reasonPhrase}. Please check for a ";
if (mod.Manifest.Version.Equals(compatibility.UpperVersion))
error += "newer version";
else
error += $"version newer than {compatibility.UpperVersion}";
- error += " at " + string.Join(" or ", mod.DataRecord.UpdateUrls);
+ error += " at " + string.Join(" or ", updateUrls);
mod.SetStatus(ModMetadataStatus.Failed, error);
}
diff --git a/src/StardewModdingAPI/Framework/Models/ModDataDefaults.cs b/src/StardewModdingAPI/Framework/Models/ModDataDefaults.cs
new file mode 100644
index 00000000..e0ab94b8
--- /dev/null
+++ b/src/StardewModdingAPI/Framework/Models/ModDataDefaults.cs
@@ -0,0 +1,18 @@
+namespace StardewModdingAPI.Framework.Models
+{
+ /// <summary>Default values for support fields to inject into the manifest.</summary>
+ internal class ModDataDefaults
+ {
+ /*********
+ ** Accessors
+ *********/
+ /// <summary>The mod's unique ID in the Chucklefish mod site (if any), used for update checks.</summary>
+ public string ChucklefishID { get; set; }
+
+ /// <summary>The mod's unique ID in Nexus Mods (if any), used for update checks.</summary>
+ public string NexusID { get; set; }
+
+ /// <summary>The mod's organisation and project name on GitHub (if any), used for update checks.</summary>
+ public string GitHubProject { get; set; }
+ }
+}
diff --git a/src/StardewModdingAPI/Framework/Models/ModDataRecord.cs b/src/StardewModdingAPI/Framework/Models/ModDataRecord.cs
index de219076..9f19d5f0 100644
--- a/src/StardewModdingAPI/Framework/Models/ModDataRecord.cs
+++ b/src/StardewModdingAPI/Framework/Models/ModDataRecord.cs
@@ -17,8 +17,11 @@ namespace StardewModdingAPI.Framework.Models
/// <summary>The mod name.</summary>
public string Name { get; set; }
- /// <summary>The URLs the user can check for a newer version.</summary>
- public string[] UpdateUrls { get; set; }
+ /// <summary>Default values for support fields to inject into the manifest.</summary>
+ public ModDataDefaults Defaults { get; set; }
+
+ /// <summary>The URL where the player can get an unofficial or alternative version of the mod if the official version isn't compatible.</summary>
+ public string AlternativeUrl { get; set; }
/// <summary>The compatibility of given mod versions (if any).</summary>
[JsonConverter(typeof(SFieldConverter))]