}
queryResult = queryResult.replaceAll("\\^([0-9a-wyzA-WYZ]|x[0-9a-fA-F]{6})", "");
String[] masterServerPacketArray = queryResult.split("\u0000\u0000\u0000");
ServerInfo serverInfo = null;
if (masterServerPacketArray[1].length() > 0) {
serverInfo = new ServerInfo();
String plyrs = masterServerPacketArray[2].substring(1);
Pattern playerPattern = Pattern.compile("(.)(.)\\x00(.{2})\\x00\\x00([\\w\\s/\\x19-\\x2f\\x51-\\x5e\\x7d\\x7b@!:~_]+)\\x00?([\\w\\s/\\x19-\\x2f\\x51-\\x5e\\x7d\\x7b@!:~_]+|\\x00?)");
Matcher m = playerPattern.matcher(plyrs);
int plyrcnt = 0;
while (m.find()) {
plyrcnt++;
}
String playercount = String.valueOf(plyrcnt);
String tempGameVersion = Util.getPartGS2(masterServerPacketArray[1], "si_version");
tempGameVersion = tempGameVersion.replaceAll("[a-zA-Z]", "").trim();
String GameVersion = tempGameVersion.substring((tempGameVersion.indexOf(" ") + 2), tempGameVersion.indexOf(" ", tempGameVersion.indexOf(" ") + 3));// there's
// a whole lot of fluff in the version field.
serverInfo.setGame(Util.getPartGS2(masterServerPacketArray[1], "si_gameType"));
serverInfo.setIp(ipStr);
serverInfo.setPort(port + "");
serverInfo.setName(Util.getPartGS2(masterServerPacketArray[1], "si_name"));
serverInfo.setGameVersion(GameVersion);
serverInfo.setPlayerCount(playercount);
serverInfo.setMaxPlayers(Util.getPartGS2(masterServerPacketArray[1], "si_maxPlayers"));
serverInfo.setMap(Util.getPartGS2(masterServerPacketArray[1], "si_map"));
serverInfo.setFullResponse(queryResult);
}
return serverInfo;
}