mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-11-07 17:36:07 +00:00
Bug fix
This commit is contained in:
parent
cc92cd66d4
commit
b79dd1d379
1 changed files with 13 additions and 12 deletions
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
|
using System.Net.Http.Json;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
|
@ -238,7 +239,7 @@ namespace MinecraftClient.Protocol.Message
|
||||||
|
|
||||||
string languageFilePath = "lang" + Path.DirectorySeparatorChar + Config.Main.Advanced.Language + ".json";
|
string languageFilePath = "lang" + Path.DirectorySeparatorChar + Config.Main.Advanced.Language + ".json";
|
||||||
|
|
||||||
// Load the external dictionnary of translation rules or display an error message
|
// Load the external dictionary of translation rules or display an error message
|
||||||
if (File.Exists(languageFilePath))
|
if (File.Exists(languageFilePath))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
@ -272,19 +273,19 @@ namespace MinecraftClient.Protocol.Message
|
||||||
if (Config.Logging.DebugMessages)
|
if (Config.Logging.DebugMessages)
|
||||||
ConsoleIO.WriteLineFormatted(string.Format(Translations.chat_request, translation_file_location));
|
ConsoleIO.WriteLineFormatted(string.Format(Translations.chat_request, translation_file_location));
|
||||||
|
|
||||||
Task<Stream> fetch_file = httpClient.GetStreamAsync(translation_file_location);
|
Task<Dictionary<string, string>?> fetckFileTask = httpClient.GetFromJsonAsync<Dictionary<string, string>>(translation_file_location);
|
||||||
fetch_file.Wait();
|
fetckFileTask.Wait();
|
||||||
TranslationRules = JsonSerializer.Deserialize<Dictionary<string, string>>(fetch_file.Result)!;
|
if (fetckFileTask.Result != null && fetckFileTask.Result.Count > 0)
|
||||||
fetch_file.Dispose();
|
{
|
||||||
|
TranslationRules = fetckFileTask.Result;
|
||||||
TranslationRules["Version"] = TranslationsFile_Version;
|
TranslationRules["Version"] = TranslationsFile_Version;
|
||||||
|
|
||||||
File.WriteAllText(languageFilePath, JsonSerializer.Serialize(TranslationRules, typeof(Dictionary<string, string>)), Encoding.UTF8);
|
File.WriteAllText(languageFilePath, JsonSerializer.Serialize(TranslationRules, typeof(Dictionary<string, string>)), Encoding.UTF8);
|
||||||
|
|
||||||
ConsoleIO.WriteLineFormatted("§8" + string.Format(Translations.chat_done, languageFilePath));
|
ConsoleIO.WriteLineFormatted("§8" + string.Format(Translations.chat_done, languageFilePath));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
fetckFileTask.Dispose();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ConsoleIO.WriteLineFormatted("§8" + Translations.chat_fail, acceptnewlines: true);
|
ConsoleIO.WriteLineFormatted("§8" + Translations.chat_fail, acceptnewlines: true);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue