-
Notifications
You must be signed in to change notification settings - Fork 0
/
Plugin.cs
63 lines (53 loc) · 1.78 KB
/
Plugin.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
using HarmonyLib;
using IPA;
using IPA.Config;
using IPA.Config.Stores;
using JetBrains.Annotations;
using MultiplayerMirror.Core.Installers;
using SiraUtil.Web.SiraSync;
using SiraUtil.Zenject;
using IPALogger = IPA.Logging.Logger;
namespace MultiplayerMirror
{
[Plugin(RuntimeOptions.DynamicInit)]
// ReSharper disable once ClassNeverInstantiated.Global
public class Plugin
{
public const string HarmonyId = "com.hippomade.multiplayermirror";
internal static PluginConfig Config { get; private set; } = null!;
internal static IPALogger? Log { get; private set; }
private Harmony? _harmony;
public Plugin() : base()
{
Config = new PluginConfig();
}
[Init]
[UsedImplicitly]
public void Init(IPALogger logger, Zenjector zenjector, Config config)
{
Log = logger;
_harmony = new Harmony(HarmonyId);
Config = config.Generated<PluginConfig>();
zenjector.UseMetadataBinder<Plugin>();
zenjector.UseLogger(logger);
zenjector.UseSiraSync(SiraSyncServiceType.GitHub, "roydejong", "BeatSaberMultiplayerMirror");
zenjector.Install<MpMirrorAppInstaller>(Location.App);
zenjector.Install<MpMirrorMenuInstaller>(Location.Menu);
zenjector.Install<MpMirrorMultiPlayerInstaller>(Location.MultiplayerCore);
}
[OnEnable]
[UsedImplicitly]
public void OnEnable()
{
// Install Harmony patches
_harmony!.PatchAll();
}
[OnDisable]
[UsedImplicitly]
public void OnDisable()
{
// Remove Harmony patches
_harmony?.UnpatchSelf();
}
}
}