From e8da8fff5163eacd6ae7870eaa8c7dbc8285e3e7 Mon Sep 17 00:00:00 2001 From: Khloe Leclair Date: Mon, 26 Sep 2022 15:18:36 -0400 Subject: Initial work on a way for mods to return specific API instances to specific mods. --- src/SMAPI/Mod.cs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/SMAPI/Mod.cs') diff --git a/src/SMAPI/Mod.cs b/src/SMAPI/Mod.cs index f764752b..1a5f5594 100644 --- a/src/SMAPI/Mod.cs +++ b/src/SMAPI/Mod.cs @@ -30,6 +30,12 @@ namespace StardewModdingAPI return null; } + /// + public virtual object? GetApi(IManifest manifest) + { + return null; + } + /// Release or reset unmanaged resources. public void Dispose() { -- cgit From 8d6670cfc8abf7e71197d2f621314fb04a0543b8 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 8 Oct 2022 20:33:01 -0400 Subject: pass mod info to GetApi instead --- src/SMAPI/Framework/ModHelpers/ModRegistryHelper.cs | 2 +- src/SMAPI/IMod.cs | 6 +++--- src/SMAPI/Mod.cs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/SMAPI/Mod.cs') diff --git a/src/SMAPI/Framework/ModHelpers/ModRegistryHelper.cs b/src/SMAPI/Framework/ModHelpers/ModRegistryHelper.cs index 8cc73481..93edd597 100644 --- a/src/SMAPI/Framework/ModHelpers/ModRegistryHelper.cs +++ b/src/SMAPI/Framework/ModHelpers/ModRegistryHelper.cs @@ -85,7 +85,7 @@ namespace StardewModdingAPI.Framework.ModHelpers { try { - api = mod.Mod?.GetApi(this.Mod.Manifest); + api = mod.Mod?.GetApi(this.Mod); if (api != null && !api.GetType().IsPublic) { api = null; diff --git a/src/SMAPI/IMod.cs b/src/SMAPI/IMod.cs index 4576246a..19d01311 100644 --- a/src/SMAPI/IMod.cs +++ b/src/SMAPI/IMod.cs @@ -24,14 +24,14 @@ namespace StardewModdingAPI void Entry(IModHelper helper); /// Get an API that other mods can access. This is always called after , and is only called once even if multiple mods access it. - /// You can implement to provide one instance to all mods, or to provide a separate instance per mod. These are mutually exclusive, so you can only implement one of them. + /// You can implement to provide one instance to all mods, or to provide a separate instance per mod. These are mutually exclusive, so you can only implement one of them. /// Returns the API instance, or null if the mod has no API. object? GetApi(); /// Get an API that other mods can access. This is always called after , and is called once per mod that accesses the API (even if they access it multiple times). - /// The manifest for the mod accessing the API. + /// The mod accessing the API. /// Returns the API instance, or null 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. /// - object? GetApi(IManifest manifest); + object? GetApi(IModInfo mod); } } diff --git a/src/SMAPI/Mod.cs b/src/SMAPI/Mod.cs index 1a5f5594..01157886 100644 --- a/src/SMAPI/Mod.cs +++ b/src/SMAPI/Mod.cs @@ -31,7 +31,7 @@ namespace StardewModdingAPI } /// - public virtual object? GetApi(IManifest manifest) + public virtual object? GetApi(IModInfo mod) { return null; } -- cgit