diff --git a/MinecraftClient/Bots.cs b/MinecraftClient/Bots.cs index ca3b34c7..4da3f296 100644 --- a/MinecraftClient/Bots.cs +++ b/MinecraftClient/Bots.cs @@ -127,10 +127,10 @@ namespace MinecraftClient try { //Detect vanilla /tell messages - //Someone whispers message + //Someone whispers to you: message if (tmp.Length > 2 && tmp[1] == "whispers") { - message = text.Substring(tmp[0].Length + 10); + message = text.Substring(tmp[0].Length + 18); sender = tmp[0]; return isValidName(sender); } @@ -264,7 +264,7 @@ namespace MinecraftClient } /// - /// This bot sends a /ping command every 60 seconds in order to stay non-afk. + /// This bot sends a command every 60 seconds in order to stay non-afk. /// public class AntiAFK : ChatBot @@ -289,7 +289,7 @@ namespace MinecraftClient count++; if (count == timeping) { - SendText("/ping"); + SendText(Settings.AntiAFK_Command); count = 0; } } @@ -875,14 +875,33 @@ namespace MinecraftClient public override void Initialize() { - // Loads the given file from the startup parameters - if (System.IO.File.Exists(file)) + //Load the given file from the startup parameters + //Automatically look in subfolders and try to add ".txt" file extension + string[] files = new string[] { - lines = System.IO.File.ReadAllLines(file); // Load the given bot text file (containing commands) + file, + file + ".txt", + "scripts\\" + file, + "scripts\\" + file + ".txt", + "config\\" + file, + "config\\" + file + ".txt", + }; + + bool file_found = false; + + foreach (string possible_file in files) + { + if (System.IO.File.Exists(possible_file)) + { + lines = System.IO.File.ReadAllLines(possible_file); + file_found = true; + break; + } } - else + + if (!file_found) { - LogToConsole("File not found: " + file); + LogToConsole("File not found: '" + file + "'"); UnloadBot(); //No need to keep the bot active } } @@ -898,9 +917,9 @@ namespace MinecraftClient nextline++; //Move the cursor so that the next time the following line will be interpreted sleepticks = sleepticks_interval; //Used to delay next command sending and prevent from beign kicked for spamming - if (instruction_line.Length > 0) + if (instruction_line.Length > 1) { - if (!instruction_line.StartsWith("//") && !instruction_line.StartsWith("#")) + if (instruction_line[0] != '#' && instruction_line[0] != '/' && instruction_line[1] != '/') { string instruction_name = instruction_line.Split(' ')[0]; switch (instruction_name.ToLower()) diff --git a/MinecraftClient/ChatParser.cs b/MinecraftClient/ChatParser.cs index 2faff1d3..5f9daf6b 100644 --- a/MinecraftClient/ChatParser.cs +++ b/MinecraftClient/ChatParser.cs @@ -21,7 +21,7 @@ namespace MinecraftClient { int cursorpos = 0; JSONData jsonData = String2Data(json, ref cursorpos); - return JSONData2String(jsonData); + return JSONData2String(jsonData, ""); } /// @@ -96,14 +96,37 @@ namespace MinecraftClient 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_US.lang + if (!System.IO.File.Exists(Settings.TranslationsFile) //Try en_GB.lang && System.IO.File.Exists(Settings.TranslationsFile_FromMCDir)) - { Settings.TranslationsFile = Settings.TranslationsFile_FromMCDir; } - if (!System.IO.File.Exists(Settings.TranslationsFile) //Still not found? try en_GB.lang - && System.IO.File.Exists(Settings.TranslationsFile_FromMCDir_Alt)) - { Settings.TranslationsFile = Settings.TranslationsFile_FromMCDir_Alt; } + { + Settings.TranslationsFile = Settings.TranslationsFile_FromMCDir; + Console.ForegroundColor = ConsoleColor.DarkGray; + ConsoleIO.WriteLine("Using en_GB.lang from your Minecraft directory."); + Console.ForegroundColor = ConsoleColor.Gray; + } - //Load an external dictionnary of translation rules + //Still not found? try downloading en_GB from Mojang's servers? + if (!System.IO.File.Exists(Settings.TranslationsFile)) + { + Console.ForegroundColor = ConsoleColor.DarkGray; + ConsoleIO.WriteLine("Downloading en_GB.lang from Mojang's servers..."); + try + { + string assets_index = downloadString(Settings.TranslationsFile_Website_Index); + string[] tmp = assets_index.Split(new string[] { "lang/en_GB.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 + '"'); + } + catch + { + ConsoleIO.WriteLine("Failed to download the file."); + } + Console.ForegroundColor = ConsoleColor.Gray; + } + + //Load the external dictionnary of translation rules or display an error message if (System.IO.File.Exists(Settings.TranslationsFile)) { string[] translations = System.IO.File.ReadAllLines(Settings.TranslationsFile); @@ -281,41 +304,43 @@ namespace MinecraftClient /// Use a JSON Object to build the corresponding string /// /// JSON object to convert + /// Allow parent color code to affect child elements (set to "" for function init) /// returns the Minecraft-formatted string - private static string JSONData2String(JSONData data) + private static string JSONData2String(JSONData data, string colorcode) { string extra_result = ""; - string colorcode = ""; switch (data.Type) { case JSONData.DataType.Object: + if (data.Properties.ContainsKey("color")) + { + colorcode = color2tag(JSONData2String(data.Properties["color"], "")); + } if (data.Properties.ContainsKey("extra")) { JSONData[] extras = data.Properties["extra"].DataArray.ToArray(); foreach (JSONData item in extras) - extra_result = extra_result + JSONData2String(item) + "§r"; - } - if (data.Properties.ContainsKey("color")) - { - colorcode = color2tag(JSONData2String(data.Properties["color"])); + extra_result = extra_result + JSONData2String(item, colorcode) + "§r"; } if (data.Properties.ContainsKey("text")) { - return extra_result + colorcode + JSONData2String(data.Properties["text"]) + colorcode; + return colorcode + JSONData2String(data.Properties["text"], colorcode) + extra_result; } else if (data.Properties.ContainsKey("translate")) { List using_data = new List(); - if (data.Properties.ContainsKey("using")) + if (data.Properties.ContainsKey("using") && !data.Properties.ContainsKey("with")) + data.Properties["with"] = data.Properties["using"]; + if (data.Properties.ContainsKey("with")) { - JSONData[] array = data.Properties["using"].DataArray.ToArray(); + JSONData[] array = data.Properties["with"].DataArray.ToArray(); for (int i = 0; i < array.Length; i++) { - using_data.Add(JSONData2String(array[i])); + using_data.Add(JSONData2String(array[i], colorcode)); } } - return extra_result + colorcode + TranslateString(JSONData2String(data.Properties["translate"]), using_data) + colorcode; + return colorcode + TranslateString(JSONData2String(data.Properties["translate"], ""), using_data) + extra_result; } else return extra_result; @@ -323,12 +348,12 @@ namespace MinecraftClient string result = ""; foreach (JSONData item in data.DataArray) { - result += JSONData2String(item); + result += JSONData2String(item, colorcode); } return result; case JSONData.DataType.String: - return data.StringValue; + return colorcode + data.StringValue; } return ""; @@ -341,5 +366,23 @@ namespace MinecraftClient /// True if hexadecimal private static bool isHex(char c) { return ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f')); } + + /// + /// Do a HTTP request to get a webpage or text data from a server file + /// + /// URL of resource + /// Returns resource data if success, otherwise a WebException is raised + + private static string downloadString(string url) + { + System.Net.HttpWebRequest myRequest = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(url); + myRequest.Method = "GET"; + System.Net.WebResponse myResponse = myRequest.GetResponse(); + System.IO.StreamReader sr = new System.IO.StreamReader(myResponse.GetResponseStream(), System.Text.Encoding.UTF8); + string result = sr.ReadToEnd(); + sr.Close(); + myResponse.Close(); + return result; + } } } diff --git a/MinecraftClient/ConsoleIO.cs b/MinecraftClient/ConsoleIO.cs index b01f1137..25bbacce 100644 --- a/MinecraftClient/ConsoleIO.cs +++ b/MinecraftClient/ConsoleIO.cs @@ -2,6 +2,8 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using System.Windows.Forms; +using System.Threading; namespace MinecraftClient { @@ -80,77 +82,86 @@ namespace MinecraftClient k = Console.ReadKey(true); while (writing_lock) { } reading_lock = true; - switch (k.Key) + if (k.Key == ConsoleKey.V && k.Modifiers == ConsoleModifiers.Control) { - case ConsoleKey.Escape: - ClearLineAndBuffer(); - break; - case ConsoleKey.Backspace: - RemoveOneChar(); - break; - case ConsoleKey.Enter: - Console.Write('\n'); - break; - case ConsoleKey.LeftArrow: - GoLeft(); - break; - case ConsoleKey.RightArrow: - GoRight(); - break; - case ConsoleKey.Home: - while (buffer.Length > 0) { GoLeft(); } - break; - case ConsoleKey.End: - while (buffer2.Length > 0) { GoRight(); } - break; - case ConsoleKey.Delete: - if (buffer2.Length > 0) - { - GoRight(); + string clip = ReadClipboard(); + foreach (char c in clip) + AddChar(c); + } + else + { + switch (k.Key) + { + case ConsoleKey.Escape: + ClearLineAndBuffer(); + break; + case ConsoleKey.Backspace: RemoveOneChar(); - } - break; - case ConsoleKey.Oem6: - break; - case ConsoleKey.DownArrow: - if (previous.Count > 0) - { - ClearLineAndBuffer(); - buffer = previous.First.Value; - previous.AddLast(buffer); - previous.RemoveFirst(); - Console.Write(buffer); - } - break; - case ConsoleKey.UpArrow: - if (previous.Count > 0) - { - ClearLineAndBuffer(); - buffer = previous.Last.Value; - previous.AddFirst(buffer); - previous.RemoveLast(); - Console.Write(buffer); - } - break; - case ConsoleKey.Tab: - if (autocomplete_engine != null && buffer.Length > 0) - { - string[] tmp = buffer.Split(' '); - if (tmp.Length > 0) + break; + case ConsoleKey.Enter: + Console.Write('\n'); + break; + case ConsoleKey.LeftArrow: + GoLeft(); + break; + case ConsoleKey.RightArrow: + GoRight(); + break; + case ConsoleKey.Home: + while (buffer.Length > 0) { GoLeft(); } + break; + case ConsoleKey.End: + while (buffer2.Length > 0) { GoRight(); } + break; + case ConsoleKey.Delete: + if (buffer2.Length > 0) { - string word_tocomplete = tmp[tmp.Length - 1]; - string word_autocomplete = autocomplete_engine.AutoComplete(word_tocomplete); - if (!String.IsNullOrEmpty(word_autocomplete) && word_autocomplete != word_tocomplete) + GoRight(); + RemoveOneChar(); + } + break; + case ConsoleKey.Oem6: + break; + case ConsoleKey.DownArrow: + if (previous.Count > 0) + { + ClearLineAndBuffer(); + buffer = previous.First.Value; + previous.AddLast(buffer); + previous.RemoveFirst(); + Console.Write(buffer); + } + break; + case ConsoleKey.UpArrow: + if (previous.Count > 0) + { + ClearLineAndBuffer(); + buffer = previous.Last.Value; + previous.AddFirst(buffer); + previous.RemoveLast(); + Console.Write(buffer); + } + break; + case ConsoleKey.Tab: + if (autocomplete_engine != null && buffer.Length > 0) + { + string[] tmp = buffer.Split(' '); + if (tmp.Length > 0) { - while (buffer.Length > 0 && buffer[buffer.Length - 1] != ' ') { RemoveOneChar(); } - foreach (char c in word_autocomplete) { AddChar(c); } + string word_tocomplete = tmp[tmp.Length - 1]; + string word_autocomplete = autocomplete_engine.AutoComplete(word_tocomplete); + if (!String.IsNullOrEmpty(word_autocomplete) && word_autocomplete != word_tocomplete) + { + while (buffer.Length > 0 && buffer[buffer.Length - 1] != ' ') { RemoveOneChar(); } + foreach (char c in word_autocomplete) { AddChar(c); } + } } } - } - break; - default: - AddChar(k.KeyChar); - break; + break; + default: + AddChar(k.KeyChar); + break; + } } reading_lock = false; } @@ -212,7 +223,7 @@ namespace MinecraftClient } #endregion - #region subfunctions + #region Subfunctions private static void ClearLineAndBuffer() { while (buffer2.Length > 0) { GoRight(); } @@ -275,6 +286,27 @@ namespace MinecraftClient for (int i = 0; i < buffer2.Length; i++) { GoBack(); } } #endregion + + #region Clipboard management + private static string ReadClipboard() + { + string clipdata = ""; + Thread staThread = new Thread(new ThreadStart( + delegate + { + try + { + clipdata = Clipboard.GetText(); + } + catch { } + } + )); + staThread.SetApartmentState(ApartmentState.STA); + staThread.Start(); + staThread.Join(); + return clipdata; + } + #endregion } /// diff --git a/MinecraftClient/McTcpClient.cs b/MinecraftClient/McTcpClient.cs index f1df7884..8365e647 100644 --- a/MinecraftClient/McTcpClient.cs +++ b/MinecraftClient/McTcpClient.cs @@ -143,6 +143,9 @@ namespace MinecraftClient { try { + //Needed if the player is dead + handler.SendRespawnPacket(); + while (client.Client.Connected) { text = ConsoleIO.ReadLine(); @@ -160,9 +163,21 @@ namespace MinecraftClient } else { - if (text.ToLower() == "/quit" || text.ToLower().StartsWith("/exec ") || text.ToLower() == "/reco" || text.ToLower() == "/reconnect") { break; } - while (text.Length > 0 && text[0] == ' ') { text = text.Substring(1); } - if (text != "") + text = text.Trim(); + if (text.ToLower() == "/quit" || text.ToLower() == "/reco") + { + break; + } + else if (text.ToLower() == "/respawn") + { + handler.SendRespawnPacket(); + ConsoleIO.WriteLine("You have respawned."); + } + else if (text.ToLower().StartsWith("/script ")) + { + handler.BotLoad(new Bots.Scripting(text.Substring(8))); + } + else if (text != "") { //Message is too long if (text.Length > 100) @@ -175,7 +190,7 @@ namespace MinecraftClient } else { - //Send the message splitted in sereval messages + //Send the message splitted in several messages while (text.Length > 100) { handler.SendChatMessage(text.Substring(0, 100)); @@ -189,22 +204,10 @@ namespace MinecraftClient } } - if (text.ToLower() == "/quit") + switch (text.ToLower()) { - ConsoleIO.WriteLine("You have left the server."); - Disconnect(); - } - - else if (text.ToLower().StartsWith("/exec ")) { - handler.BotLoad(new Bots.Scripting("config/" + text.Split()[1])); - } - - - else if (text.ToLower() == "/reco" || text.ToLower() == "/reconnect") - { - ConsoleIO.WriteLine("You have left the server."); - handler.SendRespawnPacket(); - Program.Restart(); + case "/quit": Program.Exit(); break; + case "/reco": Program.Restart(); break; } } catch (IOException) { } diff --git a/MinecraftClient/MinecraftClient.csproj b/MinecraftClient/MinecraftClient.csproj index 78e2c47e..48af6f73 100644 --- a/MinecraftClient/MinecraftClient.csproj +++ b/MinecraftClient/MinecraftClient.csproj @@ -74,6 +74,7 @@ + diff --git a/MinecraftClient/MinecraftCom.cs b/MinecraftClient/MinecraftCom.cs index ec22a810..12cbb708 100644 --- a/MinecraftClient/MinecraftCom.cs +++ b/MinecraftClient/MinecraftCom.cs @@ -132,16 +132,6 @@ namespace MinecraftClient message = ChatParser.ParseText(message); printstring(message, false); for (int i = 0; i < bots.Count; i++) { bots[i].GetText(message); } break; - case 0x37: - int stats_count = readNextVarInt(); - for (int i = 0; i < stats_count; i++) - { - string stat_name = readNextString(); - readNextVarInt(); //stat value - if (stat_name == "stat.deaths") - printstring("You are dead. Type /reco to respawn & reconnect.", false); - } - break; case 0x3A: int autocomplete_count = readNextVarInt(); string tab_list = ""; @@ -343,7 +333,6 @@ namespace MinecraftClient private void setEncryptedClient(Crypto.AesStream n) { s = n; encrypted = true; } private void Receive(byte[] buffer, int start, int offset, SocketFlags f) { - while (c.Client.Available < start + offset) { } if (encrypted) { s.Read(buffer, start, offset); @@ -549,6 +538,9 @@ namespace MinecraftClient if (message == null) message = ""; + message.Replace("\"", "\\\""); + message = "\"" + message + "\""; + try { byte[] packet_id = getVarInt(0x40); diff --git a/MinecraftClient/Program.cs b/MinecraftClient/Program.cs index a4415789..aa0516d0 100644 --- a/MinecraftClient/Program.cs +++ b/MinecraftClient/Program.cs @@ -15,7 +15,7 @@ namespace MinecraftClient { private static McTcpClient Client; public static string[] startupargs; - public const string Version = "1.7.0"; + public const string Version = "1.7.1"; /// /// The main entry point of Minecraft Console Client @@ -29,16 +29,28 @@ namespace MinecraftClient if (args.Length >= 1 && args[args.Length - 1] == "BasicIO") { ConsoleIO.basicIO = true; + Console.OutputEncoding = Console.InputEncoding = Encoding.GetEncoding(System.Globalization.CultureInfo.CurrentCulture.TextInfo.ANSICodePage); args = args.Where(o => !Object.ReferenceEquals(o, args[args.Length - 1])).ToArray(); } - //Processing Command-line arguments or Config File - - if (args.Length == 1 && System.IO.File.Exists(args[0])) + //Process ini configuration file + if (args.Length >= 1 && System.IO.File.Exists(args[0]) && System.IO.Path.GetExtension(args[0]).ToLower() == ".ini") { Settings.LoadSettings(args[0]); + + //remove ini configuration file from arguments array + List args_tmp = args.ToList(); + args_tmp.RemoveAt(0); + args = args_tmp.ToArray(); } - else if (args.Length >= 1) + else if (System.IO.File.Exists("MinecraftClient.ini")) + { + Settings.LoadSettings("MinecraftClient.ini"); + } + else Settings.WriteDefaultSettings("MinecraftClient.ini"); + + //Other command-line arguments + if (args.Length >= 1) { Settings.Login = args[0]; if (args.Length >= 2) @@ -141,11 +153,11 @@ namespace MinecraftClient } } } - else if (System.IO.File.Exists("MinecraftClient.ini")) + + if (Settings.ConsoleTitle != "") { - Settings.LoadSettings("MinecraftClient.ini"); + Console.Title = Settings.ConsoleTitle.Replace("%username%", "New Window"); } - else Settings.WriteDefaultSettings("MinecraftClient.ini"); //Asking the user to type in missing data such as Username and Password @@ -198,6 +210,11 @@ namespace MinecraftClient } if (result == MinecraftCom.LoginResult.Success) { + if (Settings.ConsoleTitle != "") + { + Console.Title = Settings.ConsoleTitle.Replace("%username%", Settings.Username); + } + Console.WriteLine("Success. (session ID: " + sessionID + ')'); if (Settings.ServerIP == "") { diff --git a/MinecraftClient/Settings.cs b/MinecraftClient/Settings.cs index f6a3284c..b1b3c1a2 100644 --- a/MinecraftClient/Settings.cs +++ b/MinecraftClient/Settings.cs @@ -21,16 +21,19 @@ namespace MinecraftClient public static string Password = ""; public static string ServerIP = ""; public static string SingleCommand = ""; + public static string ConsoleTitle = ""; //Other Settings - public static string TranslationsFile_FromMCDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\.minecraft\assets\virtual\legacy\lang\en_US.lang"; - public static string TranslationsFile_FromMCDir_Alt = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\.minecraft\assets\virtual\legacy\lang\en_GB.lang"; + 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"; //AntiAFK Settings public static bool AntiAFK_Enabled = false; public static int AntiAFK_Delay = 600; + public static string AntiAFK_Command = "/ping"; //Hangman Settings public static bool Hangman_Enabled = false; @@ -120,7 +123,7 @@ namespace MinecraftClient case "singlecommand": SingleCommand = argValue; break; case "translationsfile": TranslationsFile = argValue; break; case "botownersfile": Bots_OwnersFile = argValue; break; - case "consoletitle": Console.Title = argValue; break; + case "consoletitle": ConsoleTitle = argValue; break; } break; @@ -138,6 +141,7 @@ namespace MinecraftClient { case "enabled": AntiAFK_Enabled = str2bool(argValue); break; case "delay": AntiAFK_Delay = str2int(argValue); break; + case "command": AntiAFK_Command = argValue == "" ? "/ping" : argValue; break; } break; @@ -195,7 +199,56 @@ namespace MinecraftClient public static void WriteDefaultSettings(string settingsfile) { - System.IO.File.WriteAllText(settingsfile, "#Minecraft Console Client v" + Program.Version + "\r\n#Startup Config File\r\n\r\n[Main]\r\n\r\n#General settings\r\n#leave blank = prompt user on startup\r\n#Use \"-\" as password for offline mode\r\n\r\nlogin=\r\npassword=\r\nserverip=\r\n\r\n#Advanced settings\r\n\r\ntranslationsfile=translations.lang\r\nbotownersfile=bot-owners.txt\r\nconsoletitle=Minecraft Console Client\r\n\r\n#Bot Settings\r\n\r\n[Alerts]\r\nenabled=false\r\nalertsfile=alerts.txt\r\nexcludesfile=alerts-exclude.txt\r\n\r\n[AntiAFK]\r\nenabled=false\r\ndelay=600 #10 = 1s\r\n\r\n[AutoRelog]\r\nenabled=false\r\ndelay=10\r\nretries=3 #-1 = unlimited\r\nkickmessagesfile=kickmessages.txt\r\n\r\n[ChatLog]\r\nenabled=false\r\ntimestamps=true\r\nfilter=messages\r\nlogfile=chatlog.txt\r\n\r\n[Hangman]\r\nenabled=false\r\nenglish=true\r\nwordsfile=hangman-en.txt\r\nfichiermots=hangman-fr.txt\r\n\r\n[Scripting]\r\nenabled=false\r\nscriptfile=testscript.txt\r\n", Encoding.UTF8); + System.IO.File.WriteAllText(settingsfile, "#Minecraft Console Client v" + Program.Version + "\r\n" + + "#Startup Config File\r\n" + + "\r\n" + + "[Main]\r\n" + + "\r\n" + + "#General settings\r\n" + + "#leave blank = prompt user on startup\r\n" + + "#Use \"-\" as password for offline mode\r\n" + + "\r\n" + + "login=\r\npassword=\r\nserverip=\r\n" + + "\r\n" + + "#Advanced settings\r\n" + + "\r\n" + + "translationsfile=translations.lang\r\n" + + "botownersfile=bot-owners.txt\r\n" + + "consoletitle=Minecraft Console Client - %username%\r\n" + + "\r\n" + + "#Bot Settings\r\n" + + "\r\n" + + "[Alerts]\r\n" + + "enabled=false\r\n" + + "alertsfile=alerts.txt\r\n" + + "excludesfile=alerts-exclude.txt\r\n" + + "\r\n" + + "[AntiAFK]\r\n" + + "enabled=false\r\n" + + "delay=600 #10 = 1s\r\n" + + "command=/ping\r\n" + + "\r\n" + + "[AutoRelog]\r\n" + + "enabled=false\r\n" + + "delay=10\r\n" + + "retries=3 #-1 = unlimited\r\n" + + "kickmessagesfile=kickmessages.txt\r\n" + + "\r\n" + + "[ChatLog]\r\n" + + "enabled=false\r\n" + + "timestamps=true\r\n" + + "filter=messages\r\n" + + "logfile=chatlog.txt\r\n" + + "\r\n" + + "[Hangman]\r\n" + + "enabled=false\r\n" + + "english=true\r\n" + + "wordsfile=hangman-en.txt\r\n" + + "fichiermots=hangman-fr.txt\r\n" + + "\r\n" + + "[Scripting]\r\n" + + "enabled=false\r\n" + + "scriptfile=testscript.txt\r\n", Encoding.UTF8); } public static int str2int(string str) { try { return Convert.ToInt32(str); } catch { return 0; } } diff --git a/MinecraftClientGUI/MinecraftClient.cs b/MinecraftClientGUI/MinecraftClient.cs index 1675f4dc..987be7cd 100644 --- a/MinecraftClientGUI/MinecraftClient.cs +++ b/MinecraftClientGUI/MinecraftClient.cs @@ -59,7 +59,7 @@ namespace MinecraftClientGUI Client.StartInfo.FileName = ExePath; Client.StartInfo.Arguments = arguments; Client.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; - Client.StartInfo.StandardOutputEncoding = Encoding.GetEncoding(850); + Client.StartInfo.StandardOutputEncoding = Encoding.GetEncoding(System.Globalization.CultureInfo.CurrentCulture.TextInfo.ANSICodePage); Client.StartInfo.UseShellExecute = false; Client.StartInfo.RedirectStandardOutput = true; Client.StartInfo.RedirectStandardInput = true;