Search in sources :

Example 1 with PacketOutRemoveServer

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

the class GameServer method shutdown.

@Override
public boolean shutdown() {
    if (instance == null) {
        if (serverGroup.getGroupMode().equals(ServerGroupMode.DYNAMIC)) {
            try {
                FileUtils.deleteDirectory(dir.toFile());
            } catch (IOException e) {
            }
        }
        return true;
    }
    kill();
    if (CloudNetWrapper.getInstance().getWrapperConfig().isSavingRecords()) {
        try {
            FileCopy.copyFilesInDirectory(new File(path + "/logs"), new File("local/records/" + serverProcess.getMeta().getServiceId().toString()));
            new Document("meta", serverProcess.getMeta()).saveAsConfig(Paths.get("local/records/" + serverProcess.getMeta().getServiceId().toString() + "/metadata.json"));
        } catch (IOException e) {
        }
    }
    if (serverGroup.isMaintenance() && (CloudNetWrapper.getInstance().getWrapperConfig().isMaintenance_copy() && !serverGroup.getGroupMode().equals(ServerGroupMode.STATIC)))
        copy();
    if (!serverGroup.getGroupMode().equals(ServerGroupMode.STATIC) && !serverGroup.getGroupMode().equals(ServerGroupMode.STATIC_LOBBY))
        try {
            try {
                FileUtils.deleteDirectory(dir.toFile());
            } catch (Exception e) {
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    CloudNetWrapper.getInstance().getServers().remove(getServiceId().getServerId());
    CloudNetWrapper.getInstance().getNetworkConnection().sendPacket(new PacketOutRemoveServer(serverInfo));
    System.out.println("Server " + toString() + " was stopped");
    try {
        this.finalize();
    } catch (Throwable throwable) {
    }
    return true;
}
Also used : PacketOutRemoveServer(de.dytanic.cloudnetwrapper.network.packet.out.PacketOutRemoveServer) Document(de.dytanic.cloudnet.lib.utility.document.Document)

Aggregations

Document (de.dytanic.cloudnet.lib.utility.document.Document)1 PacketOutRemoveServer (de.dytanic.cloudnetwrapper.network.packet.out.PacketOutRemoveServer)1