12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- using HarmonyLib;
- using IPA;
- using System;
- using System.Reflection;
- using IPALogger = IPA.Logging.Logger;
- namespace BeatSaberTweakers.VolumeAdjust
- {
- /// <summary>
- /// Entry point of the plugin.
- /// </summary>
- [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);
- }
- }
- }
|