From 734de2a9ac2b0ba487552fcebf45f47493b47259 Mon Sep 17 00:00:00 2001 From: oldkingOK Date: Wed, 10 Jan 2024 11:00:04 +0800 Subject: [PATCH] Login with yggdrasil server 'hitmc.cc' will get ``` Login failed : Invalid server response. ``` Print the raw response which is `result` in [/MinecraftClient/Protocol/ProtocolHandler.cs#L554](https://github.com/oldkingOK/Minecraft-Console-Client/blob/f6797cb4b5f8989d16382d396dfc7ca69f1d6da2/MinecraftClient/Protocol/ProtocolHandler.cs#L554) (Every test shows like this) ``` HTTP/1.1 200 OK ... 1e1 {"accessToken":"...","clientToken":"...","availableProfiles":[{"id":"..","name":".."},{"id":"..","na f me":"ok_bot"}]} 0 ``` After splited by line: - 1e1 - {"accessToken": ... ,"na - f - me":"ok_bot"}]} - 0 The response when Login with 'littleskin.cn' which works fine is: ``` HTTP/1.1 200 OK ... 1e1 {"accessToken":"...","clientToken":"...","availableProfiles":[{"id":"..","name":".."},{"id":"..","name":"ok_bot"}]} 0 ``` After splited by line: - 1e1 - {"accessToken": ... ,"name":"ok_bot"}]} - 0 - - So adding [1] and [3] will make both 'hitmc.cc' and 'littleskin.cn' work fine. --- MinecraftClient/Protocol/ProtocolHandler.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MinecraftClient/Protocol/ProtocolHandler.cs b/MinecraftClient/Protocol/ProtocolHandler.cs index 92e53ce2..ee473472 100644 --- a/MinecraftClient/Protocol/ProtocolHandler.cs +++ b/MinecraftClient/Protocol/ProtocolHandler.cs @@ -1100,7 +1100,8 @@ namespace MinecraftClient.Protocol statusCode = int.Parse(raw_result.Split(' ')[1], NumberStyles.Any, CultureInfo.CurrentCulture); if (statusCode != 204) { - postResult = raw_result[(raw_result.IndexOf("\r\n\r\n") + 4)..].Split("\r\n")[1]; + var splited = raw_result[(raw_result.IndexOf("\r\n\r\n") + 4)..].Split("\r\n"); + postResult = splited[1] + splited[3]; } else {