use of net.minecraft.client.multiplayer.ServerData in project Hyperium by HyperiumClient.
the class HyperiumServerList method loadServerList.
public void loadServerList(List<ServerData> servers, Minecraft mc) {
try {
servers.clear();
NBTTagCompound nbttagcompound = CompressedStreamTools.read(new File(mc.mcDataDir, "servers.dat"));
if (nbttagcompound == null)
return;
NBTTagList nbttaglist = nbttagcompound.getTagList("servers", 10);
int bound = nbttaglist.tagCount();
for (int i = 0; i < bound; i++) {
ServerData serverDataFromNBTCompound = ServerData.getServerDataFromNBTCompound(nbttaglist.getCompoundTagAt(i));
servers.add(serverDataFromNBTCompound);
}
} catch (Exception exception) {
Hyperium.LOGGER.error("Failed to load server list", exception);
}
}
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;
}
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);
}
}
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));
}
}
use of net.minecraft.client.multiplayer.ServerData in project Wurst-MC-1.12 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;
}
Aggregations