From 8b95e5651b6eae0579fdc1f038a91c986c437b52 Mon Sep 17 00:00:00 2001 From: Anairkoen Schno Date: Sun, 5 Apr 2020 00:10:46 -0500 Subject: [PATCH] Deprecated PluginManager.AllPlugins in favor of the new name EnabledPlugins --- BSIPA-ModList/Plugin.cs | 2 +- IPA.Loader/Loader/PluginManager.cs | 32 ++++++++++++++++++------------ 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/BSIPA-ModList/Plugin.cs b/BSIPA-ModList/Plugin.cs index 3cbe8d83..c1d02353 100644 --- a/BSIPA-ModList/Plugin.cs +++ b/BSIPA-ModList/Plugin.cs @@ -77,7 +77,7 @@ namespace BSIPA_ModList private static IEnumerator LoadPluginIcons() { - foreach (var p in PluginManager.AllPlugins) + foreach (var p in PluginManager.EnabledPlugins) { yield return null; Logger.log.Debug($"Loading icon for {p.Metadata.Name}"); diff --git a/IPA.Loader/Loader/PluginManager.cs b/IPA.Loader/Loader/PluginManager.cs index 1468a954..e3b40c92 100644 --- a/IPA.Loader/Loader/PluginManager.cs +++ b/IPA.Loader/Loader/PluginManager.cs @@ -76,7 +76,7 @@ namespace IPA.Loader /// /// a new that captures the current state of loaded mods public static StateTransitionTransaction PluginStateTransaction() - => new StateTransitionTransaction(AllPlugins, DisabledPlugins); + => new StateTransitionTransaction(EnabledPlugins, DisabledPlugins); private static readonly object commitTransactionLockObject = new object(); @@ -87,8 +87,8 @@ namespace IPA.Loader lock (commitTransactionLockObject) { - if (transaction.CurrentlyEnabled.Except(AllPlugins) - .Concat(AllPlugins.Except(transaction.CurrentlyEnabled)).Any() + if (transaction.CurrentlyEnabled.Except(EnabledPlugins) + .Concat(EnabledPlugins.Except(transaction.CurrentlyEnabled)).Any() || transaction.CurrentlyDisabled.Except(DisabledPlugins) .Concat(DisabledPlugins.Except(transaction.CurrentlyDisabled)).Any()) { // ensure that the transaction's base state reflects the current state, otherwise throw @@ -123,7 +123,7 @@ namespace IPA.Loader if (executor != null) runtimeDisabledPlugins.Remove(executor); else - executor = PluginLoader.InitPlugin(meta, AllPlugins); + executor = PluginLoader.InitPlugin(meta, EnabledPlugins); if (executor == null) continue; // couldn't initialize, skip to next } @@ -226,12 +226,6 @@ namespace IPA.Loader /// if the plugin is enabled, otherwise. public static bool IsEnabled(PluginMetadata meta) => BSMetas.Any(p => p.Metadata == meta); - /// - /// Gets a list of disabled BSIPA plugins. - /// - /// a collection of all disabled plugins as - public static IEnumerable DisabledPlugins => PluginLoader.DisabledPlugins; - private static readonly HashSet runtimeDisabledPlugins = new HashSet(); /// /// An invoker for the event. @@ -256,16 +250,28 @@ namespace IPA.Loader public static event PluginDisableDelegate PluginDisabled; /// - /// Gets a list of all enabled BSIPA plugins. + /// Gets a list of all enabled BSIPA plugins. Use instead of this. /// /// a collection of all enabled plugins as s - public static IEnumerable AllPlugins => BSMetas.Select(p => p.Metadata); + [Obsolete("This is an old name that no longer accurately represents its value. Use EnabledPlugins instead.")] + public static IEnumerable AllPlugins => EnabledPlugins; + /// + /// Gets a collection of all enabled plugins, as represented by . + /// + /// a collection of all enabled plugins + public static IEnumerable EnabledPlugins => BSMetas.Select(p => p.Metadata); + /// + /// Gets a list of disabled BSIPA plugins. + /// + /// a collection of all disabled plugins as + public static IEnumerable DisabledPlugins => PluginLoader.DisabledPlugins; + private static readonly HashSet runtimeDisabledPlugins = new HashSet(); /// /// An of old IPA plugins. /// /// all legacy plugin instances - [Obsolete("I mean, IPlugin shouldn't be used, so why should this? Not renaming to extend support for old plugins.")] + [Obsolete("This exists only to provide support for legacy IPA plugins based on the IPlugin interface.")] public static IEnumerable Plugins => _ipaPlugins; private static List _ipaPlugins;