Browse Source

Fix .NET plugin initialization

Bepis 4 years ago
parent
commit
555cdf1c69
1 changed files with 15 additions and 4 deletions
  1. 15 4
      BepInEx.NetLauncher/BasePlugin.cs

+ 15 - 4
BepInEx.NetLauncher/BasePlugin.cs

@@ -1,14 +1,25 @@
-namespace BepInEx.NetLauncher
+using BepInEx.Configuration;
+using BepInEx.Logging;
+
+namespace BepInEx.NetLauncher
 {
 	public abstract class BasePlugin
 	{
-		protected HarmonyLib.Harmony HarmonyInstance { get; }
+		public ManualLogSource Log { get; }
+
+		public ConfigFile Config { get; }
+
+		public HarmonyLib.Harmony HarmonyInstance { get; set; }
 
 		protected BasePlugin()
 		{
-			//var info = PluginInfoHelper.GetPluginInfo(this);
+			var metadata = MetadataHelper.GetMetadata(this);
+
+			HarmonyInstance = new HarmonyLib.Harmony("BepInEx.Plugin." + metadata.GUID);
+
+			Log = Logger.CreateLogSource(metadata.Name);
 
-			//HarmonyInstance = new HarmonyLib.Harmony("BepInEx.Plugin." + info.GUID);
+			Config = new ConfigFile(Utility.CombinePaths(Paths.ConfigPath, metadata.GUID + ".cfg"), false, metadata);
 		}
 
 		public abstract void Load();