Search in sources :

Example 26 with ServerData

use of net.minecraft.client.multiplayer.ServerData in project Hyperium by HyperiumClient.

the class HyperiumServerList method saveSingleServer.

public static void saveSingleServer(ServerData serverData) {
    ServerList serverlist = new ServerList(Minecraft.getMinecraft());
    serverlist.loadServerList();
    for (int i = 0; i < serverlist.countServers(); ++i) {
        ServerData serverdata = serverlist.getServerData(i);
        if (serverdata.serverName.equals(serverData.serverName) && serverdata.serverIP.equals(serverData.serverIP)) {
            serverlist.func_147413_a(i, serverData);
            break;
        }
    }
    serverlist.saveServerList();
}
Also used : ServerData(net.minecraft.client.multiplayer.ServerData) ServerList(net.minecraft.client.multiplayer.ServerList)

Example 27 with ServerData

use of net.minecraft.client.multiplayer.ServerData in project Hyperium by HyperiumClient.

the class HyperiumServerList method saveServerList.

public void saveServerList(List<ServerData> servers, Minecraft mc) {
    try {
        NBTTagList nbttaglist = new NBTTagList();
        for (ServerData server : servers) {
            NBTTagCompound nbtCompound = server.getNBTCompound();
            nbttaglist.appendTag(nbtCompound);
        }
        NBTTagCompound nbttagcompound = new NBTTagCompound();
        nbttagcompound.setTag("servers", nbttaglist);
        CompressedStreamTools.safeWrite(nbttagcompound, new File(mc.mcDataDir, "servers.dat"));
    } catch (Exception exception) {
        Hyperium.LOGGER.error("Save server list error", exception);
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) ServerData(net.minecraft.client.multiplayer.ServerData) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) File(java.io.File)

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