-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCommandLoggerConfiguration.cs
65 lines (57 loc) · 1.7 KB
/
CommandLoggerConfiguration.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
using System.Xml.Serialization;
using System.Linq;
using Rocket.API;
namespace coolpuppy24.commandlogger
{
public struct CommandLoggerEntry
{
/// <summary>
/// Name of the command (ex: /god : god is a name)
/// </summary>
[XmlAttribute("name")]
public string Name;
/// <summary>
/// Command aliases (ex: /i, /item, /give : is aliases separated by ,)
/// </summary>
[XmlAttribute("aliases")]
public string Aliases;
/// <summary>
/// Get aliases as Array
/// </summary>
/// <returns>string[]</returns>
public string[] GetAliases() => (from i in Aliases.Split(',') select i.Trim()).ToArray();
public CommandLoggerEntry(string Name, params string[] Aliases)
{
this.Name = Name;
this.Aliases = string.Join(",", Aliases);
}
}
public sealed class CommandLoggerConfiguration : IDefaultable, IRocketPluginConfiguration
{
public bool LogToConsole;
public bool LogToFile;
[XmlElement("LogFormat")]
public string LogFormat;
[XmlArray("CommandEntries"), XmlArrayItem("CommandEntry")]
public CommandLoggerEntry[] Entries;
public void LoadDefaults()
{
this.LogToConsole = true;
this.LogToFile = true;
this.LogFormat = "[{0}] {1} ({2}) executed \"{3}\" command as \"{4}\" with \"{5}\" arguments.";
this.Entries = new CommandLoggerEntry[]
{
new CommandLoggerEntry("god"),
new CommandLoggerEntry("vanish"),
new CommandLoggerEntry("investigate"),
new CommandLoggerEntry("item", "i", "give"),
new CommandLoggerEntry("vehicle", "v"),
new CommandLoggerEntry("teleport", "tp", "tphere"),
new CommandLoggerEntry("spy"),
new CommandLoggerEntry("ban"),
new CommandLoggerEntry("kick"),
new CommandLoggerEntry("kill", "slay")
};
}
}
}