Search in sources :

Example 16 with ServerData

use of net.minecraft.client.multiplayer.ServerData in project Wurst-MC-1.12-OF by Wurst-Imperium.

the class ServerHook method importServers.

public static void importServers(GuiMultiplayer guiMultiplayer) {
    JFileChooser fileChooser = new JFileChooser(WurstFolders.SERVERLISTS.toFile()) {

        @Override
        protected JDialog createDialog(Component parent) throws HeadlessException {
            JDialog dialog = super.createDialog(parent);
            dialog.setAlwaysOnTop(true);
            return dialog;
        }
    };
    fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    fileChooser.setAcceptAllFileFilterUsed(false);
    fileChooser.addChoosableFileFilter(new FileNameExtensionFilter("TXT files", "txt"));
    int action = fileChooser.showOpenDialog(FrameHook.getFrame());
    if (action == JFileChooser.APPROVE_OPTION)
        try {
            File file = fileChooser.getSelectedFile();
            BufferedReader load = new BufferedReader(new FileReader(file));
            int i = 0;
            for (String line = ""; (line = load.readLine()) != null; ) {
                i++;
                guiMultiplayer.savedServerList.addServerData(new ServerData("Grief me #" + i, line, false));
                guiMultiplayer.savedServerList.saveServerList();
                guiMultiplayer.serverListSelector.setSelectedSlotIndex(-1);
                guiMultiplayer.serverListSelector.updateOnlineServers(guiMultiplayer.savedServerList);
            }
            load.close();
            guiMultiplayer.refreshServerList();
        } catch (IOException e) {
            e.printStackTrace();
            MiscUtils.simpleError(e, fileChooser);
        }
}
Also used : JFileChooser(javax.swing.JFileChooser) BufferedReader(java.io.BufferedReader) ServerData(net.minecraft.client.multiplayer.ServerData) FileReader(java.io.FileReader) IOException(java.io.IOException) Component(java.awt.Component) FileNameExtensionFilter(javax.swing.filechooser.FileNameExtensionFilter) File(java.io.File) JDialog(javax.swing.JDialog)

Example 17 with ServerData

use of net.minecraft.client.multiplayer.ServerData in project Wurst-MC-1.10 by Wurst-Imperium.

the class ServerHook method importServers.

public static void importServers(GuiMultiplayer guiMultiplayer) {
    JFileChooser fileChooser = new JFileChooser(WurstFolders.SERVERLISTS.toFile()) {

        @Override
        protected JDialog createDialog(Component parent) throws HeadlessException {
            JDialog dialog = super.createDialog(parent);
            dialog.setAlwaysOnTop(true);
            return dialog;
        }
    };
    fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    fileChooser.setAcceptAllFileFilterUsed(false);
    fileChooser.addChoosableFileFilter(new FileNameExtensionFilter("TXT files", "txt"));
    int action = fileChooser.showOpenDialog(FrameHook.getFrame());
    if (action == JFileChooser.APPROVE_OPTION)
        try {
            File file = fileChooser.getSelectedFile();
            BufferedReader load = new BufferedReader(new FileReader(file));
            int i = 0;
            for (String line = ""; (line = load.readLine()) != null; ) {
                i++;
                guiMultiplayer.savedServerList.addServerData(new ServerData("Grief me #" + i, line, false));
                guiMultiplayer.savedServerList.saveServerList();
                guiMultiplayer.serverListSelector.setSelectedSlotIndex(-1);
                guiMultiplayer.serverListSelector.updateOnlineServers(guiMultiplayer.savedServerList);
            }
            load.close();
            guiMultiplayer.refreshServerList();
        } catch (IOException e) {
            e.printStackTrace();
            MiscUtils.simpleError(e, fileChooser);
        }
}
Also used : JFileChooser(javax.swing.JFileChooser) BufferedReader(java.io.BufferedReader) ServerData(net.minecraft.client.multiplayer.ServerData) FileReader(java.io.FileReader) IOException(java.io.IOException) Component(java.awt.Component) FileNameExtensionFilter(javax.swing.filechooser.FileNameExtensionFilter) File(java.io.File) JDialog(javax.swing.JDialog)

Example 18 with ServerData

use of net.minecraft.client.multiplayer.ServerData in project Wurst-MC-1.10 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).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 19 with ServerData

use of net.minecraft.client.multiplayer.ServerData in project Wurst-MC-1.11 by Wurst-Imperium.

the class ServerHook method importServers.

public static void importServers(GuiMultiplayer guiMultiplayer) {
    JFileChooser fileChooser = new JFileChooser(WurstFolders.SERVERLISTS.toFile()) {

        @Override
        protected JDialog createDialog(Component parent) throws HeadlessException {
            JDialog dialog = super.createDialog(parent);
            dialog.setAlwaysOnTop(true);
            return dialog;
        }
    };
    fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    fileChooser.setAcceptAllFileFilterUsed(false);
    fileChooser.addChoosableFileFilter(new FileNameExtensionFilter("TXT files", "txt"));
    int action = fileChooser.showOpenDialog(FrameHook.getFrame());
    if (action == JFileChooser.APPROVE_OPTION)
        try {
            File file = fileChooser.getSelectedFile();
            BufferedReader load = new BufferedReader(new FileReader(file));
            int i = 0;
            for (String line = ""; (line = load.readLine()) != null; ) {
                i++;
                guiMultiplayer.savedServerList.addServerData(new ServerData("Grief me #" + i, line, false));
                guiMultiplayer.savedServerList.saveServerList();
                guiMultiplayer.serverListSelector.setSelectedSlotIndex(-1);
                guiMultiplayer.serverListSelector.updateOnlineServers(guiMultiplayer.savedServerList);
            }
            load.close();
            guiMultiplayer.refreshServerList();
        } catch (IOException e) {
            e.printStackTrace();
            MiscUtils.simpleError(e, fileChooser);
        }
}
Also used : JFileChooser(javax.swing.JFileChooser) BufferedReader(java.io.BufferedReader) ServerData(net.minecraft.client.multiplayer.ServerData) FileReader(java.io.FileReader) IOException(java.io.IOException) Component(java.awt.Component) FileNameExtensionFilter(javax.swing.filechooser.FileNameExtensionFilter) File(java.io.File) JDialog(javax.swing.JDialog)

Example 20 with ServerData

use of net.minecraft.client.multiplayer.ServerData in project Wurst-MC-1.11 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