use of de.dytanic.cloudnet.lib.utility.document.Document in project CloudNet by Dytanic.
the class CommandStatistic method onExecuteCommand.
@Override
public void onExecuteCommand(CommandSender sender, String[] args) {
Document document = StatisticManager.getInstance().getStatistics();
sender.sendMessage("CloudNet2 Statistics:", " ", "CloudStartups: " + StatisticManager.getInstance().getStatistics().getInt("cloudStartup"), "Cloud online time: " + TimeUnit.MILLISECONDS.toMinutes(document.getInt("cloudOnlineTime")) + "min", "Wrapper connections: " + document.getInt("wrapperConnections"), "Highest server online count: " + document.getInt("highestServerOnlineCount"), "Started servers: " + document.getLong("startedServers"), " ", "Player Statistics:", " ", "Registered: " + CloudNet.getInstance().getDbHandlers().getPlayerDatabase().getDatabase().size(), "Highest online count: " + document.getInt("highestPlayerOnline"), "Logins: " + document.getInt("playerLogin"), "Command executions: " + document.getInt("playerCommandExecutions"), " ");
}
use of de.dytanic.cloudnet.lib.utility.document.Document in project CloudNet by Dytanic.
the class CloudConfig method defaultInitUsers.
private void defaultInitUsers(ConsoleReader consoleReader) {
if (Files.exists(usersPath))
return;
String password = NetworkUtils.randomString(8);
System.out.println("\"admin\" Password: " + password);
System.out.println(NetworkUtils.SPACE_STRING);
new Document().append("users", Arrays.asList(new BasicUser("admin", password, Arrays.asList("*")))).saveAsConfig(usersPath);
}
use of de.dytanic.cloudnet.lib.utility.document.Document in project CloudNet by Dytanic.
the class CloudNet method startProxyAsync.
public void startProxyAsync(ProxyGroup proxyGroup) {
Wrapper wrapper = fetchPerformanceWrapper(proxyGroup.getMemory(), toWrapperInstances(proxyGroup.getWrapper()));
if (wrapper == null)
return;
Collection<Integer> collection = CollectionWrapper.getCollection(getProxys(), new Catcher<Integer, ProxyServer>() {
@Override
public Integer doCatch(ProxyServer key) {
return key.getProxyInfo().getPort();
}
});
collection.addAll(wrapper.getBinndedPorts());
int startport = proxyGroup.getStartPort();
while (collection.contains(startport)) {
startport++;
}
ProxyProcessMeta proxyProcessMeta = new ProxyProcessMeta(newServiceId(proxyGroup, wrapper), proxyGroup.getMemory(), startport, new String[] {}, null, Arrays.asList(), new Document());
wrapper.startProxyAsync(proxyProcessMeta);
}
use of de.dytanic.cloudnet.lib.utility.document.Document in project CloudNet by Dytanic.
the class CloudPriorityStartupHandler method onHandle.
@Override
public void onHandle(CloudNet cloudNet) {
double onlineCount = CloudNet.getInstance().getNetworkManager().newCloudNetwork().getOnlineCount();
for (ServerGroup group : CloudNet.getInstance().getServerGroups().values()) {
if (group.getPriorityService().getGlobal().getOnlineServers() == 0 || group.getPriorityService().getGlobal().getOnlineCount() == 0 || group.getGroupMode() == ServerGroupMode.STATIC || group.isMaintenance())
continue;
double priority = (group.getPriorityService().getGlobal().getOnlineServers() / ((double) group.getPriorityService().getGlobal().getOnlineCount())) * (onlineCount == 0 ? 1.0D : (onlineCount));
Collection<String> servers = CloudNet.getInstance().getServersAndWaitings(group.getName());
if (servers.size() == 0 && servers.size() < (priority <= 1 ? 1 : priority)) {
CloudNet.getInstance().startGameServer(group);
continue;
}
if (servers.size() < (priority <= 1 ? 1 : priority)) {
CloudNet.getInstance().startGameServer(group, new Document(), true);
}
}
}
use of de.dytanic.cloudnet.lib.utility.document.Document in project CloudNet by Dytanic.
the class PacketAPIInGetOfflinePlayer method handleInput.
@Override
public void handleInput(Document data, PacketSender packetSender) {
if (data.contains("uniqueId")) {
UUID uniqueId = data.getObject("uniqueId", UUID.class);
// use cache for offline player instance
OfflinePlayer offlinePlayer = CloudNet.getInstance().getNetworkManager().getOnlinePlayer(uniqueId);
if (offlinePlayer == null)
offlinePlayer = CloudNet.getInstance().getDbHandlers().getPlayerDatabase().getPlayer(uniqueId);
packetSender.sendPacket(getResult(new Document("player", offlinePlayer)));
} else {
String name = data.getString("name");
// use cache for offline player instance
OfflinePlayer offlinePlayer = CloudNet.getInstance().getNetworkManager().getPlayer(name);
if (offlinePlayer == null)
offlinePlayer = CloudNet.getInstance().getDbHandlers().getPlayerDatabase().getPlayer(CloudNet.getInstance().getDbHandlers().getNameToUUIDDatabase().get(name));
packetSender.sendPacket(getResult(new Document("player", offlinePlayer)));
}
}
Aggregations