Fix for previous commit

Fix code optimization from commit 8f77895
This commit is contained in:
ORelio 2014-02-14 17:30:44 +01:00
parent 8f77895084
commit 474aee3e55

View file

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