-
Notifications
You must be signed in to change notification settings - Fork 4
/
Config.cs
81 lines (73 loc) · 3.02 KB
/
Config.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
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Utils;
using System.Text.Json.Serialization;
namespace CallAdmin
{
public partial class CallAdmin
{
public required CallAdminConfig Config { get; set; }
public void OnConfigParsed(CallAdminConfig config)
{
if (config.Version != ConfigVersion) throw new Exception($"You have a wrong config version. Delete it and restart the server to get the right version ({ConfigVersion})!");
if (config.Commands.ReportHandledEnabled && (string.IsNullOrEmpty(config.Database.Host) || string.IsNullOrEmpty(config.Database.Name) || string.IsNullOrEmpty(config.Database.User)))
{
throw new Exception($"You need to setup Database credentials in config!");
}
else if (string.IsNullOrEmpty(config.Commands.ReportPrefix) || string.IsNullOrEmpty(config.Commands.ReportHandledPrefix))
{
throw new Exception($"You need to setup CommandsPrefix in config!");
}
else if (string.IsNullOrEmpty(config.WebHookUrl) || string.IsNullOrEmpty(config.Reasons))
{
throw new Exception($"You need to setup WebHookUrl and Reasons in config!");
}
Config = config;
}
}
public class CallAdminConfig : BasePluginConfig
{
public override int Version { get; set; } = 6;
[JsonPropertyName("ServerIpWithPort")]
public string ServerIpWithPort { get; set; } = "";
[JsonPropertyName("CooldownRefreshCommandSeconds")]
public int CooldownRefreshCommandSeconds { get; set; } = 30;
[JsonPropertyName("Reasons")]
public string Reasons { get; set; } = "Hack;Toxic;Camping;Your Custom Reason{CUSTOMREASON}";
[JsonPropertyName("WebHookUrl")]
public string WebHookUrl { get; set; } = "";
[JsonPropertyName("Debug")]
public bool Debug { get; set; } = false;
[JsonPropertyName("Database")]
public Database Database { get; set; } = new();
[JsonPropertyName("Commands")]
public Commands Commands { get; set; } = new();
}
public class Database
{
[JsonPropertyName("Host")]
public string Host { get; set; } = "";
[JsonPropertyName("Port")]
public int Port { get; set; } = 3306;
[JsonPropertyName("User")]
public string User { get; set; } = "";
[JsonPropertyName("Password")]
public string Password { get; set; } = "";
[JsonPropertyName("Name")]
public string Name { get; set; } = "";
[JsonPropertyName("Prefix")]
public string Prefix { get; set; } = "call_admin";
}
public class Commands
{
[JsonPropertyName("ReportPrefix")]
public string ReportPrefix { get; set; } = "report";
[JsonPropertyName("ReportPermission")]
public string ReportPermission { get; set; } = "";
[JsonPropertyName("ReportHandledEnabled")]
public bool ReportHandledEnabled { get; set; } = true;
[JsonPropertyName("ReportHandledPrefix")]
public string ReportHandledPrefix { get; set; } = "report_handled";
[JsonPropertyName("ReportHandledPermission")]
public string ReportHandledPermission { get; set; } = "@css/generic;@css/ban";
}
}