Search in sources :

Example 1 with MasterTemplateDeploy

use of de.dytanic.cloudnetwrapper.util.MasterTemplateDeploy in project CloudNet by Dytanic.

the class CloudGameServer method shutdown.

@Override
public boolean shutdown() {
    if (instance == null) {
        try {
            FileUtils.deleteDirectory(dir.toFile());
        } catch (IOException e) {
        }
        return true;
    }
    if (instance.isAlive()) {
        executeCommand("stop");
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
        }
    }
    instance.destroyForcibly();
    try {
        Files.deleteIfExists(Paths.get(path + "/plugins/CloudNetAPI.jar"));
    } catch (IOException e) {
    }
    if (CloudNetWrapper.getInstance().isCanDeployed()) {
        MasterTemplateDeploy masterTemplateDeploy = new MasterTemplateDeploy(path, new ConnectableAddress(CloudNetWrapper.getInstance().getWrapperConfig().getCloudnetHost(), CloudNetWrapper.getInstance().getWrapperConfig().getWebPort()), CloudNetWrapper.getInstance().getSimpledUser(), CloudNetWrapper.getInstance().getOptionSet().has("ssl"), cloudServerMeta.getTemplate(), null, cloudServerMeta.getTemplateName());
        try {
            masterTemplateDeploy.deploy();
        } catch (Exception e) {
        }
    }
    try {
        FileUtils.deleteDirectory(new File(path));
    } catch (IOException e) {
    }
    CloudNetWrapper.getInstance().getCloudservers().remove(getServiceId().getServerId());
    CloudNetWrapper.getInstance().getNetworkConnection().sendPacket(new PacketOutRemoveCloudServer(serverInfo));
    System.out.println("Server " + toString() + " was stopped");
    try {
        this.finalize();
    } catch (Throwable throwable) {
    }
    return true;
}
Also used : ConnectableAddress(de.dytanic.cloudnet.lib.ConnectableAddress) PacketOutRemoveCloudServer(de.dytanic.cloudnetwrapper.network.packet.out.PacketOutRemoveCloudServer) ZipFile(java.util.zip.ZipFile) MasterTemplateDeploy(de.dytanic.cloudnetwrapper.util.MasterTemplateDeploy)

Aggregations

ConnectableAddress (de.dytanic.cloudnet.lib.ConnectableAddress)1 PacketOutRemoveCloudServer (de.dytanic.cloudnetwrapper.network.packet.out.PacketOutRemoveCloudServer)1 MasterTemplateDeploy (de.dytanic.cloudnetwrapper.util.MasterTemplateDeploy)1 ZipFile (java.util.zip.ZipFile)1