-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlugin.cs
48 lines (40 loc) · 1.39 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
using BepInEx;
using Steamworks;
using HarmonyLib;
using System.Reflection;
using BepInEx.Logging;
namespace GetYourOwnPortal;
[BepInPlugin(Plugin.GUID, Plugin.NAME, Plugin.VERSION)]
public class Plugin : BaseUnityPlugin
{
static ManualLogSource _Logger = new ManualLogSource(GUID);
// Plugin metadata
public const string NAME = "GetYourOwnPortal";
public const string AUTHOR = "Kevver";
public const string GUID = $"{AUTHOR}.{NAME}";
public const string VERSION = "1.0.5";
// HarmonyLib handle
static readonly Harmony harmony = new(NAME);
public static ServerSync.ConfigSync configSync = new ServerSync.ConfigSync(GUID)
{
DisplayName = NAME,
CurrentVersion = VERSION,
MinimumRequiredVersion = VERSION
};
public static bool PlayerIsAdmin()
{
bool isAdmin = configSync.IsAdmin || (ZNet.instance && ZNet.instance.IsServer());
_Logger.LogInfo($"IsAdmin: {isAdmin}");
return isAdmin;
}
private void Awake()
{
// Setup loggers
BepInEx.Logging.Logger.Sources.Add(Plugin._Logger);
BepInEx.Logging.Logger.Sources.Add(Portal.Create.Logger);
BepInEx.Logging.Logger.Sources.Add(Portal.Edit.Logger);
BepInEx.Logging.Logger.Sources.Add(Portal.Destroy.Logger);
// Patch assembly with HarmonyLib
harmony.PatchAll(Assembly.GetExecutingAssembly());
}
}