-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathPlugin.cs
More file actions
59 lines (45 loc) · 2.22 KB
/
Copy pathPlugin.cs
File metadata and controls
59 lines (45 loc) · 2.22 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
using LabApi.Events.CustomHandlers;
using LabApi.Features.Console;
using UserSettings.ServerSpecific;
using LabApi.Loader;
namespace Timers
{
public class Plugin : LabApi.Loader.Features.Plugins.Plugin
{
private Events _events = null!;
public override string Name => "Timers";
public override string Author => "LumiFae";
public override Version Version => new(1, 5, 1);
public override string Description { get; } = "Adds countdown timers to the respawn UI";
public override Version RequiredApiVersion { get; } = new (1, 0, 2);
public static Plugin Instance { private set; get; } = null!;
public Translation Translation { get; private set; } = null!;
public Config Config { get; private set; } = null!;
internal SSTwoButtonsSetting Setting { get; private set; } = null!;
public override void Enable()
{
Logger.Debug("Enabling plugin...", Config.Debug);
Instance = this;
_events = new();
CustomHandlersManager.RegisterEventsHandler(_events);
ServerSpecificSettingsSync.ServerOnSettingValueReceived += Events.OnSettingUpdated;
SSGroupHeader header = new(Translation.ServerSpecificSettingHeading);
Setting = new SSTwoButtonsSetting(Config.ServerSpecificSettingId, Translation.OverlaySettingText, Translation.Enable, Translation.Disable, hint:Translation.OverlaySettingHint);
ServerSpecificSettingsSync.DefinedSettings = [..ServerSpecificSettingsSync.DefinedSettings ?? [], header, Setting];
ServerSpecificSettingsSync.SendToAll();
}
public override void Disable()
{
CustomHandlersManager.UnregisterEventsHandler(_events);
ServerSpecificSettingsSync.ServerOnSettingValueReceived -= Events.OnSettingUpdated;
_events = null!;
}
public override void LoadConfigs()
{
this.TryLoadConfig("config.yml", out Config? config);
Config = config ?? new Config();
this.TryLoadConfig("translation.yml", out Translation? translation);
Translation = translation ?? new Translation();
}
}
}