Detect Forge (which still not supported)

Code Optimisation, Detect Forge server
Changes imported from pull request #35
This commit is contained in:
ORelio 2014-02-14 14:59:27 +01:00
parent eef5e92af5
commit 8f77895084

View file

@ -396,12 +396,20 @@ namespace MinecraftClient
string result = ComTmp.readNextString(); //Get the Json data string result = ComTmp.readNextString(); //Get the Json data
if (result[0] == '{' && result.Contains("protocol\":") && result.Contains("name\":\"")) if (result[0] == '{' && result.Contains("protocol\":") && result.Contains("name\":\""))
{ {
string[] tmp_ver = result.Split(new string[] { "protocol\":" }, StringSplitOptions.None); string tmp_ver = result.Split(new string[] { "protocol\":" }, StringSplitOptions.None)[1];
string[] tmp_name = result.Split(new string[] { "name\":\"" }, StringSplitOptions.None); string tmp_name = result.Split(new string[] { "name\":\"" }, StringSplitOptions.None)[1];
//Detecting Forge (which is not supported)
if (result.Contains("modinfo\":"))
{
tmp_name += "Forge ";
tmp_ver = "0";
}
if (tmp_ver.Length >= 2 && tmp_name.Length >= 2) if (tmp_ver.Length >= 2 && tmp_name.Length >= 2)
{ {
protocolversion = atoi(tmp_ver[1]); protocolversion = atoi(tmp_ver);
version = tmp_name[1].Split('"')[0]; version = tmp_name.Split('"')[0];
Console.ForegroundColor = ConsoleColor.DarkGray; Console.ForegroundColor = ConsoleColor.DarkGray;
//Console.WriteLine(result); //Debug: show the full Json string //Console.WriteLine(result); //Debug: show the full Json string
Console.WriteLine("Server version : " + version + " (protocol v" + protocolversion + ")."); Console.WriteLine("Server version : " + version + " (protocol v" + protocolversion + ").");