Search in sources :

Example 51 with Document

use of de.dytanic.cloudnet.lib.utility.document.Document in project CloudNet by Dytanic.

the class StatisticManager method addStartup.

public void addStartup() {
    if (!statistic)
        return;
    Document document = database.getDocument(NAME);
    if (!document.contains("cloudStartup")) {
        document.append("cloudStartup", 0L);
    }
    document.append("cloudStartup", document.getLong("cloudStartup") + 1L);
}
Also used : Document(de.dytanic.cloudnet.lib.utility.document.Document) DatabaseDocument(de.dytanic.cloudnet.lib.database.DatabaseDocument)

Example 52 with Document

use of de.dytanic.cloudnet.lib.utility.document.Document in project CloudNet by Dytanic.

the class StatisticManager method wrapperConnections.

public void wrapperConnections() {
    if (!statistic)
        return;
    Document document = database.getDocument(NAME);
    if (!document.contains("wrapperConnections")) {
        document.append("wrapperConnections", 0);
    }
    document.append("wrapperConnections", document.getLong("wrapperConnections") + 1L);
}
Also used : Document(de.dytanic.cloudnet.lib.utility.document.Document) DatabaseDocument(de.dytanic.cloudnet.lib.database.DatabaseDocument)

Example 53 with Document

use of de.dytanic.cloudnet.lib.utility.document.Document in project CloudNet by Dytanic.

the class PacketAPIInGetPlayers method handleInput.

@Override
public void handleInput(Document data, PacketSender packetSender) {
    Packet packet = getResult(new Document().append("players", CloudNet.getInstance().getNetworkManager().getOnlinePlayers().values()));
    packetSender.sendPacket(packet);
}
Also used : Packet(de.dytanic.cloudnet.lib.network.protocol.packet.Packet) Document(de.dytanic.cloudnet.lib.utility.document.Document)

Example 54 with Document

use of de.dytanic.cloudnet.lib.utility.document.Document in project CloudNet by Dytanic.

the class CommandInstallPlugin method onExecuteCommand.

@Override
public void onExecuteCommand(CommandSender sender, String[] args) {
    switch(args.length) {
        case 3:
            MinecraftServer minecraftServer = CloudNet.getInstance().getServer(args[0]);
            if (minecraftServer != null && minecraftServer.getChannel() != null) {
                minecraftServer.sendCustomMessage("cloudnet_internal", "install_plugin", new Document("name", args[1]).append("url", args[2]));
                sender.sendMessage("Plugin will install on " + args[0] + "...");
            } else {
                sender.sendMessage("Server doesn't exist");
            }
            break;
        default:
            sender.sendMessage("installplugin <server> <name> <url>");
            break;
    }
}
Also used : Document(de.dytanic.cloudnet.lib.utility.document.Document) MinecraftServer(de.dytanic.cloudnetcore.network.components.MinecraftServer)

Example 55 with Document

use of de.dytanic.cloudnet.lib.utility.document.Document in project CloudNet by Dytanic.

the class CloudPriorityGroupStartupHandler method onHandle.

@Override
public void onHandle(CloudNet cloudNet) {
    for (ServerGroup group : CloudNet.getInstance().getServerGroups().values()) {
        double onlineCount = CloudNet.getInstance().getOnlineCount(group.getName());
        if (group.getPriorityService().getGroup().getOnlineServers() == 0 || group.getPriorityService().getGlobal().getOnlineCount() == 0 || group.getGroupMode() == ServerGroupMode.STATIC || group.isMaintenance())
            continue;
        double priority = (group.getPriorityService().getGroup().getOnlineServers() / ((double) group.getPriorityService().getGroup().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)

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