-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConfig.cs
45 lines (38 loc) · 1.21 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
using System.IO;
using TShockAPI;
using Newtonsoft.Json;
namespace TSWVote
{
internal class Config
{
internal static string ConfigPath
{
get { return Path.Combine(TShock.SavePath, "TSWVote.json"); }
}
public int ServerID = 0;
public int NumberOfWebClients = 30;
public int Timeout = 10000;
public bool RequirePermission = false;
public string PermissionName = "vote.vote";
internal static Config Read()
{
if (!Directory.Exists(TShock.SavePath))
{
// This should've probably been fixed with plugin load order,
// But the problem is, I remember the plugin load order already having been set up correctly.
// So I am going to assume something changed on TShock's side of things and this a quick fix,
// Until they sort out the new updates and all the recent bugs they now have.
Directory.CreateDirectory(TShock.SavePath);
}
if (!File.Exists(ConfigPath))
{
File.WriteAllText(ConfigPath, JsonConvert.SerializeObject(new Config(), Formatting.Indented));
}
return JsonConvert.DeserializeObject<Config>(File.ReadAllText(ConfigPath));
}
internal void Write()
{
File.WriteAllText(ConfigPath, JsonConvert.SerializeObject(this, Formatting.Indented));
}
}
}