Search in sources :

Example 1 with ServerData

use of net.minecraft.client.multiplayer.ServerData in project MinecraftForge by MinecraftForge.

the class FMLClientHandler method connectToServerAtStartup.

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);
}
Also used : GuiMainMenu(net.minecraft.client.gui.GuiMainMenu) ServerData(net.minecraft.client.multiplayer.ServerData) GuiConnecting(net.minecraft.client.multiplayer.GuiConnecting) ServerPinger(net.minecraft.client.network.ServerPinger) WrongMinecraftVersionException(net.minecraftforge.fml.common.WrongMinecraftVersionException) DuplicateModsFoundException(net.minecraftforge.fml.common.DuplicateModsFoundException) LoaderException(net.minecraftforge.fml.common.LoaderException) IOException(java.io.IOException) ModSortingException(net.minecraftforge.fml.common.toposort.ModSortingException) MissingModsException(net.minecraftforge.fml.common.MissingModsException) Java8VersionException(net.minecraftforge.fml.common.Java8VersionException)

Example 2 with ServerData

use of net.minecraft.client.multiplayer.ServerData in project Almura by AlmuraDev.

the class MixinGuiMultiplayer method onInitGui.

@Inject(method = "initGui", at = @At("RETURN"))
public void onInitGui(CallbackInfo ci) {
    boolean hasPublicData = false;
    boolean hasDevData = false;
    for (int i = 0; i < this.getServerList().countServers(); i++) {
        final ServerData data = this.getServerList().getServerData(i);
        if (data.serverName.equals(PUBLIC_SERVER_DATA.serverName) && data.serverIP.equals(PUBLIC_SERVER_DATA.serverIP)) {
            hasPublicData = true;
        } else if (data.serverName.equals(DEV_SERVER_DATA.serverName) && data.serverIP.equals(DEV_SERVER_DATA.serverIP)) {
            hasDevData = true;
        }
    }
    if (!hasPublicData) {
        this.getServerList().addServerData(PUBLIC_SERVER_DATA);
    }
    if (!hasDevData) {
        this.getServerList().addServerData(DEV_SERVER_DATA);
    }
    this.serverListSelector.updateOnlineServers(this.getServerList());
}
Also used : ServerData(net.minecraft.client.multiplayer.ServerData) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 3 with ServerData

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

the class ServerHook method getProtocolVersion.

public static int getProtocolVersion() {
    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 4 with ServerData

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

use of net.minecraft.client.multiplayer.ServerData in project Wurst-MC-1.12 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)27 File (java.io.File)8 IOException (java.io.IOException)7 Component (java.awt.Component)5 BufferedReader (java.io.BufferedReader)5 FileReader (java.io.FileReader)5 JDialog (javax.swing.JDialog)4 JFileChooser (javax.swing.JFileChooser)4 FileNameExtensionFilter (javax.swing.filechooser.FileNameExtensionFilter)4 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 InvokeEvent (cc.hyperium.event.InvokeEvent)1 JoinHypixelEvent (cc.hyperium.event.network.server.hypixel.JoinHypixelEvent)1 CreateServerButton (cc.hyperium.gui.util.CreateServerButton)1 IMixinGuiMultiplayer (cc.hyperium.mixinsimp.client.gui.IMixinGuiMultiplayer)1 ConnectingGui (com.almuradev.almura.feature.menu.main.ConnectingGui)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 NativeImage (com.mojang.blaze3d.platform.NativeImage)1