-
Notifications
You must be signed in to change notification settings - Fork 0
/
Config.cs
75 lines (51 loc) · 1.95 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
using System.IO;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using OTAPI;
public class Config
{
public static Config config = new Config();
private const string path = "tshock/VotePlus.json";
[JsonProperty("启用投票踢出")]
public bool EnableKick { get; set; } = true;
[JsonProperty("踢出持续时间(秒)")]
public int KickDuration { get; set; } = 600;
[JsonProperty("启用投票封禁")]
public bool EnableBan { get; set; } = false;
[JsonProperty("启用投票禁言")]
public bool EnableMute { get; set; } = true;
[JsonProperty("启用投票清除BOSS")]
public bool EnableBossClear { get; set; } = true;
[JsonProperty("启用投票关闭事件")]
public bool EnableEventClear { get; set; } = true;
[JsonProperty("启用投票修改时间")]
public bool EnableTimeChange { get; set; } = true;
[JsonProperty("启用投票修改天气")]
public bool EnableWeatherChange { get; set; } = true;
[JsonProperty("启用自由投票")]
public bool EnableFreeVote { get; set; } = true;
[JsonProperty("最小投票人数")]
public int MinVote { get; set; } = 3;
[JsonProperty("投票通过率")]
public int VotePass { get; set; } = 60;
public void Write()
{
using StreamWriter streamWriter = new StreamWriter(path);
streamWriter.WriteLine(JsonConvert.SerializeObject(this, Formatting.Indented));
}
public static void GetConfig()
{
var newconfig = new Config();
if (!File.Exists(path))
{
using StreamWriter streamWriter = new StreamWriter(path);
streamWriter.WriteLine(JsonConvert.SerializeObject(config, Formatting.Indented));
}
else
{
using StreamReader streamReader = new StreamReader(path);
newconfig = JsonConvert.DeserializeObject<Config>(streamReader.ReadToEnd())!;
}
config = newconfig;
}
}