-
Notifications
You must be signed in to change notification settings - Fork 3
/
EventHandlers.cs
101 lines (87 loc) · 3.2 KB
/
EventHandlers.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
using System;
using System.Linq;
using Exiled.API.Features;
using Exiled.Events.EventArgs.Player;
using Exiled.Events.EventArgs.Server;
using Exiled.Permissions.Extensions;
using KillLogs.Enums;
using Respawning;
namespace KillLogs
{
public class EventHandlers
{
private readonly Plugin plugin;
public EventHandlers(Plugin plugin)
{
this.plugin = plugin;
}
public void OnDying(DyingEventArgs ev)
{
if (!Round.IsStarted) return;
Log.Debug("Player died");
if (ev.Attacker == null) return;
if (ev.Player == null) return;
Log.Debug("Not null target/victim");
if (ev.Attacker.IsScp && !plugin.Config.LogScpKills) return;
Log.Debug("Not SCP");
if (ev.Attacker == ev.Player)
{
if (!plugin.Config.LogSuicides) return;
Log.Debug("Suicide");
plugin.LogManager.ReportKill(ev, LogReason.Regular);
return;
}
if (ev.Attacker.Role.Team == ev.Player.Role.Team)
{
Log.Debug("**TEAMKILL**");
plugin.LogManager.ReportKill(ev, LogReason.TeamKill, plugin.Config.PingTeamkills);
return;
}
if (!ev.Attacker.IsScp && ev.Player.IsCuffed)
{
Log.Debug("**CUFFED**");
plugin.LogManager.ReportKill(ev, LogReason.CuffedKill, plugin.Config.PingCuffedHumanKills);
return;
}
Log.Debug("Regular kill");
plugin.LogManager.ReportKill(ev, LogReason.Regular);
}
public void OnRoundEnded(RoundEndedEventArgs ev)
{
plugin.LogManager.EnqueueText("**=== ROUND ENDED ===**", true);
Log.Debug("Sent round ended message");
}
public void OnRoundStarted()
{
plugin.LogManager.EnqueueText("**=== ROUND STARTED ===**", true);
Log.Debug("Sent round started message");
plugin.PlayersToNotify.Clear();
plugin.PlayersToNotify = Player.List.Where(player => player.CheckPermission("kill_logs.notify")).ToList();
}
public void OnVerified(VerifiedEventArgs ev)
{
if (ev.Player.CheckPermission("kill_logs.notify") && !plugin.PlayersToNotify.Contains(ev.Player))
plugin.PlayersToNotify.Add(ev.Player);
}
public void OnLeft(LeftEventArgs ev)
{
plugin.PlayersToNotify.Remove(ev.Player);
}
public void OnRespawningTeam(RespawningTeamEventArgs ev)
{
switch (ev.NextKnownTeam)
{
case SpawnableTeamType.ChaosInsurgency:
plugin.LogManager.EnqueueText("**=== CI SPAWNED ===**", true);
break;
case SpawnableTeamType.NineTailedFox:
plugin.LogManager.EnqueueText("**=== NTF SPAWNED ===**",true);
break;
case SpawnableTeamType.None:
break;
default:
throw new ArgumentOutOfRangeException();
}
}
}
}