From 061762957067c7570ddafa2ac7f53ebc445a4450 Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Fri, 26 Feb 2016 17:57:05 -0800 Subject: [PATCH 1/2] Fix two bugs with 1.7.10 protocol The first bug is that the list isn't cleared in some cases, meaning new packets get data from the previous packet if it isn't read fully. Most commonly, this happens with a plugin channel message. The second bug happens because lists don't throw IndexOutOfRangeExceptions, but instead throw ArgumentOutOfRangeExceptions. This caused the catch for ignoring message types to not occur, instead causing the client to crash. This only happens in 1.7.10, where the message type is not included. Most likely, these changes will fix the bugs seen in #114 and #117, although they may be caused by other bugs. --- MinecraftClient/Protocol/Handlers/Protocol18.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MinecraftClient/Protocol/Handlers/Protocol18.cs b/MinecraftClient/Protocol/Handlers/Protocol18.cs index d6e8f880..3601b052 100644 --- a/MinecraftClient/Protocol/Handlers/Protocol18.cs +++ b/MinecraftClient/Protocol/Handlers/Protocol18.cs @@ -104,6 +104,7 @@ namespace MinecraftClient.Protocol.Handlers private void readNextPacket(ref int packetID, List packetData) { + packetData.Clear(); int size = readNextVarIntRAW(); //Packet size packetData.AddRange(readDataRAW(size)); //Packet contents @@ -165,7 +166,7 @@ namespace MinecraftClient.Protocol.Handlers || (messageType == 2 && !Settings.DisplayXPBarMessages)) break; } - catch (IndexOutOfRangeException) { /* No message type */ } + catch (ArgumentOutOfRangeException) { /* No message type */ } handler.OnTextReceived(ChatParser.ParseText(message)); break; case 0x08: //Player Position and Look From 5c8f66dbd08a23f5e12ce88e3f19930e92e23fb6 Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Fri, 26 Feb 2016 18:00:53 -0800 Subject: [PATCH 2/2] Fix broken new line in settings Fixes #115. --- MinecraftClient/Settings.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MinecraftClient/Settings.cs b/MinecraftClient/Settings.cs index 5cb3402d..7b0ffe88 100644 --- a/MinecraftClient/Settings.cs +++ b/MinecraftClient/Settings.cs @@ -408,7 +408,7 @@ namespace MinecraftClient + "consoletitle=%username%@%serverip% - Minecraft Console Client\r\n" + "internalcmdchar=slash #use 'none', 'slash' or 'backslash'\r\n" + "splitmessagedelay=2 #seconds between each part of a long message\r\n" - + "botmessagedelay=2 #seconds to delay between message a bot makes to avoid accidental spam\n\n" + + "botmessagedelay=2 #seconds to delay between message a bot makes to avoid accidental spam\r\n" + "mcversion=auto #use 'auto' or '1.X.X' values\r\n" + "brandinfo=mcc #use 'mcc','vanilla', or 'none'\r\n" + "chatbotlogfile= #leave empty for no logfile\r\n"