-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlugin.cs
More file actions
57 lines (45 loc) · 2.04 KB
/
Plugin.cs
File metadata and controls
57 lines (45 loc) · 2.04 KB
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
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using ModSync.Networking;
using UnityEngine;
namespace ModSync
{
[BepInPlugin(MyPluginInfo.PLUGIN_GUID, MyPluginInfo.PLUGIN_NAME, MyPluginInfo.PLUGIN_VERSION)]
public class Plugin : BaseUnityPlugin
{
internal static Plugin Instance { get; private set; } = null!;
internal static new ManualLogSource Logger { get; private set; } = null!;
internal static ConfigEntry<bool> EnableModCheck { get; private set; } = null!;
internal static ConfigEntry<bool> EnableConfigSync { get; private set; } = null!;
internal static ConfigEntry<bool> NotifyOnMismatch { get; private set; } = null!;
internal static ConfigEntry<bool> BlockJoinOnMismatch { get; private set; } = null!;
private readonly Harmony _harmony = new Harmony(MyPluginInfo.PLUGIN_GUID);
private void Awake()
{
Instance = this;
Logger = base.Logger;
EnableModCheck = Config.Bind(
"General", "EnableModCheck", true,
"Check if players joining your room have the same mods installed.");
EnableConfigSync = Config.Bind(
"General", "EnableConfigSync", true,
"Sync host's mod configs to clients when they join the room.");
NotifyOnMismatch = Config.Bind(
"ModCheck", "NotifyOnMismatch", true,
"Show a notification when a mod mismatch is detected.");
BlockJoinOnMismatch = Config.Bind(
"ModCheck", "BlockJoinOnMismatch", false,
"Kick clients that have different mods than the host. (Host only)");
_harmony.PatchAll();
// Attach the network handler to this GameObject so it persists
gameObject.AddComponent<ModSyncNetwork>();
Logger.LogInfo($"{MyPluginInfo.PLUGIN_NAME} v{MyPluginInfo.PLUGIN_VERSION} loaded.");
}
private void OnDestroy()
{
_harmony.UnpatchSelf();
}
}
}