diff --git a/MinecraftClient/Bots.cs b/MinecraftClient/Bots.cs index 56fe383a..f5c16d73 100644 --- a/MinecraftClient/Bots.cs +++ b/MinecraftClient/Bots.cs @@ -710,7 +710,7 @@ namespace MinecraftClient public static MessageFilter str2filter(string filtername) { - switch (filtername) + switch (filtername.ToLower()) { case "all": return MessageFilter.AllText; case "messages": return MessageFilter.AllMessages; diff --git a/MinecraftClient/ChatParser.cs b/MinecraftClient/ChatParser.cs index 83755f1c..203d6bc7 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).Replace("u0027", "'"); + return JSONData2String(jsonData); } /// @@ -213,7 +213,25 @@ namespace MinecraftClient cursorpos++; while (toparse[cursorpos] != '"') { - if (toparse[cursorpos] == '\\') { cursorpos++; } + if (toparse[cursorpos] == '\\') + { + try //Unicode character \u0123 + { + if (toparse[cursorpos + 1] == 'u' + && isHex(toparse[cursorpos + 2]) + && isHex(toparse[cursorpos + 3]) + && isHex(toparse[cursorpos + 4]) + && isHex(toparse[cursorpos + 5])) + { + //"abc\u0123abc" => "0123" => 0123 => Unicode char n°0123 => Add char to string + data.StringValue += char.ConvertFromUtf32(int.Parse(toparse.Substring(cursorpos + 2, 4), System.Globalization.NumberStyles.HexNumber)); + cursorpos += 6; continue; + } + else cursorpos++; //Normal character escapement \" + } + catch (IndexOutOfRangeException) { cursorpos++; } // \u01 + catch (ArgumentOutOfRangeException) { cursorpos++; } // Unicode index 0123 was invalid + } data.StringValue += toparse[cursorpos]; cursorpos++; } @@ -301,5 +319,13 @@ namespace MinecraftClient return ""; } + + /// + /// Small function for checking if a char is an hexadecimal char (0-9 A-F a-f) + /// + /// Char to test + /// True if hexadecimal + + private static bool isHex(char c) { return ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f')); } } } diff --git a/MinecraftClient/MinecraftCom.cs b/MinecraftClient/MinecraftCom.cs index e055028d..f8bb436f 100644 --- a/MinecraftClient/MinecraftCom.cs +++ b/MinecraftClient/MinecraftCom.cs @@ -182,7 +182,7 @@ namespace MinecraftClient string message = readNextString(); if (protocolversion >= 72) { - //printstring("§8" + message, false); //Debug + //printstring("§8" + message, false); //Debug : Show the RAW JSON data message = ChatParser.ParseText(message); printstring(message, false); }