Plugin.cs 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using HarmonyLib;
  2. using IPA;
  3. using System;
  4. using System.Reflection;
  5. using IPALogger = IPA.Logging.Logger;
  6. namespace BeatSaberTweakers.HapticFeedbackAdjust
  7. {
  8. /// <summary>
  9. /// Entry point of the plugin.
  10. /// </summary>
  11. [Plugin(RuntimeOptions.SingleStartInit)]
  12. public sealed class Plugin //: IPlugin
  13. {
  14. internal static IPALogger Logger;
  15. [Init]
  16. public void Init(IPALogger logger)
  17. {
  18. Logger = logger;
  19. Logger.Debug("Init");
  20. try
  21. {
  22. Logger?.Debug("Applying Harmony patches.");
  23. harmony.PatchAll(Assembly.GetExecutingAssembly());
  24. }
  25. catch (Exception ex)
  26. {
  27. Logger?.Critical("Error applying Harmony patches: " + ex.Message);
  28. Logger?.Debug(ex);
  29. }
  30. }
  31. public const string HarmonyId = nameof(BeatSaberTweakers) + "." + nameof(HapticFeedbackAdjust);
  32. internal static Harmony harmony => new Harmony(HarmonyId);
  33. }
  34. }