forked from RisottoMan/AutoEvent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlugin.cs
59 lines (49 loc) · 1.82 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
using System;
using System.IO;
using AutoEvent.Interfaces;
using Exiled.API.Features;
using Exiled.Events.EventArgs.Map;
using HarmonyLib;
namespace AutoEvent
{
public class AutoEvent : Plugin<Config, Translation>
{
public override string Name => "AutoEvent";
public override string Author => "Created by KoT0XleB, extended by swd and sky";
public override Version Version => new Version(8, 2, 2);
public static IEvent ActiveEvent = null;
public static AutoEvent Singleton;
public static Harmony HarmonyPatch;
public override void OnEnabled()
{
Singleton = this;
HarmonyPatch = new Harmony("autoevent");
HarmonyPatch.PatchAll();
Event.RegisterEvents();
if (!Config.IsEnabled) return;
if (!Directory.Exists(Path.Combine(Paths.Configs, "Music"))) Directory.CreateDirectory(Path.Combine(Paths.Configs, "Music"));
Exiled.Events.Handlers.Server.RestartingRound += OnRestarting;
Exiled.Events.Handlers.Map.Decontaminating += OnDecontamination;
base.OnEnabled();
}
public override void OnDisabled()
{
HarmonyPatch.UnpatchAll();
Singleton = null;
Exiled.Events.Handlers.Server.RestartingRound -= OnRestarting;
Exiled.Events.Handlers.Map.Decontaminating -= OnDecontamination;
base.OnDisabled();
}
private void OnRestarting()
{
if (ActiveEvent == null) return;
Extensions.StopAudio();
ServerStatic.StopNextRound = ServerStatic.NextRoundAction.Restart;
}
private void OnDecontamination(DecontaminatingEventArgs ev)
{
if (ActiveEvent == null) return;
ev.IsAllowed = false;
}
}
}