-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathBloodstonePlugin.cs
More file actions
80 lines (67 loc) · 2.66 KB
/
BloodstonePlugin.cs
File metadata and controls
80 lines (67 loc) · 2.66 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using Bloodstone.API;
namespace Bloodstone
{
[BepInPlugin(MyPluginInfo.PLUGIN_GUID, MyPluginInfo.PLUGIN_NAME, MyPluginInfo.PLUGIN_VERSION)]
[BepInDependency("gg.deca.VampireCommandFramework", BepInDependency.DependencyFlags.SoftDependency)]
public class BloodstonePlugin : BasePlugin
{
#nullable disable
public static ManualLogSource Logger { get; private set; }
internal static BloodstonePlugin Instance { get; private set; }
#nullable enable
private ConfigEntry<bool> _enableReloadCommand;
private ConfigEntry<string> _reloadCommand;
private ConfigEntry<string> _reloadPluginsFolder;
public BloodstonePlugin() : base()
{
BloodstonePlugin.Logger = Log;
Instance = this;
_enableReloadCommand = Config.Bind("General", "EnableReloading", true, "Whether to enable the reloading feature (both client and server).");
_reloadCommand = Config.Bind("General", "ReloadCommand", "!reload", "Server text command to reload plugins. User must be an admin.");
_reloadPluginsFolder = Config.Bind("General", "ReloadablePluginsFolder", "BepInEx/BloodstonePlugins", "The folder to (re)load plugins from, relative to the game directory.");
}
public override void Load()
{
// Hooks
if (VWorld.IsServer)
{
Hooks.Chat.Initialize();
}
if (VWorld.IsClient)
{
API.KeybindManager.Load();
// Hooks.Keybindings.Initialize();
}
Hooks.OnInitialize.Initialize();
Hooks.GameFrame.Initialize();
Network.SerializationHooks.Initialize();
Logger.LogInfo($"Bloodstone v{MyPluginInfo.PLUGIN_VERSION} loaded.");
// NOTE: MUST BE LAST. This initializes plugins that depend on our state being set up.
if (VWorld.IsClient || _enableReloadCommand.Value)
{
Reload.Initialize(_reloadCommand.Value, _reloadPluginsFolder.Value);
}
}
public override bool Unload()
{
// Hooks
if (VWorld.IsServer)
{
Hooks.Chat.Uninitialize();
}
if (VWorld.IsClient)
{
API.KeybindManager.Save();
Hooks.Keybindings.Uninitialize();
}
Hooks.OnInitialize.Uninitialize();
Hooks.GameFrame.Uninitialize();
Network.SerializationHooks.Uninitialize();
return true;
}
}
}