pass mod info to GetApi instead

This commit is contained in:
Jesse Plamondon-Willard 2022-10-08 20:33:01 -04:00
parent a565ac9405
commit 8d6670cfc8
No known key found for this signature in database
GPG Key ID: CF8B1456B3E29F49
3 changed files with 5 additions and 5 deletions

View File

@ -85,7 +85,7 @@ namespace StardewModdingAPI.Framework.ModHelpers
{ {
try try
{ {
api = mod.Mod?.GetApi(this.Mod.Manifest); api = mod.Mod?.GetApi(this.Mod);
if (api != null && !api.GetType().IsPublic) if (api != null && !api.GetType().IsPublic)
{ {
api = null; api = null;

View File

@ -24,14 +24,14 @@ namespace StardewModdingAPI
void Entry(IModHelper helper); void Entry(IModHelper helper);
/// <summary>Get an <a href="https://stardewvalleywiki.com/Modding:Modder_Guide/APIs/Integrations">API that other mods can access</a>. This is always called after <see cref="Entry"/>, and is only called once even if multiple mods access it.</summary> /// <summary>Get an <a href="https://stardewvalleywiki.com/Modding:Modder_Guide/APIs/Integrations">API that other mods can access</a>. This is always called after <see cref="Entry"/>, and is only called once even if multiple mods access it.</summary>
/// <remarks>You can implement <see cref="GetApi()"/> to provide one instance to all mods, or <see cref="GetApi(IManifest)"/> to provide a separate instance per mod. These are mutually exclusive, so you can only implement one of them.</remarks> /// <remarks>You can implement <see cref="GetApi()"/> to provide one instance to all mods, or <see cref="GetApi(IModInfo)"/> to provide a separate instance per mod. These are mutually exclusive, so you can only implement one of them.</remarks>
/// <remarks>Returns the API instance, or <c>null</c> if the mod has no API.</remarks> /// <remarks>Returns the API instance, or <c>null</c> if the mod has no API.</remarks>
object? GetApi(); object? GetApi();
/// <summary>Get an <a href="https://stardewvalleywiki.com/Modding:Modder_Guide/APIs/Integrations">API that other mods can access</a>. This is always called after <see cref="Entry"/>, and is called once per mod that accesses the API (even if they access it multiple times).</summary> /// <summary>Get an <a href="https://stardewvalleywiki.com/Modding:Modder_Guide/APIs/Integrations">API that other mods can access</a>. This is always called after <see cref="Entry"/>, and is called once per mod that accesses the API (even if they access it multiple times).</summary>
/// <param name="manifest">The manifest for the mod accessing the API.</param> /// <param name="mod">The mod accessing the API.</param>
/// <remarks>Returns the API instance, or <c>null</c> if the mod has no API. Note that the manifest is provided for informational purposes only, and that denying API access to specific mods is strongly discouraged and may be considered abusive.</remarks> /// <remarks>Returns the API instance, or <c>null</c> if the mod has no API. Note that the manifest is provided for informational purposes only, and that denying API access to specific mods is strongly discouraged and may be considered abusive.</remarks>
/// <inheritdoc cref="GetApi()" include="/Remarks" /> /// <inheritdoc cref="GetApi()" include="/Remarks" />
object? GetApi(IManifest manifest); object? GetApi(IModInfo mod);
} }
} }

View File

@ -31,7 +31,7 @@ namespace StardewModdingAPI
} }
/// <inheritdoc /> /// <inheritdoc />
public virtual object? GetApi(IManifest manifest) public virtual object? GetApi(IModInfo mod)
{ {
return null; return null;
} }