Skip to content

Commit

Permalink
Made PluginManager singleton publicly accessible
Browse files Browse the repository at this point in the history
  • Loading branch information
TomRichter committed Dec 4, 2018
1 parent c858ddf commit 8a80de3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
9 changes: 1 addition & 8 deletions PulsarPluginLoader/Patches/LoadPlugins.cs
Original file line number Diff line number Diff line change
@@ -1,27 +1,20 @@
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()
{
if (!pluginsLoaded)
{
string pluginsDir = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Plugins");
pluginManager.LoadPluginsDirectory(pluginsDir);
PluginManager.Instance.LoadPluginsDirectory(pluginsDir);
pluginsLoaded = true;
}
}
Expand Down
15 changes: 15 additions & 0 deletions PulsarPluginLoader/PluginManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,21 @@ public class PluginManager
private readonly Dictionary<string, PulsarPlugin> activePlugins;
private readonly HashSet<string> 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);
Expand Down

0 comments on commit 8a80de3

Please sign in to comment.