Skip to content

Commit

Permalink
feat: config version
Browse files Browse the repository at this point in the history
  • Loading branch information
NuanRMxi committed Sep 10, 2024
1 parent e7a6813 commit 9c515bb
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ private static void Main(string[] args)
if (File.Exists("config.json"))
{
config = JsonConvert.DeserializeObject<Config>(File.ReadAllText("config.json"))!;
if (config.ConfigVersion != 0)
{
LogManager.WriteLog("The configuration file is outdated and will be updated.", LogManager.LogLevel.Warning);
config.ConfigVersion = 0;
File.WriteAllText("config.json", JsonConvert.SerializeObject(config, Formatting.Indented));
}
if (config.isDebug)
{
LogManager.WriteLog("Debug mode is enabled.", LogManager.LogLevel.Warning);
Expand All @@ -30,7 +36,7 @@ private static void Main(string[] args)
else
{
File.WriteAllText("config.json", JsonConvert.SerializeObject(config, Formatting.Indented));
LogManager.JustConsoleWrite(
LogManager.WriteLog(
"We have generated a default configuration file. If modifications are needed, please exit the program and modify \"config.json\", and then run it again.",
LogManager.LogLevel.Warning);
}
Expand Down Expand Up @@ -527,6 +533,7 @@ private static async Task ServerOnClose(IWebSocketConnection socket)
/// </summary>
public class Config
{
public int ConfigVersion = 0;
public bool isPrivate = false;
public bool RoomChat = false;
public bool isDebug = false;
Expand Down

0 comments on commit 9c515bb

Please sign in to comment.