Search in sources :

Example 1 with CommandCloudDeploy

use of de.dytanic.cloudnet.bridge.internal.command.bukkit.CommandCloudDeploy in project CloudNet by Dytanic.

the class BukkitBootstrap method enableTasks.

private void enableTasks() {
    Bukkit.getScheduler().runTask(this, new Runnable() {

        @Override
        public void run() {
            if (CloudServer.getInstance().getGroupData() != null) {
                if (CloudAPI.getInstance().getServerGroupData(CloudAPI.getInstance().getGroup()).getMode().equals(ServerGroupMode.LOBBY) || CloudAPI.getInstance().getServerGroupData(CloudAPI.getInstance().getGroup()).getMode().equals(ServerGroupMode.STATIC_LOBBY)) {
                    CommandCloudServer server = new CommandCloudServer();
                    getCommand("cloudserver").setExecutor(server);
                    getCommand("cloudserver").setPermission("cloudnet.command.cloudserver");
                    getCommand("cloudserver").setTabCompleter(server);
                }
                Bukkit.getPluginManager().callEvent(new BukkitCloudServerInitEvent(CloudServer.getInstance()));
                CloudServer.getInstance().update();
                if (CloudAPI.getInstance().getServerGroupData(CloudAPI.getInstance().getGroup()).getAdvancedServerConfig().isDisableAutoSavingForWorlds())
                    for (World world : Bukkit.getWorlds()) world.setAutoSave(false);
            }
            if (CloudServer.getInstance().getServerConfig().getProperties().contains(NetworkUtils.DEV_PROPERTY) && CloudAPI.getInstance().getModuleProperties().contains("devservice"))
                CloudServer.getInstance().registerCommand(new CommandCloudDeploy());
            if (CloudServer.getInstance().getGroupData() != null) {
                getServer().getScheduler().runTaskTimer(BukkitBootstrap.this, new Runnable() {

                    @Override
                    public void run() {
                        try {
                            ServerListPingEvent serverListPingEvent = new ServerListPingEvent(new InetSocketAddress("127.0.0.1", 53345).getAddress(), CloudServer.getInstance().getMotd(), Bukkit.getOnlinePlayers().size(), CloudServer.getInstance().getMaxPlayers());
                            Bukkit.getPluginManager().callEvent(serverListPingEvent);
                            if (!serverListPingEvent.getMotd().equals(CloudServer.getInstance().getMotd())) {
                                CloudServer.getInstance().setMotd(serverListPingEvent.getMotd());
                                if (serverListPingEvent.getMotd().toLowerCase().contains("running") || serverListPingEvent.getMotd().toLowerCase().contains("ingame")) {
                                    CloudServer.getInstance().changeToIngame();
                                }
                            }
                            if (serverListPingEvent.getMaxPlayers() != CloudServer.getInstance().getMaxPlayers()) {
                                CloudServer.getInstance().setMaxPlayers(serverListPingEvent.getMaxPlayers());
                            }
                        } catch (Exception ex) {
                        }
                    }
                }, 0, 5);
            }
            if (CloudAPI.getInstance().getPermissionPool() != null && (getServer().getPluginManager().isPluginEnabled("VaultAPI") || getServer().getPluginManager().isPluginEnabled("Vault")))
                try {
                    Class.forName("de.dytanic.cloudnet.bridge.vault.VaultInvoker").getMethod("invoke", new Class[0]).invoke(null, new Object[0]);
                } catch (IllegalAccessException | ClassNotFoundException | NoSuchMethodException | InvocationTargetException e) {
                    e.printStackTrace();
                }
        }
    });
}
Also used : BukkitCloudServerInitEvent(de.dytanic.cloudnet.bridge.event.bukkit.BukkitCloudServerInitEvent) InetSocketAddress(java.net.InetSocketAddress) World(org.bukkit.World) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvocationTargetException(java.lang.reflect.InvocationTargetException) CommandCloudDeploy(de.dytanic.cloudnet.bridge.internal.command.bukkit.CommandCloudDeploy) CommandCloudServer(de.dytanic.cloudnet.bridge.internal.command.bukkit.CommandCloudServer) ServerListPingEvent(org.bukkit.event.server.ServerListPingEvent)

Aggregations

BukkitCloudServerInitEvent (de.dytanic.cloudnet.bridge.event.bukkit.BukkitCloudServerInitEvent)1 CommandCloudDeploy (de.dytanic.cloudnet.bridge.internal.command.bukkit.CommandCloudDeploy)1 CommandCloudServer (de.dytanic.cloudnet.bridge.internal.command.bukkit.CommandCloudServer)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 InetSocketAddress (java.net.InetSocketAddress)1 World (org.bukkit.World)1 ServerListPingEvent (org.bukkit.event.server.ServerListPingEvent)1