Repository navigation
Expand file tree
/
Copy pathRadarColorFix.cs
More file actions
72 lines (58 loc) · 1.85 KB
/
Copy pathRadarColorFix.cs
File metadata and controls
72 lines (58 loc) · 1.85 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
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Core.Attributes;
using CounterStrikeSharp.API.Core.Attributes.Registration;
using RadarColorFix.Configs;
using RadarColorFix.Services;
namespace RadarColorFix;
[MinimumApiVersion(369)]
public class RadarColorFix : BasePlugin, IPluginConfig<BaseConfigs>
{
public override string ModuleName => "RadarColorFix";
public override string ModuleVersion => "1.0.2";
public override string ModuleAuthor => "luca.uy";
public override string ModuleDescription => "Fixes the issue of duplicate colors on the radar";
public required BaseConfigs Config { get; set; }
private ColorManagementService? _colorService;
public void OnConfigParsed(BaseConfigs config)
{
Config = config;
Utils.Logger.Config = config;
}
public override void Load(bool hotReload)
{
_colorService = new ColorManagementService();
if (hotReload)
{
Utils.Logger.LogInfo("Plugin", "Reloading plugin...");
_colorService.RebuildColorState();
}
RegisterEventHandler<EventPlayerDisconnect>(OnPlayerDisconnect);
RegisterEventHandler<EventRoundStart>(OnRoundStart);
RegisterListener<Listeners.OnMapEnd>(OnMapEnd);
}
[GameEventHandler]
public HookResult OnRoundStart(EventRoundStart @event, GameEventInfo info)
{
_colorService?.ProcessRoundStart();
return HookResult.Continue;
}
[GameEventHandler]
private HookResult OnPlayerDisconnect(EventPlayerDisconnect @event, GameEventInfo info)
{
if (@event.Userid is not CCSPlayerController player)
return HookResult.Continue;
_colorService?.HandlePlayerDisconnect(player);
return HookResult.Continue;
}
private void OnMapEnd()
{
_colorService?.Clear();
}
public override void Unload(bool hotReload)
{
Utils.Logger.LogDebug("Plugin", "Plugin unloaded, clearing data...");
_colorService?.Clear();
_colorService = null;
}
}