mirror of
https://github.com/BepInEx/BepInEx.git
synced 2026-10-20 01:46:13 +00:00
Add a Source property to PluginInfo
Also abstract an interface among the base plugins classes to make this easier
This commit is contained in:
1 parent
d8dd404e52
commit
b688bfa978
9 files changed
+75
-47
No files matched your search
@@ -1,10 +1,12 @@
|
||||
using BepInEx.Bootstrap;
|
||||
using BepInEx.Configuration;
|
||||
using BepInEx.Contract;
|
||||
using BepInEx.Logging;
|
||||
using HarmonyLib;
|
||||
|
||||
namespace BepInEx.NET.Common
|
||||
{
|
||||
public abstract class BasePlugin
|
||||
public abstract class BasePlugin : IPlugin
|
||||
{
|
||||
protected BasePlugin()
|
||||
{
|
||||
@@ -12,13 +14,21 @@ namespace BepInEx.NET.Common
|
||||
|
||||
HarmonyInstance = new Harmony("BepInEx.Plugin." + metadata.GUID);
|
||||
|
||||
Log = Logger.CreateLogSource(metadata.Name);
|
||||
Info = BaseChainloader<BasePlugin>.GetPluginInfoFromGuid(metadata.GUID);
|
||||
Info.Instance = this;
|
||||
|
||||
Logger = BepInEx.Logging.Logger.CreateLogSource(metadata.Name);
|
||||
|
||||
Config = new ConfigFile(Utility.CombinePaths(Paths.ConfigPath, metadata.GUID + ".cfg"), false, metadata);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public PluginInfo Info { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public ManualLogSource Logger { get; }
|
||||
|
||||
public ManualLogSource Log { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public ConfigFile Config { get; }
|
||||
|
||||
public Harmony HarmonyInstance { get; set; }
|
||||
|
||||
@@ -1,21 +1,28 @@
|
||||
using BepInEx.Configuration;
|
||||
using BepInEx.Bootstrap;
|
||||
using BepInEx.Configuration;
|
||||
using BepInEx.Contract;
|
||||
using BepInEx.Logging;
|
||||
using Il2CppInterop.Runtime.InteropTypes;
|
||||
|
||||
namespace BepInEx.Unity.IL2CPP;
|
||||
|
||||
public abstract class BasePlugin
|
||||
public abstract class BasePlugin : IPlugin
|
||||
{
|
||||
protected BasePlugin()
|
||||
{
|
||||
var metadata = MetadataHelper.GetPluginMetadata(this);
|
||||
|
||||
Log = Logger.CreateLogSource(metadata.Name);
|
||||
Info = BaseChainloader<BasePlugin>.GetPluginInfoFromGuid(metadata.GUID);
|
||||
Info.Instance = this;
|
||||
|
||||
Logger = BepInEx.Logging.Logger.CreateLogSource(metadata.Name);
|
||||
|
||||
Config = new ConfigFile(Utility.CombinePaths(Paths.ConfigPath, metadata.GUID + ".cfg"), false, metadata);
|
||||
}
|
||||
|
||||
public ManualLogSource Log { get; }
|
||||
public PluginInfo Info { get; }
|
||||
|
||||
public ManualLogSource Logger { get; }
|
||||
|
||||
public ConfigFile Config { get; }
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using System;
|
||||
using BepInEx.Bootstrap;
|
||||
using BepInEx.Configuration;
|
||||
using BepInEx.Contract;
|
||||
using BepInEx.Logging;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -8,7 +10,7 @@ namespace BepInEx.Unity.Mono;
|
||||
/// <summary>
|
||||
/// The base plugin type that is used by the BepInEx plugin loader.
|
||||
/// </summary>
|
||||
public abstract class BaseUnityPlugin : MonoBehaviour
|
||||
public abstract class BaseUnityPlugin : MonoBehaviour, IPlugin
|
||||
{
|
||||
/// <summary>
|
||||
/// Create a new instance of a plugin and all of its tied in objects.
|
||||
@@ -21,13 +23,8 @@ public abstract class BaseUnityPlugin : MonoBehaviour
|
||||
throw new InvalidOperationException("Can't create an instance of " + GetType().FullName +
|
||||
" because it inherits from BaseUnityPlugin and the BepInPlugin attribute is missing.");
|
||||
|
||||
Info = new PluginInfo
|
||||
{
|
||||
Metadata = metadata,
|
||||
Instance = this,
|
||||
Dependencies = MetadataHelper.GetDependencies(GetType()),
|
||||
Processes = MetadataHelper.GetAttributes<BepInProcess>(GetType()),
|
||||
};
|
||||
Info = BaseChainloader<BaseUnityPlugin>.GetPluginInfoFromGuid(metadata.GUID);
|
||||
Info.Instance = this;
|
||||
|
||||
Logger = BepInEx.Logging.Logger.CreateLogSource(metadata.Name);
|
||||
|
||||
@@ -42,7 +39,7 @@ public abstract class BaseUnityPlugin : MonoBehaviour
|
||||
/// <summary>
|
||||
/// Logger instance tied to this plugin.
|
||||
/// </summary>
|
||||
protected ManualLogSource Logger { get; }
|
||||
public ManualLogSource Logger { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Default config file tied to this plugin. The config file will not be created until
|
||||
|
||||
Reference in new issue
Block a user