Search in sources :

Example 1 with ServerInfo

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);
    }
}
Also used : ServerInfo(net.minecraft.client.network.ServerInfo) MinecraftServerAccess(net.pl3x.minimap.mixin.MinecraftServerAccess)

Example 2 with ServerInfo

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"));
}
Also used : Path(java.nio.file.Path) MServerInfo(mathax.client.utils.network.serverfinder.MServerInfo) ServerInfo(net.minecraft.client.network.ServerInfo) ServerList(net.minecraft.client.option.ServerList) IOException(java.io.IOException) IPAddress(mathax.client.utils.network.serverfinder.IPAddress)

Example 3 with ServerInfo

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;
    }
}
Also used : MServerInfo(mathax.client.utils.network.serverfinder.MServerInfo) ServerInfo(net.minecraft.client.network.ServerInfo)

Example 4 with ServerInfo

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);
}
Also used : ServerInfo(net.minecraft.client.network.ServerInfo) IOException(java.io.IOException)

Example 5 with ServerInfo

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);
}
Also used : MCVersion(com.seedfinding.mccore.version.MCVersion) ServerInfo(net.minecraft.client.network.ServerInfo)

Aggregations

ServerInfo (net.minecraft.client.network.ServerInfo)8 IOException (java.io.IOException)3 MServerInfo (mathax.client.utils.network.serverfinder.MServerInfo)2 MCVersion (com.seedfinding.mccore.version.MCVersion)1 BufferedWriter (java.io.BufferedWriter)1 File (java.io.File)1 FileWriter (java.io.FileWriter)1 Path (java.nio.file.Path)1 IPAddress (mathax.client.utils.network.serverfinder.IPAddress)1 ServerList (net.minecraft.client.option.ServerList)1 HandshakeC2SPacket (net.minecraft.network.packet.c2s.handshake.HandshakeC2SPacket)1 MinecraftServerAccess (net.pl3x.minimap.mixin.MinecraftServerAccess)1 BleachSubscribe (org.bleachhack.eventbus.BleachSubscribe)1