Search in sources :

Example 1 with PacketOutUpdateWrapperInfo

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

the class CommandReload method onExecuteCommand.

@Override
public void onExecuteCommand(CommandSender sender, String[] args) {
    CloudNetWrapper.getInstance().getWrapperConfig().load();
    CloudNetWrapper.getInstance().setMaxMemory(CloudNetWrapper.getInstance().getWrapperConfig().getMaxMemory());
    CloudNetWrapper.getInstance().getNetworkConnection().sendPacket(new PacketOutUpdateWrapperInfo());
    System.out.println("Reloading was completed successfully");
}
Also used : PacketOutUpdateWrapperInfo(de.dytanic.cloudnetwrapper.network.packet.out.PacketOutUpdateWrapperInfo)

Example 2 with PacketOutUpdateWrapperInfo

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

the class CloudNetWrapper method onShutdownCentral.

@Override
public void onShutdownCentral() throws Exception {
    canDeployed = false;
    if (serverProcessQueue != null) {
        serverProcessQueue.getProxys().clear();
        serverProcessQueue.getServers().clear();
        serverProcessQueue.setRunning(false);
    }
    for (GameServer gameServer : servers.values()) gameServer.shutdown();
    for (BungeeCord gameServer : proxys.values()) gameServer.shutdown();
    proxyGroups.clear();
    serverGroups.clear();
    System.out.println("Wrapper try to connect to the CloudNet-Core");
    try {
        FileUtils.deleteDirectory(new File("temp"));
    } catch (Exception ex) {
    }
    new File("temp").mkdir();
    while (networkConnection.getChannel() == null) {
        networkConnection.tryConnect(optionSet.has("ssl"), new NetDispatcher(networkConnection, false), auth);
        if (networkConnection.getChannel() != null) {
            networkConnection.sendPacketSynchronized(new PacketOutUpdateWrapperInfo());
            break;
        }
        Thread.sleep(2000);
    }
    canDeployed = true;
    if (serverProcessQueue != null)
        serverProcessQueue.setRunning(true);
}
Also used : PacketOutUpdateWrapperInfo(de.dytanic.cloudnetwrapper.network.packet.out.PacketOutUpdateWrapperInfo) BungeeCord(de.dytanic.cloudnetwrapper.server.BungeeCord) NetDispatcher(de.dytanic.cloudnet.lib.network.NetDispatcher) CloudGameServer(de.dytanic.cloudnetwrapper.server.CloudGameServer) GameServer(de.dytanic.cloudnetwrapper.server.GameServer) File(java.io.File) IOException(java.io.IOException)

Example 3 with PacketOutUpdateWrapperInfo

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

the class CloudNetWrapper method bootstrap.

@Override
public boolean bootstrap() throws Exception {
    if (!optionSet.has("disable-autoupdate"))
        checkForUpdates();
    if (!optionSet.has("disallow_bukkit_download") && !Files.exists(Paths.get("local/spigot.jar")))
        new SetupSpigotVersion().run(cloudNetLogging.getReader());
    Thread thread = new Thread(scheduler);
    thread.setDaemon(true);
    thread.start();
    commandManager.registerCommand(new CommandHelp()).registerCommand(new CommandClear()).registerCommand(new CommandVersion()).registerCommand(new CommandClearCache()).registerCommand(new CommandStop()).registerCommand(new CommandReload());
    networkConnection.getPacketManager().registerHandler(PacketRC.CN_CORE, PacketInWrapperInfo.class);
    networkConnection.getPacketManager().registerHandler(PacketRC.CN_CORE + 1, PacketInStartProxy.class);
    networkConnection.getPacketManager().registerHandler(PacketRC.CN_CORE + 2, PacketInStopProxy.class);
    networkConnection.getPacketManager().registerHandler(PacketRC.CN_CORE + 3, PacketInStartServer.class);
    networkConnection.getPacketManager().registerHandler(PacketRC.CN_CORE + 4, PacketInStopServer.class);
    networkConnection.getPacketManager().registerHandler(PacketRC.CN_CORE + 5, PacketInCreateTemplate.class);
    networkConnection.getPacketManager().registerHandler(PacketRC.CN_CORE + 6, PacketInScreen.class);
    networkConnection.getPacketManager().registerHandler(PacketRC.CN_CORE + 7, PacketInExecuteServerCommand.class);
    networkConnection.getPacketManager().registerHandler(PacketRC.CN_CORE + 8, PacketInInstallUpdate.class);
    networkConnection.getPacketManager().registerHandler(PacketRC.CN_CORE + 9, PacketInExecuteCommand.class);
    networkConnection.getPacketManager().registerHandler(PacketRC.CN_CORE + 10, PacketInCopyServer.class);
    networkConnection.getPacketManager().registerHandler(PacketRC.CN_CORE + 11, PacketInOnlineServer.class);
    networkConnection.getPacketManager().registerHandler(PacketRC.CN_CORE + 12, PacketInUpdateWrapperProperties.class);
    networkConnection.getPacketManager().registerHandler(PacketRC.CN_CORE + 13, PacketInStartCloudServer.class);
    networkConnection.getPacketManager().registerHandler(PacketRC.CN_CORE + 14, PacketInCopyDirectory.class);
    networkConnection.getPacketManager().registerHandler(PacketRC.TEST + 1, PacketInTestResult.class);
    System.out.println("Trying to connect " + networkConnection.getConnectableAddress().getHostName() + ":" + networkConnection.getConnectableAddress().getPort());
    while (networkConnection.getConnectionTrys() < 5 && networkConnection.getChannel() == null) {
        networkConnection.tryConnect(optionSet.has("ssl"), new NetDispatcher(networkConnection, false), auth);
        if (networkConnection.getChannel() != null) {
            networkConnection.sendPacketSynchronized(new PacketOutUpdateWrapperInfo());
            break;
        }
        Thread.sleep(2000);
        if (networkConnection.getConnectionTrys() == 5)
            System.exit(0);
    }
    if (!Files.exists(Paths.get("local/server-icon.png")))
        FileCopy.insertData("files/server-icon.png", "local/server-icon.png");
    System.out.println("Starting process queue...");
    scheduler.runTaskRepeatSync(serverProcessQueue, 0, 20);
    // Server Handlers
    {
        networkConnection.sendPacket(new PacketOutSetReadyWrapper(true));
        IWrapperHandler iWrapperHandler = new StopTimeHandler();
        scheduler.runTaskRepeatSync(iWrapperHandler.toExecutor(), 0, iWrapperHandler.getTicks());
        scheduler.runTaskRepeatSync(new Runnable() {

            @Override
            public void run() {
                networkConnection.sendPacket(new PacketOutUpdateCPUUsage(getCpuUsage()));
            }
        }, 0, 200);
    }
    cloudNetLogging.getHandler().add(new ICloudLoggerHandler() {

        @Override
        public void handleConsole(String input) {
            if (networkConnection.isConnected())
                networkConnection.sendPacket(new PacketOutWrapperScreen(input));
        }
    });
    canDeployed = true;
    RUNNING = true;
    Runtime.getRuntime().addShutdownHook(new Thread(this));
    return true;
}
Also used : PacketOutUpdateWrapperInfo(de.dytanic.cloudnetwrapper.network.packet.out.PacketOutUpdateWrapperInfo) PacketOutSetReadyWrapper(de.dytanic.cloudnetwrapper.network.packet.out.PacketOutSetReadyWrapper) StopTimeHandler(de.dytanic.cloudnetwrapper.handlers.StopTimeHandler) NetDispatcher(de.dytanic.cloudnet.lib.network.NetDispatcher) PacketOutUpdateCPUUsage(de.dytanic.cloudnetwrapper.network.packet.out.PacketOutUpdateCPUUsage) ICloudLoggerHandler(de.dytanic.cloudnet.logging.handler.ICloudLoggerHandler) IWrapperHandler(de.dytanic.cloudnetwrapper.handlers.IWrapperHandler) SetupSpigotVersion(de.dytanic.cloudnetwrapper.setup.SetupSpigotVersion) PacketOutWrapperScreen(de.dytanic.cloudnetwrapper.network.packet.out.PacketOutWrapperScreen)

Aggregations

PacketOutUpdateWrapperInfo (de.dytanic.cloudnetwrapper.network.packet.out.PacketOutUpdateWrapperInfo)3 NetDispatcher (de.dytanic.cloudnet.lib.network.NetDispatcher)2 ICloudLoggerHandler (de.dytanic.cloudnet.logging.handler.ICloudLoggerHandler)1 IWrapperHandler (de.dytanic.cloudnetwrapper.handlers.IWrapperHandler)1 StopTimeHandler (de.dytanic.cloudnetwrapper.handlers.StopTimeHandler)1 PacketOutSetReadyWrapper (de.dytanic.cloudnetwrapper.network.packet.out.PacketOutSetReadyWrapper)1 PacketOutUpdateCPUUsage (de.dytanic.cloudnetwrapper.network.packet.out.PacketOutUpdateCPUUsage)1 PacketOutWrapperScreen (de.dytanic.cloudnetwrapper.network.packet.out.PacketOutWrapperScreen)1 BungeeCord (de.dytanic.cloudnetwrapper.server.BungeeCord)1 CloudGameServer (de.dytanic.cloudnetwrapper.server.CloudGameServer)1 GameServer (de.dytanic.cloudnetwrapper.server.GameServer)1 SetupSpigotVersion (de.dytanic.cloudnetwrapper.setup.SetupSpigotVersion)1 File (java.io.File)1 IOException (java.io.IOException)1