diff --git a/PulsarPluginLoader/Patches/LoadPlugins.cs b/PulsarPluginLoader/Patches/LoadPlugins.cs index 9ecd736..02a17d1 100644 --- a/PulsarPluginLoader/Patches/LoadPlugins.cs +++ b/PulsarPluginLoader/Patches/LoadPlugins.cs @@ -1,19 +1,12 @@ using Harmony; -using PulsarPluginLoader.Utils; -using System; -using System.Collections.Generic; -using System.Diagnostics; using System.IO; -using System.Linq; using System.Reflection; -using System.Runtime.CompilerServices; namespace PulsarPluginLoader.Patches { [HarmonyPatch(typeof(PLGlobal), "Start")] class LoadPlugins { - private static readonly PluginManager pluginManager = new PluginManager(); private static bool pluginsLoaded = false; static void Prefix() @@ -21,7 +14,7 @@ static void Prefix() if (!pluginsLoaded) { string pluginsDir = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Plugins"); - pluginManager.LoadPluginsDirectory(pluginsDir); + PluginManager.Instance.LoadPluginsDirectory(pluginsDir); pluginsLoaded = true; } } diff --git a/PulsarPluginLoader/PluginManager.cs b/PulsarPluginLoader/PluginManager.cs index dc164d2..7cc70b4 100644 --- a/PulsarPluginLoader/PluginManager.cs +++ b/PulsarPluginLoader/PluginManager.cs @@ -17,6 +17,21 @@ public class PluginManager private readonly Dictionary activePlugins; private readonly HashSet pluginDirectories; + private static PluginManager _instance = null; + + public static PluginManager Instance + { + get + { + if (_instance == null) + { + _instance = new PluginManager(); + } + + return _instance; + } + } + public PluginManager() { FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location);