use of de.dytanic.cloudnetcore.api.event.network.CloudInitEvent in project CloudNet by Dytanic.
the class CloudNet method bootstrap.
@Override
public boolean bootstrap() throws Exception {
if (!optionSet.has("disable-autoupdate"))
checkForUpdates();
dbHandlers = new DatabaseBasicHandlers(databaseManager);
dbHandlers.getStatisticManager().addStartup();
this.moduleManager.setDisabledModuleList(config.getDisabledModules());
if (!optionSet.has("disable-modules")) {
System.out.println("Loading Modules...");
moduleManager.loadModules();
}
for (WrapperMeta wrapperMeta : config.getWrappers()) {
System.out.println("Loading Wrapper " + wrapperMeta.getId() + " @ " + wrapperMeta.getHostName());
this.wrappers.put(wrapperMeta.getId(), new Wrapper(wrapperMeta));
}
// Packet Init
this.users = config.getUsers();
// Groups Loading
NetworkUtils.addAll(this.serverGroups, config.getServerGroups(), new Acceptable<ServerGroup>() {
@Override
public boolean isAccepted(ServerGroup value) {
System.out.println("Loading ServerGroup: " + value.getName());
setupGroup(value);
return true;
}
});
NetworkUtils.addAll(this.proxyGroups, config.getProxyGroups(), new Acceptable<ProxyGroup>() {
@Override
public boolean isAccepted(ProxyGroup value) {
System.out.println("Loading ProxyGroup: " + value.getName());
setupProxy(value);
return true;
}
});
webServer = new WebServer(optionSet.has("ssl"), config.getWebServerConfig().getAddress(), config.getWebServerConfig().getPort());
// CommandManager Appending
this.initialCommands();
this.initWebHandlers();
this.initPacketHandlers();
// Scheduler Startup
{
Thread thread = new Thread(scheduler);
thread.setDaemon(true);
thread.start();
}
{
Thread thread = new Thread(subScheduler);
thread.setDaemon(true);
thread.start();
}
for (ConnectableAddress connectableAddress : config.getAddresses()) {
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
new CloudNetServer(optionSet, connectableAddress);
}
});
thread.setDaemon(true);
thread.start();
}
webServer.bind();
RUNNING = true;
Runtime.getRuntime().addShutdownHook(new Thread(this));
/*==================================*/
{
if (!optionSet.has("onlyConsole")) {
CloudStartupHandler cloudStartupHandler = new CloudStartupHandler();
CloudPriorityStartupHandler cloudPriorityStartupHandler = new CloudPriorityStartupHandler();
CloudPriorityGroupStartupHandler cloudPriorityGroupStartupHandler = new CloudPriorityGroupStartupHandler();
CloudPlayerRemoverHandler cloudPlayerRemoverHandler = new CloudPlayerRemoverHandler();
scheduler.runTaskRepeatSync(cloudStartupHandler, 0, cloudStartupHandler.getTicks());
scheduler.runTaskRepeatSync(cloudPriorityGroupStartupHandler, 0, cloudPriorityGroupStartupHandler.getTicks());
scheduler.runTaskRepeatSync(cloudPriorityStartupHandler, 0, cloudPriorityStartupHandler.getTicks());
scheduler.runTaskRepeatSync(cloudPlayerRemoverHandler, 0, cloudPlayerRemoverHandler.getTicks());
}
CloudStopCheckHandler cloudStopCheck = new CloudStopCheckHandler();
scheduler.runTaskRepeatSync(cloudStopCheck, 0, cloudStopCheck.getTicks());
scheduler.runTaskRepeatSync(serverLogManager, 0, 2000);
scheduler.runTaskRepeatSync(new Runnable() {
@Override
public void run() {
for (CloudPlayer cloudPlayer : networkManager.getWaitingPlayers().values()) {
if ((cloudPlayer.getLoginTimeStamp().getTime() + 10000L) < System.currentTimeMillis()) {
networkManager.getWaitingPlayers().remove(cloudPlayer.getUniqueId());
}
}
}
}, 0, 100);
}
if (!optionSet.has("disable-modules"))
System.out.println("Enabling Modules...");
moduleManager.enableModules();
// Event Init
eventManager.callEvent(new CloudInitEvent());
new LocalCloudWrapper().run(optionSet);
return true;
}
Aggregations