public void connectToServerAtStartup(String host, int port) { setupServerList(); ServerPinger osp = new ServerPinger(); ServerData serverData = new ServerData("Command Line", host+":"+port,false); try { osp.ping(serverData); startupConnectionData.await(30, TimeUnit.SECONDS); } catch (Exception e) { showGuiScreen(new GuiConnecting(new GuiMainMenu(), client, host, port)); return; } connectToServer(new GuiMainMenu(), serverData); }
public void ping(final String ip, final int port) { server = new ServerData("", ip + ":" + port, false); new Thread("Wurst Server Connector #" + threadNumber.incrementAndGet()) { @Override public void run() { ServerPinger pinger = new ServerPinger(); try { logger.info("Pinging " + ip + ":" + port + "..."); pinger.ping(server); logger.info("Ping successful: " + ip + ":" + port); }catch(UnknownHostException e) { logger.info("Unknown host: " + ip + ":" + port); failed = true; }catch(Exception e2) { logger.info("Ping failed: " + ip + ":" + port); failed = true; } pinger.clearPendingNetworks(); done = true; } }.start(); }
private static GuiScreen connectToServerAtStartup(String host, int port) { if (startupConnectionDataField == null || serverDataTagField == null) return null; CountDownLatch startupConnectionData = ReflectionHelper.get(ObfuscatedField.FMLClientHandler_startupConnectionData, startupConnectionDataField, null); Map<ServerData, ExtendedServerListData> serverDataTag = ReflectionHelper.get(ObfuscatedField.FMLClientHandler_serverDataTag, serverDataTagField, FMLClientHandler.instance()); if (startupConnectionData == null || serverDataTag == null) return null; FMLClientHandler.instance().setupServerList(); ServerPinger osp = new ServerPinger(); ServerData serverData = new ServerData("Command Line", host+":"+port,false); try { osp.ping(serverData); startupConnectionData.await(30, TimeUnit.SECONDS); } catch (Exception e) { return GuiConnecting.newGuiConnecting(new GuiMainMenu(), Minecraft.getMinecraft(), host, port); } ExtendedServerListData extendedData = serverDataTag.get(serverData); if (extendedData != null && extendedData.isBlocked) return new GuiAccessDenied(new GuiMainMenu(), serverData); else return GuiConnecting.newGuiConnecting(new GuiMainMenu(), Minecraft.getMinecraft(), serverData); }
public ServerPinger getOldServerPinger() { return this.oldServerPinger; }