using HarmonyLib; using IPA; using System; using System.Reflection; using IPALogger = IPA.Logging.Logger; namespace BeatSaberTweakers.VolumeAdjust { /// /// Entry point of the plugin. /// [Plugin(RuntimeOptions.SingleStartInit)] public sealed class Plugin //: IPlugin { internal static IPALogger Logger; public const string HarmonyId = nameof(BeatSaberTweakers) + "." + nameof(VolumeAdjust); private Harmony _harmony => new Harmony(HarmonyId); [Init] public void Init(IPALogger logger) { Logger = logger; Logger.Debug("Init"); } [OnEnable] public void OnEnable() { try { Logger?.Debug("Applying Harmony patches."); _harmony.PatchAll(Assembly.GetExecutingAssembly()); } catch (Exception ex) { Logger?.Critical("Error applying Harmony patches: " + ex.Message); Logger?.Debug(ex); } } [OnDisable] public void OnDisable() { _harmony.UnpatchAll(HarmonyId); } } }