use of de.dytanic.cloudnet.bridge.internal.command.bukkit.CommandCloudServer 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();
}
}
});
}
Aggregations