diff options
| author | william341 <[email protected]> | 2017-06-29 13:13:45 -0700 |
|---|---|---|
| committer | william341 <[email protected]> | 2017-06-29 13:13:45 -0700 |
| commit | ad387c41e7d6cc547431e88695d4723ea2dba913 (patch) | |
| tree | a68282dda40c4f0b28883241c7adcf9010f4550e /ShiftOS.Objects | |
| parent | b4b19e7a4d203b58537f5b98214296ab52c49b2d (diff) | |
| parent | 5bebd4411bc6266cbee482a429ba794eefa8f9b6 (diff) | |
| download | shiftos_thereturn-ad387c41e7d6cc547431e88695d4723ea2dba913.tar.gz shiftos_thereturn-ad387c41e7d6cc547431e88695d4723ea2dba913.tar.bz2 shiftos_thereturn-ad387c41e7d6cc547431e88695d4723ea2dba913.zip | |
Merge remote-tracking branch 'refs/remotes/shiftos-game/master'
Diffstat (limited to 'ShiftOS.Objects')
| -rw-r--r-- | ShiftOS.Objects/UserConfig.cs | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/ShiftOS.Objects/UserConfig.cs b/ShiftOS.Objects/UserConfig.cs index 579ce00..8232230 100644 --- a/ShiftOS.Objects/UserConfig.cs +++ b/ShiftOS.Objects/UserConfig.cs @@ -14,24 +14,27 @@ namespace ShiftOS.Objects public string DigitalSocietyAddress { get; set; } public int DigitalSocietyPort { get; set; } - public static UserConfig Get() - { - var conf = new UserConfig + private static UserConfig def = new UserConfig { Language = "english", DigitalSocietyAddress = "michaeltheshifter.me", DigitalSocietyPort = 13370 }; - if (!File.Exists("servers.json")) - { - File.WriteAllText("servers.json", JsonConvert.SerializeObject(conf, Formatting.Indented)); - } + public static UserConfig current = null; + + public static UserConfig Get() + { + if (current != null) + return current; + if (File.Exists("servers.json")) + current = JsonConvert.DeserializeObject<UserConfig>(File.ReadAllText("servers.json")); else { - conf = JsonConvert.DeserializeObject<UserConfig>(File.ReadAllText("servers.json")); + File.WriteAllText("servers.json", JsonConvert.SerializeObject(def, Formatting.Indented)); + current = def; } - return conf; + return current; } } } |
