-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPlugin.cs
More file actions
77 lines (61 loc) · 2.49 KB
/
Plugin.cs
File metadata and controls
77 lines (61 loc) · 2.49 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
using Exiled.API.Features;
using Exiled.Events.EventArgs.Map;
using Exiled.Events.EventArgs.Server;
using System;
using System.IO;
namespace AudioPlayerManager
{
public class Plugin : Plugin<Config, Translation>
{
public override string Author => "Antoniofo";
public override string Name => "AudioPlayer";
public override Version Version => new Version(2, 4, 5);
public override Version RequiredExiledVersion => new Version(9, 9, 2);
public override string Prefix => "audioplayer";
public static Plugin Instance;
public override void OnEnabled()
{
Instance = this;
if (!Directory.Exists(Config.AudioFilePath))
{
Log.Warn("audio directory doesn't exist. Creating...");
Directory.CreateDirectory(Config.AudioFilePath);
}
Exiled.Events.Handlers.Server.RespawningTeam += OnRespawnTeam;
Exiled.Events.Handlers.Map.AnnouncingNtfEntrance += OnNTFAnnounce;
Exiled.Events.Handlers.Map.AnnouncingChaosEntrance += OnChaosAnnounce;
ServerSpecificSettings.RegisterSettings();
base.OnEnabled();
}
public override void OnDisabled()
{
Instance = null;
Exiled.Events.Handlers.Server.RespawningTeam -= OnRespawnTeam;
Exiled.Events.Handlers.Map.AnnouncingNtfEntrance -= OnNTFAnnounce;
Exiled.Events.Handlers.Map.AnnouncingChaosEntrance -= OnChaosAnnounce;
ServerSpecificSettings.UnregisterSettings();
base.OnDisabled();
}
private void OnNTFAnnounce(AnnouncingNtfEntranceEventArgs obj)
{
if (Config.PlayMtfSound)
obj.IsAllowed = false;
}
private void OnChaosAnnounce(AnnouncingChaosEntranceEventArgs obj)
{
if (Config.PlayChaosSound)
obj.IsAllowed = false;
}
private void OnRespawnTeam(RespawningTeamEventArgs ev)
{
if (ev.Wave.Faction == PlayerRoles.Faction.FoundationStaff && Config.PlayMtfSound)
{
API.SoundPlayer.PlayGlobalAudio(Path.GetFileNameWithoutExtension(Config.MtfSoundFilePath), false);
}
else if (ev.Wave.Faction == PlayerRoles.Faction.FoundationEnemy && Config.PlayChaosSound)
{
API.SoundPlayer.PlayGlobalAudio(Path.GetFileNameWithoutExtension(Config.ChaosSoundFilePath), false);
}
}
}
}