use of net.minecraft.client.network.ServerInfo in project MiniMap by pl3xgaming.
the class FileManager method start.
public void start() {
this.worldDirs.clear();
this.tilesDir = null;
if (MiniMap.getClient().isInSingleplayer()) {
MinecraftServerAccess server = (MinecraftServerAccess) MiniMap.getClient().getServer();
if (server == null) {
throw new RuntimeException("Cannot obtain single player world name");
}
this.tilesDir = resolve(this.configDir, "singleplayer/" + server.getSession().getDirectoryName());
} else {
ServerInfo server = MiniMap.getClient().getCurrentServerEntry();
if (server == null) {
throw new RuntimeException("Cannot obtain multiplayer server ip address");
}
this.tilesDir = resolve(this.configDir, "multiplayer/" + server.address);
}
}
use of net.minecraft.client.network.ServerInfo in project Client by MatHax.
the class ServerFinderScreen method saveToFile.
private void saveToFile() {
int newIPs = 0;
Path filePath = MatHax.GAME_FOLDER.toPath().resolve("servers.txt");
Set<IPAddress> hashedIPs = new HashSet<>();
if (Files.exists(filePath)) {
try {
List<String> ips = Files.readAllLines(filePath);
for (String ip : ips) {
IPAddress parsedIP = IPAddress.fromText(ip);
if (parsedIP != null)
hashedIPs.add(parsedIP);
}
} catch (IOException e) {
e.printStackTrace();
}
}
ServerList servers = multiplayerScreen.getServerList();
for (int i = 0; i < servers.size(); i++) {
ServerInfo info = servers.get(i);
IPAddress addr = IPAddress.fromText(info.address);
if (addr != null && hashedIPs.add(addr))
newIPs++;
}
StringBuilder fileOutput = new StringBuilder();
for (IPAddress ip : hashedIPs) {
String stringIP = ip.toString();
if (stringIP != null)
fileOutput.append(stringIP).append("\n");
}
try {
Files.writeString(filePath, fileOutput.toString());
} catch (IOException e) {
e.printStackTrace();
}
MatHax.LOG.info("Saved " + newIPs + " new IP" + (newIPs == 1 ? "" : "s"));
}
use of net.minecraft.client.network.ServerInfo in project Client by MatHax.
the class ServerFinderScreen method onServerDone.
@Override
public void onServerDone(ServerPinger pinger) {
if (state == ServerFinderState.Cancelled || pinger == null || pinger.getSearchNumber() != searchNumber)
return;
synchronized (serverFinderLock) {
checked++;
numActiveThreads--;
}
if (pinger.isWorking()) {
if (!isServerInList(pinger.getServerIP()) && filterPass(pinger.getServerInfo())) {
synchronized (serverFinderLock) {
working++;
multiplayerScreen.getServerList().add(new ServerInfo("Server discovery #" + working, pinger.getServerIP(), false));
multiplayerScreen.getServerList().saveFile();
((IMultiplayerScreen) multiplayerScreen).getServerListWidget().setSelected(null);
((IMultiplayerScreen) multiplayerScreen).getServerListWidget().setServers(multiplayerScreen.getServerList());
}
}
}
while (numActiveThreads < maxThreads && pingNewIP()) ;
synchronized (serverFinderLock) {
if (checked == targetChecked)
state = ServerFinderState.Done;
}
}
use of net.minecraft.client.network.ServerInfo in project Hypnotic-Client by Hypnotic-Development.
the class ServerFinder method buttonClicked.
@Override
public void buttonClicked(Button button) {
switch(button.getId()) {
case 1:
if (findModeIndex < findModes.length - 1) {
findModeIndex++;
} else {
findModeIndex = 0;
}
findMode = findModes[findModeIndex];
findModeButton.setText("Find Mode: " + findMode);
break;
case 2:
if (saveModeIndex < saveModes.length - 1) {
saveModeIndex++;
} else {
saveModeIndex = 0;
}
saveMode = saveModes[saveModeIndex];
saveModeButton.setText("Save Mode: " + saveMode);
break;
case 3:
if (mhBrandIndex < mhServerBrands.length - 1) {
mhBrandIndex++;
} else {
mhBrandIndex = 0;
}
mhServerBrand = mhServerBrands[mhBrandIndex];
mhBrandButton.setText("Minehut Server Brand: " + mhServerBrand);
break;
case 4:
if (mhGmIndex < mhGms.length - 1) {
mhGmIndex++;
} else {
mhGmIndex = 0;
}
mhGm = mhGms[mhGmIndex];
mhGmButton.setText("Minehut Server Gamemode: " + mhGm);
break;
case 0:
multiplayerScreen.getServerList().add(new ServerInfo((findMode.equalsIgnoreCase("Minehut") ? "Minehut server " : "Server finder "), "139.99.125.158:25569", false));
threads = 0;
try {
findServers();
} catch (Exception e) {
e.printStackTrace();
}
break;
}
super.buttonClicked(button);
}
use of net.minecraft.client.network.ServerInfo in project meteor-rejects by AntiCope.
the class Seeds method setSeed.
public void setSeed(String seed) {
if (mc.isIntegratedServerRunning())
return;
ServerInfo server = mc.getCurrentServerEntry();
MCVersion ver = null;
if (server != null)
ver = MCVersion.fromString(server.version.asString());
if (ver == null) {
String targetVer = "unknown";
if (server != null)
targetVer = server.version.asString();
sendInvalidVersionWarning(seed, targetVer);
ver = MCVersion.latest();
}
setSeed(seed, ver);
}
Aggregations