use of net.minecraft.client.multiplayer.ServerData in project Wurst-MC-1.9 by Wurst-Imperium.
the class ServerHook method updateLastServerFromServerlist.
public static void updateLastServerFromServerlist(IGuiListEntry entry, GuiMultiplayer guiMultiplayer) {
if (entry instanceof ServerListEntryNormal) {
currentServerIP = ((ServerListEntryNormal) entry).getServerData().serverIP;
if (!currentServerIP.contains(":"))
currentServerIP += ":25565";
lastServer = (ServerListEntryNormal) (guiMultiplayer.serverListSelector.getSelectedServer() < 0 ? null : guiMultiplayer.serverListSelector.getListEntry(guiMultiplayer.serverListSelector.getSelectedServer()));
} else if (entry instanceof ServerListEntryLanDetected) {
currentServerIP = ((ServerListEntryLanDetected) entry).getLanServer().getServerIpPort();
lastServer = new ServerListEntryNormal(guiMultiplayer, new ServerData("LAN-Server", currentServerIP, false));
}
}
use of net.minecraft.client.multiplayer.ServerData in project Wurst-MC-1.12 by Wurst-Imperium.
the class GuiCleanUp method actionPerformed.
@Override
protected void actionPerformed(GuiButton clickedButton) {
if (clickedButton.enabled)
if (clickedButton.id == 0)
mc.displayGuiScreen(prevScreen);
else if (clickedButton.id == 1) {
// Clean Up
WurstClient.INSTANCE.analytics.trackEvent("clean up", "start");
if (removeAll) {
prevScreen.savedServerList.clearServerList();
prevScreen.savedServerList.saveServerList();
prevScreen.serverListSelector.setSelectedSlotIndex(-1);
prevScreen.serverListSelector.updateOnlineServers(prevScreen.savedServerList);
mc.displayGuiScreen(prevScreen);
return;
}
for (int i = prevScreen.savedServerList.countServers() - 1; i >= 0; i--) {
ServerData server = prevScreen.savedServerList.getServerData(i);
if (WurstClient.INSTANCE.options.cleanupUnknown && server.serverMOTD.equals(TextFormatting.DARK_RED + "Can\'t resolve hostname") || WurstClient.INSTANCE.options.cleanupOutdated && !WMinecraft.PROTOCOLS.containsKey(server.version) || WurstClient.INSTANCE.options.cleanupFailed && server.pingToServer != -2L && server.pingToServer < 0L || WurstClient.INSTANCE.options.cleanupGriefMe && server.serverName.startsWith("Grief me")) {
prevScreen.savedServerList.removeServerData(i);
prevScreen.savedServerList.saveServerList();
prevScreen.serverListSelector.setSelectedSlotIndex(-1);
prevScreen.serverListSelector.updateOnlineServers(prevScreen.savedServerList);
}
}
if (WurstClient.INSTANCE.options.cleanupRename)
for (int i = 0; i < prevScreen.savedServerList.countServers(); i++) {
ServerData server = prevScreen.savedServerList.getServerData(i);
server.serverName = "Grief me #" + (i + 1);
prevScreen.savedServerList.saveServerList();
prevScreen.serverListSelector.setSelectedSlotIndex(-1);
prevScreen.serverListSelector.updateOnlineServers(prevScreen.savedServerList);
}
mc.displayGuiScreen(prevScreen);
} else if (clickedButton.id == 2) {
// Unknown host
WurstClient.INSTANCE.options.cleanupUnknown = !WurstClient.INSTANCE.options.cleanupUnknown;
clickedButton.displayString = "Unknown Hosts: " + removeOrKeep(WurstClient.INSTANCE.options.cleanupUnknown);
ConfigFiles.OPTIONS.save();
WurstClient.INSTANCE.analytics.trackEvent("clean up", "unknown host", removeOrKeep(WurstClient.INSTANCE.options.cleanupUnknown));
} else if (clickedButton.id == 3) {
// Outdated
WurstClient.INSTANCE.options.cleanupOutdated = !WurstClient.INSTANCE.options.cleanupOutdated;
clickedButton.displayString = "Outdated Servers: " + removeOrKeep(WurstClient.INSTANCE.options.cleanupOutdated);
ConfigFiles.OPTIONS.save();
WurstClient.INSTANCE.analytics.trackEvent("clean up", "outdated servers", removeOrKeep(WurstClient.INSTANCE.options.cleanupOutdated));
} else if (clickedButton.id == 4) {
// Failed ping
WurstClient.INSTANCE.options.cleanupFailed = !WurstClient.INSTANCE.options.cleanupFailed;
clickedButton.displayString = "Failed Ping: " + removeOrKeep(WurstClient.INSTANCE.options.cleanupFailed);
ConfigFiles.OPTIONS.save();
WurstClient.INSTANCE.analytics.trackEvent("clean up", "failed ping", removeOrKeep(WurstClient.INSTANCE.options.cleanupFailed));
} else if (clickedButton.id == 5) {
// Grief me
WurstClient.INSTANCE.options.cleanupGriefMe = !WurstClient.INSTANCE.options.cleanupGriefMe;
ConfigFiles.OPTIONS.save();
clickedButton.displayString = "\"Grief Me\" Servers: " + removeOrKeep(WurstClient.INSTANCE.options.cleanupGriefMe);
WurstClient.INSTANCE.analytics.trackEvent("clean up", "grief me", removeOrKeep(WurstClient.INSTANCE.options.cleanupGriefMe));
} else if (clickedButton.id == 6) {
// Remove
removeAll = !removeAll;
clickedButton.displayString = "�cRemove all Servers: " + yesOrNo(removeAll);
WurstClient.INSTANCE.analytics.trackEvent("clean up", "remove all servers", yesOrNo(removeAll));
} else if (clickedButton.id == 7) {
// Rename
WurstClient.INSTANCE.options.cleanupRename = !WurstClient.INSTANCE.options.cleanupRename;
clickedButton.displayString = "Rename all Servers: " + yesOrNo(WurstClient.INSTANCE.options.cleanupRename);
ConfigFiles.OPTIONS.save();
WurstClient.INSTANCE.analytics.trackEvent("clean up", "rename servers", yesOrNo(WurstClient.INSTANCE.options.cleanupRename));
}
}
use of net.minecraft.client.multiplayer.ServerData in project Wurst-MC-1.12 by Wurst-Imperium.
the class WurstServerPinger method ping.
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();
}
use of net.minecraft.client.multiplayer.ServerData in project Wurst-MC-1.12-OF by Wurst-Imperium.
the class ServerHook method getProtocolVersion.
public static int getProtocolVersion() {
if (WurstClient.INSTANCE.options.mc112x_compatibility == 2)
return 340;
else if (WurstClient.INSTANCE.options.mc112x_compatibility == 1)
return 338;
NavigableMap<Integer, String> protocols = WMinecraft.PROTOCOLS;
// use default if using Wurst-Bot
if (WurstBot.isEnabled())
return protocols.lastKey();
ServerData server = lastServer.getServerData();
// use default if ping failed
if (!server.pinged || server.pingToServer < 0)
return protocols.lastKey();
// use default if server protocol is not supported
if (!protocols.containsKey(server.version))
return protocols.lastKey();
// use server protocol
return server.version;
}
use of net.minecraft.client.multiplayer.ServerData in project Wurst-MC-1.12-OF by Wurst-Imperium.
the class ServerHook method updateLastServerFromServerlist.
public static void updateLastServerFromServerlist(IGuiListEntry entry, GuiMultiplayer guiMultiplayer) {
if (entry instanceof ServerListEntryNormal) {
currentServerIP = ((ServerListEntryNormal) entry).getServerData().serverIP;
if (!currentServerIP.contains(":"))
currentServerIP += ":25565";
lastServer = (ServerListEntryNormal) (guiMultiplayer.serverListSelector.getSelected() < 0 ? null : guiMultiplayer.serverListSelector.getListEntry(guiMultiplayer.serverListSelector.getSelected()));
} else if (entry instanceof ServerListEntryLanDetected) {
currentServerIP = ((ServerListEntryLanDetected) entry).getServerData().getServerIpPort();
lastServer = new ServerListEntryNormal(guiMultiplayer, new ServerData("LAN-Server", currentServerIP, false));
}
}
Aggregations