Search in sources :

Example 11 with ServerData

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));
    }
}
Also used : ServerListEntryLanDetected(net.minecraft.client.gui.ServerListEntryLanDetected) ServerData(net.minecraft.client.multiplayer.ServerData) ServerListEntryNormal(net.minecraft.client.gui.ServerListEntryNormal)

Example 12 with ServerData

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));
        }
}
Also used : ServerData(net.minecraft.client.multiplayer.ServerData)

Example 13 with ServerData

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();
}
Also used : UnknownHostException(java.net.UnknownHostException) ServerData(net.minecraft.client.multiplayer.ServerData) ServerPinger(net.minecraft.client.network.ServerPinger) UnknownHostException(java.net.UnknownHostException)

Example 14 with ServerData

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;
}
Also used : ServerData(net.minecraft.client.multiplayer.ServerData)

Example 15 with ServerData

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));
    }
}
Also used : ServerListEntryLanDetected(net.minecraft.client.gui.ServerListEntryLanDetected) ServerData(net.minecraft.client.multiplayer.ServerData) ServerListEntryNormal(net.minecraft.client.gui.ServerListEntryNormal)

Aggregations

ServerData (net.minecraft.client.multiplayer.ServerData)20 IOException (java.io.IOException)7 File (java.io.File)6 Component (java.awt.Component)5 BufferedReader (java.io.BufferedReader)5 FileReader (java.io.FileReader)5 JDialog (javax.swing.JDialog)5 JFileChooser (javax.swing.JFileChooser)5 FileNameExtensionFilter (javax.swing.filechooser.FileNameExtensionFilter)5 ServerListEntryLanDetected (net.minecraft.client.gui.ServerListEntryLanDetected)4 ServerListEntryNormal (net.minecraft.client.gui.ServerListEntryNormal)4 Minecraft (net.minecraft.client.Minecraft)3 GuiConnecting (net.minecraft.client.multiplayer.GuiConnecting)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 NativeImage (com.mojang.blaze3d.platform.NativeImage)1 Window (com.mojang.blaze3d.platform.Window)1 RenderSystem (com.mojang.blaze3d.systems.RenderSystem)1 com.mojang.blaze3d.vertex (com.mojang.blaze3d.vertex)1 Either (com.mojang.datafixers.util.Either)1 Matrix3f (com.mojang.math.Matrix3f)1