Search in sources :

Example 1 with ServerProcessMeta

use of de.dytanic.cloudnet.lib.server.ServerProcessMeta in project CloudNet by Dytanic.

the class PacketInAddServer method handleInput.

@Override
public void handleInput(Document data, PacketSender packetSender) {
    if (!(packetSender instanceof Wrapper))
        return;
    Wrapper cn = ((Wrapper) packetSender);
    ServerInfo nullServerInfo = data.getObject("serverInfo", new TypeToken<ServerInfo>() {
    }.getType());
    ServerProcessMeta serverProcessMeta = data.getObject("serverProcess", new TypeToken<ServerProcessMeta>() {
    }.getType());
    MinecraftServer minecraftServer = new MinecraftServer(serverProcessMeta, cn, CloudNet.getInstance().getServerGroups().get(nullServerInfo.getServiceId().getGroup()), nullServerInfo);
    cn.getServers().put(nullServerInfo.getServiceId().getServerId(), minecraftServer);
    cn.getWaitingServices().remove(minecraftServer.getServerId());
    {
        if (serverProcessMeta.isPriorityStop()) {
            ServerGroup serverGroup = CloudNet.getInstance().getServerGroups().get(serverProcessMeta.getServiceId().getGroup());
            if (serverGroup != null) {
                PriorityStopTask priorityStopTask = new PriorityStopTask(cn, minecraftServer, serverGroup.getPriorityService().getStopTimeInSeconds());
                ScheduledTask scheduledTask = CloudNet.getInstance().getSubScheduler().runTaskRepeatSync(priorityStopTask, 0, 50);
                priorityStopTask.setScheduledTask(scheduledTask);
            }
        }
    }
    CloudNet.getInstance().getNetworkManager().handleServerAdd(minecraftServer);
}
Also used : PriorityStopTask(de.dytanic.cloudnetcore.network.components.priority.PriorityStopTask) Wrapper(de.dytanic.cloudnetcore.network.components.Wrapper) ServerGroup(de.dytanic.cloudnet.lib.server.ServerGroup) ServerProcessMeta(de.dytanic.cloudnet.lib.server.ServerProcessMeta) ServerInfo(de.dytanic.cloudnet.lib.server.info.ServerInfo) TypeToken(com.google.gson.reflect.TypeToken) ScheduledTask(de.dytanic.cloudnet.lib.utility.threading.ScheduledTask) MinecraftServer(de.dytanic.cloudnetcore.network.components.MinecraftServer)

Example 2 with ServerProcessMeta

use of de.dytanic.cloudnet.lib.server.ServerProcessMeta in project CloudNet by Dytanic.

the class PacketInStartServer method handleInput.

@Override
public void handleInput(Document data, PacketSender packetSender) {
    ServerProcessMeta serverProcessMeta = data.getObject("serverProcess", new TypeToken<ServerProcessMeta>() {
    }.getType());
    if (!data.contains("async")) {
        System.out.println("Server process is now in queue [" + serverProcessMeta.getServiceId() + "]");
        CloudNetWrapper.getInstance().getServerProcessQueue().putProcess(serverProcessMeta);
    } else {
        CloudNetWrapper.getInstance().getServerProcessQueue().patchAsync(serverProcessMeta);
    }
}
Also used : ServerProcessMeta(de.dytanic.cloudnet.lib.server.ServerProcessMeta) TypeToken(com.google.gson.reflect.TypeToken)

Aggregations

TypeToken (com.google.gson.reflect.TypeToken)2 ServerProcessMeta (de.dytanic.cloudnet.lib.server.ServerProcessMeta)2 ServerGroup (de.dytanic.cloudnet.lib.server.ServerGroup)1 ServerInfo (de.dytanic.cloudnet.lib.server.info.ServerInfo)1 ScheduledTask (de.dytanic.cloudnet.lib.utility.threading.ScheduledTask)1 MinecraftServer (de.dytanic.cloudnetcore.network.components.MinecraftServer)1 Wrapper (de.dytanic.cloudnetcore.network.components.Wrapper)1 PriorityStopTask (de.dytanic.cloudnetcore.network.components.priority.PriorityStopTask)1