Search in sources :

Example 1 with PacketOutRemoveProxy

use of de.dytanic.cloudnetwrapper.network.packet.out.PacketOutRemoveProxy in project CloudNet by Dytanic.

the class BungeeCord method shutdown.

@Override
public boolean shutdown() {
    if (instance == null) {
        if (proxyGroup.getProxyGroupMode().equals(ProxyGroupMode.DYNAMIC)) {
            try {
                Files.delete(Paths.get(path));
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return true;
    }
    if (instance.isAlive()) {
        executeCommand("end");
        NetworkUtils.sleepUninterruptedly(500);
    }
    instance.destroyForcibly();
    if (CloudNetWrapper.getInstance().getWrapperConfig().isSavingRecords()) {
        try {
            FileCopy.copyFilesInDirectory(new File(path), new File("local/records/" + proxyProcessMeta.getServiceId().toString()));
            new Document("meta", proxyProcessMeta).saveAsConfig(Paths.get("local/records/metadata.json"));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    if (proxyGroup.getProxyGroupMode().equals(ProxyGroupMode.DYNAMIC)) {
        try {
            FileUtils.deleteDirectory(new File(path));
        } catch (IOException e) {
        }
    }
    CloudNetWrapper.getInstance().getProxys().remove(getServiceId().getServerId());
    CloudNetWrapper.getInstance().getNetworkConnection().sendPacket(new PacketOutRemoveProxy(proxyInfo));
    System.out.println("Proxy " + toString() + " was stopped");
    try {
        this.finalize();
    } catch (Throwable throwable) {
    }
    return true;
}
Also used : PacketOutRemoveProxy(de.dytanic.cloudnetwrapper.network.packet.out.PacketOutRemoveProxy) IOException(java.io.IOException) Document(de.dytanic.cloudnet.lib.utility.document.Document) File(java.io.File)

Aggregations

Document (de.dytanic.cloudnet.lib.utility.document.Document)1 PacketOutRemoveProxy (de.dytanic.cloudnetwrapper.network.packet.out.PacketOutRemoveProxy)1 File (java.io.File)1 IOException (java.io.IOException)1