Search in sources :

Example 1 with Document

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"), " ");
}
Also used : Document(de.dytanic.cloudnet.lib.utility.document.Document)

Example 2 with Document

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);
}
Also used : BasicUser(de.dytanic.cloudnet.lib.user.BasicUser) Document(de.dytanic.cloudnet.lib.utility.document.Document)

Example 3 with Document

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);
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) LocalCloudWrapper(de.dytanic.cloudnetcore.setup.LocalCloudWrapper) Document(de.dytanic.cloudnet.lib.utility.document.Document)

Example 4 with Document

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);
        }
    }
}
Also used : ServerGroup(de.dytanic.cloudnet.lib.server.ServerGroup) Document(de.dytanic.cloudnet.lib.utility.document.Document)

Example 5 with Document

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)));
    }
}
Also used : OfflinePlayer(de.dytanic.cloudnet.lib.player.OfflinePlayer) UUID(java.util.UUID) Document(de.dytanic.cloudnet.lib.utility.document.Document)

Aggregations

Document (de.dytanic.cloudnet.lib.utility.document.Document)69 DatabaseDocument (de.dytanic.cloudnet.lib.database.DatabaseDocument)26 TypeToken (com.google.gson.reflect.TypeToken)7 ArrayList (java.util.ArrayList)7 File (java.io.File)6 UUID (java.util.UUID)6 OfflinePlayer (de.dytanic.cloudnet.lib.player.OfflinePlayer)5 ServerGroup (de.dytanic.cloudnet.lib.server.ServerGroup)5 ServerConfig (de.dytanic.cloudnet.lib.server.ServerConfig)4 ServerInfo (de.dytanic.cloudnet.lib.server.info.ServerInfo)4 HttpURLConnection (java.net.HttpURLConnection)4 URL (java.net.URL)4 ConnectableAddress (de.dytanic.cloudnet.lib.ConnectableAddress)3 CloudPlayer (de.dytanic.cloudnet.lib.player.CloudPlayer)3 Template (de.dytanic.cloudnet.lib.server.template.Template)3 ServerInstallablePlugin (de.dytanic.cloudnet.lib.service.plugin.ServerInstallablePlugin)3 SimpledUser (de.dytanic.cloudnet.lib.user.SimpledUser)3 Acceptable (de.dytanic.cloudnet.lib.utility.Acceptable)3 MinecraftServer (de.dytanic.cloudnetcore.network.components.MinecraftServer)3 IOException (java.io.IOException)3