Skip to content

Commit

Permalink
revert: CFG Auto Update
Browse files Browse the repository at this point in the history
  • Loading branch information
K4ryuu committed Nov 5, 2023
1 parent 9292a88 commit 81232df
Showing 1 changed file with 8 additions and 22 deletions.
30 changes: 8 additions & 22 deletions src/CFG.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,16 @@ public void CheckConfig(string moduleDirectory)
{
CreateAndWriteFile(path);
}
else
{
using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read))
using (StreamReader sr = new StreamReader(fs))
{
// Deserialize the JSON from the file and load the configuration.
config = JsonSerializer.Deserialize<Config>(sr.ReadToEnd())!;
}

if (config != null && config.ChatPrefix != null)
config.ChatPrefix = ModifiedChatPrefix(config.ChatPrefix);

// Check if the FFAMode is missing in the loaded configuration
if (config!.FFAMode == default)
{
config.FFAMode = false;
// Serialize the updated configuration and write it back to the file
string jsonConfig = JsonSerializer.Serialize(config, new JsonSerializerOptions()
{
WriteIndented = true
});
File.WriteAllText(path, jsonConfig);
}
using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read))
using (StreamReader sr = new StreamReader(fs))
{
// Deserialize the JSON from the file and load the configuration.
config = JsonSerializer.Deserialize<Config>(sr.ReadToEnd())!;
}

if (config != null && config.ChatPrefix != null)
config.ChatPrefix = ModifiedChatPrefix(config.ChatPrefix);
}

private static void CreateAndWriteFile(string path)
Expand Down

0 comments on commit 81232df

Please sign in to comment.