diff --git a/MinecraftClient/ChatParser.cs b/MinecraftClient/ChatParser.cs index 5f9daf6b..7a656792 100644 --- a/MinecraftClient/ChatParser.cs +++ b/MinecraftClient/ChatParser.cs @@ -95,29 +95,25 @@ namespace MinecraftClient TranslationRules["commands.message.display.incoming"] = "§7%s whispers to you: %s"; TranslationRules["commands.message.display.outgoing"] = "§7You whisper to %s: %s"; - //Use translations from Minecraft assets if translation file is not found but a copy of the game is installed? - if (!System.IO.File.Exists(Settings.TranslationsFile) //Try en_GB.lang - && System.IO.File.Exists(Settings.TranslationsFile_FromMCDir)) - { - Settings.TranslationsFile = Settings.TranslationsFile_FromMCDir; - Console.ForegroundColor = ConsoleColor.DarkGray; - ConsoleIO.WriteLine("Using en_GB.lang from your Minecraft directory."); - Console.ForegroundColor = ConsoleColor.Gray; - } + //Language file in a subfolder, depending on the language setting + if (!System.IO.Directory.Exists("lang")) + System.IO.Directory.CreateDirectory("lang"); - //Still not found? try downloading en_GB from Mojang's servers? - if (!System.IO.File.Exists(Settings.TranslationsFile)) + string Language_File = "lang\\" + Settings.Language + ".lang"; + + //File not found? Try downloading language file from Mojang's servers? + if (!System.IO.File.Exists(Language_File)) { Console.ForegroundColor = ConsoleColor.DarkGray; - ConsoleIO.WriteLine("Downloading en_GB.lang from Mojang's servers..."); + ConsoleIO.WriteLine("Downloading '" + Settings.Language + ".lang' from Mojang servers..."); try { string assets_index = downloadString(Settings.TranslationsFile_Website_Index); - string[] tmp = assets_index.Split(new string[] { "lang/en_GB.lang" }, StringSplitOptions.None); + string[] tmp = assets_index.Split(new string[] { "lang/" + Settings.Language + ".lang" }, StringSplitOptions.None); tmp = tmp[1].Split(new string[] { "hash\": \"" }, StringSplitOptions.None); string hash = tmp[1].Split('"')[0]; //Translations file identifier on Mojang's servers - System.IO.File.WriteAllText(Settings.TranslationsFile, downloadString(Settings.TranslationsFile_Website_Download + '/' + hash.Substring(0, 2) + '/' + hash)); - ConsoleIO.WriteLine("Done. File saved as \"" + Settings.TranslationsFile + '"'); + System.IO.File.WriteAllText(Language_File, downloadString(Settings.TranslationsFile_Website_Download + '/' + hash.Substring(0, 2) + '/' + hash)); + ConsoleIO.WriteLine("Done. File saved as '" + Language_File + '\''); } catch { @@ -126,10 +122,20 @@ namespace MinecraftClient Console.ForegroundColor = ConsoleColor.Gray; } - //Load the external dictionnary of translation rules or display an error message - if (System.IO.File.Exists(Settings.TranslationsFile)) + //Download Failed? Defaulting to en_GB.lang if the game is installed + if (!System.IO.File.Exists(Language_File) //Try en_GB.lang + && System.IO.File.Exists(Settings.TranslationsFile_FromMCDir)) { - string[] translations = System.IO.File.ReadAllLines(Settings.TranslationsFile); + Language_File = Settings.TranslationsFile_FromMCDir; + Console.ForegroundColor = ConsoleColor.DarkGray; + ConsoleIO.WriteLine("Defaulting to en_GB.lang from your Minecraft directory."); + Console.ForegroundColor = ConsoleColor.Gray; + } + + //Load the external dictionnary of translation rules or display an error message + if (System.IO.File.Exists(Language_File)) + { + string[] translations = System.IO.File.ReadAllLines(Language_File); foreach (string line in translations) { if (line.Length > 0) @@ -149,8 +155,7 @@ namespace MinecraftClient else //No external dictionnary found. { Console.ForegroundColor = ConsoleColor.DarkGray; - ConsoleIO.WriteLine("Translations file not found: \"" + Settings.TranslationsFile + "\"" - + "\nYou can pick a translation file from .minecraft\\assets\\lang\\" + ConsoleIO.WriteLine("Translations file not found: \"" + Language_File + "\"" + "\nSome messages won't be properly printed without this file."); Console.ForegroundColor = ConsoleColor.Gray; } diff --git a/MinecraftClient/Settings.cs b/MinecraftClient/Settings.cs index b1b3c1a2..b107fc74 100644 --- a/MinecraftClient/Settings.cs +++ b/MinecraftClient/Settings.cs @@ -27,8 +27,8 @@ namespace MinecraftClient public static string TranslationsFile_FromMCDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\.minecraft\assets\objects\9e\9e2fdc43fc1c7024ff5922b998fadb2971a64ee0"; //MC 1.7.4 en_GB.lang public static string TranslationsFile_Website_Index = "https://s3.amazonaws.com/Minecraft.Download/indexes/1.7.4.json"; public static string TranslationsFile_Website_Download = "http://resources.download.minecraft.net"; - public static string TranslationsFile = "translations.lang"; public static string Bots_OwnersFile = "bot-owners.txt"; + public static string Language = "en_GB"; //AntiAFK Settings public static bool AntiAFK_Enabled = false; @@ -121,7 +121,7 @@ namespace MinecraftClient case "password": Password = argValue; break; case "serverip": ServerIP = argValue; break; case "singlecommand": SingleCommand = argValue; break; - case "translationsfile": TranslationsFile = argValue; break; + case "language": Language = argValue; break; case "botownersfile": Bots_OwnersFile = argValue; break; case "consoletitle": ConsoleTitle = argValue; break; } @@ -212,7 +212,7 @@ namespace MinecraftClient + "\r\n" + "#Advanced settings\r\n" + "\r\n" - + "translationsfile=translations.lang\r\n" + + "language=en_GB\r\n" + "botownersfile=bot-owners.txt\r\n" + "consoletitle=Minecraft Console Client - %username%\r\n" + "\r\n"