diff --git a/IPA.Loader/IPA.Loader.csproj b/IPA.Loader/IPA.Loader.csproj index fe782f84..18a2f765 100644 --- a/IPA.Loader/IPA.Loader.csproj +++ b/IPA.Loader/IPA.Loader.csproj @@ -108,9 +108,7 @@ - - diff --git a/IPA.Loader/Loader/Composite/CompositeBSPlugin.cs b/IPA.Loader/Loader/Composite/CompositeBSPlugin.cs index 9b0a1b9a..70bc6999 100644 --- a/IPA.Loader/Loader/Composite/CompositeBSPlugin.cs +++ b/IPA.Loader/Loader/Composite/CompositeBSPlugin.cs @@ -5,11 +5,7 @@ using Logger = IPA.Logging.Logger; namespace IPA.Loader.Composite { - internal class CompositeBSPlugin : -#pragma warning disable CS0618 // Type or member is obsolete - IBeatSaberPlugin, -#pragma warning restore CS0618 // Type or member is obsolete - _IPlugin + internal class CompositeBSPlugin { private readonly IEnumerable plugins; @@ -19,11 +15,6 @@ namespace IPA.Loader.Composite this.plugins = plugins; } - [Obsolete] - public void OnApplicationStart() { - Invoke(plugin => (plugin.Plugin as IBeatSaberPlugin)?.OnApplicationStart()); - } - public void OnApplicationQuit() { Invoke(plugin => plugin.Plugin.OnApplicationQuit()); } diff --git a/IPA.Loader/Loader/PluginComponent.cs b/IPA.Loader/Loader/PluginComponent.cs index 88457e79..4663468a 100644 --- a/IPA.Loader/Loader/PluginComponent.cs +++ b/IPA.Loader/Loader/PluginComponent.cs @@ -34,9 +34,6 @@ namespace IPA.Loader gameObject.AddComponent(); #endif -#pragma warning disable CS0612 // Type or member is obsolete - bsPlugins.OnApplicationStart(); -#pragma warning restore CS0612 // Type or member is obsolete ipaPlugins.OnApplicationStart(); SceneManager.activeSceneChanged += OnActiveSceneChanged; diff --git a/IPA.Loader/Loader/PluginLoader.cs b/IPA.Loader/Loader/PluginLoader.cs index e7b0eff6..23a8a79a 100644 --- a/IPA.Loader/Loader/PluginLoader.cs +++ b/IPA.Loader/Loader/PluginLoader.cs @@ -124,7 +124,7 @@ namespace IPA.Loader /// public class PluginInfo { - internal _IPlugin Plugin { get; set; } + internal IPlugin Plugin { get; set; } /// /// Metadata for the plugin. @@ -196,14 +196,14 @@ namespace IPA.Loader foreach (var plugin in plugins) { - try + var metadata = new PluginMetadata { - var metadata = new PluginMetadata - { - File = new FileInfo(Path.Combine(BeatSaber.PluginsPath, plugin)), - IsSelf = false - }; + File = new FileInfo(Path.Combine(BeatSaber.PluginsPath, plugin)), + IsSelf = false + }; + try + { var pluginModule = AssemblyDefinition.ReadAssembly(plugin, new ReaderParameters { ReadingMode = ReadingMode.Immediate, @@ -244,7 +244,7 @@ namespace IPA.Loader if (type.Namespace != pluginNs) continue; // TODO: change this to just IPlugin - if (type.HasInterface(typeof(_IPlugin).FullName)) + if (type.HasInterface(typeof(IPlugin).FullName)) { metadata.PluginType = type; break; @@ -264,6 +264,7 @@ namespace IPA.Loader { Logger.loader.Error($"Could not load data for plugin {Path.GetFileName(plugin)}"); Logger.loader.Error(e); + ignoredPlugins.Add(metadata); } } @@ -642,7 +643,7 @@ namespace IPA.Loader } var type = meta.Assembly.GetType(meta.PluginType.FullName); - var instance = Activator.CreateInstance(type) as _IPlugin; + var instance = Activator.CreateInstance(type) as IPlugin; info.Metadata = meta; info.Plugin = instance; diff --git a/IPA.Loader/Loader/PluginManager.cs b/IPA.Loader/Loader/PluginManager.cs index a26c6385..df8fd3c5 100644 --- a/IPA.Loader/Loader/PluginManager.cs +++ b/IPA.Loader/Loader/PluginManager.cs @@ -32,7 +32,7 @@ namespace IPA.Loader /// /// An of new Beat Saber plugins /// - internal static IEnumerable<_IPlugin> BSPlugins => (_bsPlugins ?? throw new InvalidOperationException()).Select(p => p.Plugin); + internal static IEnumerable BSPlugins => (_bsPlugins ?? throw new InvalidOperationException()).Select(p => p.Plugin); private static List _bsPlugins; internal static IEnumerable BSMetas => _bsPlugins; @@ -324,11 +324,17 @@ namespace IPA.Loader // initialize BSIPA plugins first _bsPlugins.AddRange(PluginLoader.LoadPlugins()); + var metadataPaths = PluginsMetadata.Select(m => m.File.FullName).ToList(); + var ignoredPaths = ignoredPlugins.Select(m => m.File.FullName).ToList(); + var disabledPaths = DisabledPlugins.Select(m => m.File.FullName).ToList(); + //Copy plugins to .cache string[] originalPlugins = Directory.GetFiles(pluginDirectory, "*.dll"); foreach (string s in originalPlugins) { - if (PluginsMetadata.Select(m => m.File.FullName).Contains(s)) continue; + if (metadataPaths.Contains(s)) continue; + if (ignoredPaths.Contains(s)) continue; + if (disabledPaths.Contains(s)) continue; string pluginCopy = Path.Combine(cacheDir, Path.GetFileName(s)); #region Fix assemblies for refactor diff --git a/IPA.Loader/PluginInterfaces/BeatSaber/IBeatSaberPlugin.cs b/IPA.Loader/PluginInterfaces/BeatSaber/IBeatSaberPlugin.cs deleted file mode 100644 index 2d16355e..00000000 --- a/IPA.Loader/PluginInterfaces/BeatSaber/IBeatSaberPlugin.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -// ReSharper disable CheckNamespace - -namespace IPA -{ - /// - /// Interface for Beat Saber plugins. Every class that implements this will be loaded if the DLL is placed at - /// data/Managed/Plugins. - /// - [Obsolete("Use IPA.IPlugin instead")] - public interface IBeatSaberPlugin : _IPlugin - { - /// - /// Gets invoked when the application is started. - /// - /// THIS EVENT WILL NOT BE GUARANTEED TO FIRE. USE Init OR INSTEAD. - /// - void OnApplicationStart(); - } -} diff --git a/IPA.Loader/PluginInterfaces/BeatSaber/IDisablablePlugin.cs b/IPA.Loader/PluginInterfaces/BeatSaber/IDisablablePlugin.cs index fdabfd74..af28e0a9 100644 --- a/IPA.Loader/PluginInterfaces/BeatSaber/IDisablablePlugin.cs +++ b/IPA.Loader/PluginInterfaces/BeatSaber/IDisablablePlugin.cs @@ -21,7 +21,7 @@ /// from events. After this is called there should be no lingering effects of the mod. /// /// - /// This will get called at shutdown, after , as well as when the + /// This will get called at shutdown, after , as well as when the /// plugin is disabled at runtime. /// void OnDisable(); diff --git a/IPA.Loader/PluginInterfaces/BeatSaber/IEnhancedBeatSaberPlugin.cs b/IPA.Loader/PluginInterfaces/BeatSaber/IEnhancedBeatSaberPlugin.cs deleted file mode 100644 index e83ce7f3..00000000 --- a/IPA.Loader/PluginInterfaces/BeatSaber/IEnhancedBeatSaberPlugin.cs +++ /dev/null @@ -1,12 +0,0 @@ -// ReSharper disable CheckNamespace -namespace IPA -{ - /// - /// - /// An enhanced version of a standard BeatSaber plugin. - /// - [System.Obsolete] - public interface IEnhancedBeatSaberPlugin : IBeatSaberPlugin, IGenericEnhancedPlugin - { - } -} diff --git a/IPA.Loader/PluginInterfaces/BeatSaber/IPlugin.cs b/IPA.Loader/PluginInterfaces/BeatSaber/IPlugin.cs index 60cbce66..b7ea8e88 100644 --- a/IPA.Loader/PluginInterfaces/BeatSaber/IPlugin.cs +++ b/IPA.Loader/PluginInterfaces/BeatSaber/IPlugin.cs @@ -6,7 +6,7 @@ namespace IPA /// Interface for BSIPA plugins. Every class that implements this will be loaded if the DLL is placed at /// <install dir>/Plugins. /// - public interface IPlugin : _IPlugin + public interface IPlugin { /// /// Called when a plugin is enabled. This is where you should set up Harmony patches and the like. @@ -18,11 +18,7 @@ namespace IPA /// Init will only ever be called once. /// void OnEnable(); - } - /// - /// An interface for providing compatability with BSIPA 3.x.x. Do not use. - /// - public interface _IPlugin { + /// /// Gets invoked when the application is closed. ///