-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCommandTransparency.cs
117 lines (77 loc) · 3.19 KB
/
CommandTransparency.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Rocket.Core.Plugins;
using Rocket.Core.Logging;
using Rocket.Unturned.Player;
using Rocket.Unturned.Permissions;
using Rocket.Unturned.Commands;
using Rocket.Unturned.Chat;
using Rocket.Unturned.Events;
using Steamworks;
using UnityEngine;
using SDG.Unturned;
using Rocket.Unturned.Enumerations;
using Rocket.API.Collections;
using Rocket.API;
using Rocket.Core.RCON;
using Logger = Rocket.Core.Logging.Logger;
namespace CommandTransparency
{
public class CommandTransparency : RocketPlugin<CommandTransparencyConfiguration>
{
public static bool isToggled { get; set; }
// Load message
protected override void Load()
{
Logger.Log($"Loading {name} by Spinkles...");
CommandTransparency.isToggled = true;
UnturnedPlayerEvents.OnPlayerChatted += onPlayerChatted;
Logger.Log($"{Name} {Assembly.GetName().Version} has been loaded!");
Logger.Log($"");
}
// unload message
protected override void Unload()
{
CommandTransparency.isToggled = false;
UnturnedPlayerEvents.OnPlayerChatted -= onPlayerChatted;
Logger.Log($"{name} by Spinkles has been unloaded!");
Logger.Log($"");
}
private void onPlayerChatted(UnturnedPlayer player, ref Color color, string message, EChatMode chatmode, ref bool cancel)
{
if (CommandTransparency.isToggled == true)
{
Logger.Log($"{player} has chatted! Checking for permission.");
if (player.HasPermission("CommandTransparency.TransparentCommands"))
{
Logger.Log($"Permission found from {player}.");
string wasCommand = message.Substring(0, 1);
if (wasCommand == "/")
{
Logger.Log($"Chat is a command, because it starts with /!");
Logger.Log("Checking if the command isn't ignored.");
if (Configuration.Instance.IgnoredCommands.Any(message.ToLower().Contains))
{
Logger.Log($"Command is included in Ignored Commands.");
}
else
{
Logger.Log($"Command isn't ignored!");
Logger.Log($"Broadcasting to everyone what the command was now.");
var broadcastMessage = $"{player.CharacterName} has executed command {message}";
UnturnedChat.Say(color: Color.red, message: broadcastMessage);
Logger.Log($"Now everyone knows what the admin did! >:)");
}
}
else
{
Logger.Log($"It's not a command. Ignoring.");
}
}
}
}
}
}