-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfig.cs
More file actions
54 lines (50 loc) · 1.58 KB
/
Copy pathConfig.cs
File metadata and controls
54 lines (50 loc) · 1.58 KB
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
using Newtonsoft.Json;
using Rocket.API;
using System.Collections.Generic;
using System.IO;
namespace LiteWhitelist
{
public class Config
{
public bool WhitelistEnabled { get; set; }
public int QueueInterval { get; set; }
public string DeniedMessage { get; set; }
public HashSet<ulong> WhitelistedUsers { get; set; }
public void LoadDefaults() {
this.WhitelistEnabled = true;
QueueInterval = 5;
this.DeniedMessage = "Server is currently only allowing Donators and Staff";
this.WhitelistedUsers = new HashSet<ulong>(11)
{
76561199015319396UL,
76561198860356692UL,
76561198122135022UL,
76561198343617672UL,
76561198282562527UL,
76561198322584057UL,
76561198796248492UL,
76561199216254915UL,
76561198446113409UL,
76561199648915892UL,
76561198162135741UL
};
}
public static Config Load(string filePath)
{
if (!File.Exists(filePath))
{
var config = new Config();
config.LoadDefaults();
File.WriteAllText(filePath, JsonConvert.SerializeObject(config, Formatting.Indented));
return config;
}
string json = File.ReadAllText(filePath);
return JsonConvert.DeserializeObject<Config>(json);
}
public void Save(string filePath)
{
string json = JsonConvert.SerializeObject(this, Formatting.Indented);
File.WriteAllText(filePath, json);
}
}
}