-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConfiguration.cs
47 lines (38 loc) · 1.34 KB
/
Configuration.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
using Newtonsoft.Json;
using TShockAPI;
namespace AutoAirItem;
internal class Configuration
{
#region 实例变量
[JsonProperty("插件指令权限", Order = -16)]
public string Text { get; set; } = "指令菜单:/air 或 /垃圾,权限名【AutoAir.use】,给玩家权限:/group addperm default AutoAir.use";
[JsonProperty("插件开关", Order = -15)]
public bool Open { get; set; } = true;
[JsonProperty("重启服务器不删数据", Order = -14)]
public bool Db { get; set; } = true;
[JsonProperty("排除垃圾表", Order = -13)]
public int[] Exclude = new int[] { 71,72,73,74 };
#endregion
#region 读取与创建配置文件方法
public static readonly string FilePath = Path.Combine(TShock.SavePath, "自动垃圾桶.json");
public void Write()
{
var json = JsonConvert.SerializeObject(this, Formatting.Indented);
File.WriteAllText(FilePath, json);
}
public static Configuration Read()
{
if (!File.Exists(FilePath))
{
var NewConfig = new Configuration();
new Configuration().Write();
return NewConfig;
}
else
{
var jsonContent = File.ReadAllText(FilePath);
return JsonConvert.DeserializeObject<Configuration>(jsonContent)!;
}
}
#endregion
}