Repository navigation
Expand file tree
/
Copy pathC3ConfigFile.cs
More file actions
89 lines (74 loc) · 2.64 KB
/
Copy pathC3ConfigFile.cs
File metadata and controls
89 lines (74 loc) · 2.64 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
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
82
83
84
85
86
87
88
89
using System;
using System.IO;
using Newtonsoft.Json;
namespace C3Mod
{
public class C3ConfigFile
{
public bool TPLockEnabled = true;
public int VoteTime = 30;
public int VoteMinimumPerTeam = 1;
public int VoteNotifyInterval = 7;
public int DuelTimesToNotify = 5;
public int DuelNotifyInterval = 7;
public int DuelScoreLimit = 3;
public int CTFScoreLimit = 3;
public int OneFlagScorelimit = 3;
public int TeamDeathmatchScorelimit = 20;
public int FFAScorelimit = 10;
public int TDMScoreNotifyInterval = 30;
public bool HealPlayersOnFlagCapture = false;
public bool RespawnPlayersOnFlagCapture = false;
public bool ReCountdownOnFlagCapture = false;
public int MonsterApocalypseLivesPerWave = 1;
public int MonsterApocalypseIntermissionTime = 20;
public int MonsterApocalypseScoreNotifyInterval = 15;
public int MonsterApocalypseMinimumPlayers = 1;
public bool DuelsEnabled = false;
public bool CTFEnabled = false;
public bool OneFlagEnabled = false;
public bool TeamDeathmatchEnabled = false;
public bool MonsterApocalypseEnabled = false;
public bool FreeForAllEnabled = false;
public bool C3TeamsLocked = true;
public int FFASpawnProtectionTime = 10;
public bool ShowWelcomeMessage = true;
public int TeamColor1 = 1;
public int TeamColor2 = 3;
internal static C3ConfigFile Read(string path)
{
if (!File.Exists(path))
return new C3ConfigFile();
using (var fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read))
{
return Read(fs);
}
}
internal static C3ConfigFile Read(Stream stream)
{
using (var sr = new StreamReader(stream))
{
var cf = JsonConvert.DeserializeObject<C3ConfigFile>(sr.ReadToEnd());
if (ConfigRead != null)
ConfigRead(cf);
return cf;
}
}
internal void Write(string path)
{
using (var fs = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Write))
{
Write(fs);
}
}
internal void Write(Stream stream)
{
var str = JsonConvert.SerializeObject(this, Formatting.Indented);
using (var sw = new StreamWriter(stream))
{
sw.Write(str);
}
}
internal static Action<C3ConfigFile> ConfigRead;
}
}