Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions MinecraftClient/MinecraftCom.cs
Original file line number Diff line number Diff line change
Expand Up @@ -396,12 +396,20 @@ public static bool GetServerInfo(string serverIP, ref int protocolversion, ref s
string result = ComTmp.readNextString(); //Get the Json data
if (result[0] == '{' && result.Contains("protocol\":") && result.Contains("name\":\""))
{
string[] tmp_ver = result.Split(new string[] { "protocol\":" }, StringSplitOptions.None);
string[] tmp_name = result.Split(new string[] { "name\":\"" }, StringSplitOptions.None);
string tmp_name = result.Split(new string[] { "name\":\"" }, StringSplitOptions.None)[1];
string tmp_ver = result.Split(new string[] { "protocol\":" }, StringSplitOptions.None)[1];

// Detecting Forge.
if (result.Contains("modinfo\":"))
{
tmp_name = "Forge " + result.Split(new string[] {"name\":\""}, StringSplitOptions.None)[1];
tmp_ver = "0.0";
}

if (tmp_ver.Length >= 2 && tmp_name.Length >= 2)
{
protocolversion = atoi(tmp_ver[1]);
version = tmp_name[1].Split('"')[0];
protocolversion = atoi(tmp_ver);
version = tmp_name.Split('"')[0];
Console.ForegroundColor = ConsoleColor.DarkGray;
//Console.WriteLine(result); //Debug: show the full Json string
Console.WriteLine("Server version : " + version + " (protocol v" + protocolversion + ").");
Expand Down