Search in sources :

Example 6 with Document

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

the class NameToUUIDDatabase method handleUpdate.

@Deprecated
public void handleUpdate(UpdateConfigurationDatabase updateConfigurationDatabase) {
    if (!updateConfigurationDatabase.get().contains("updated_database_from_2_1_Pv29")) {
        Collection<Document> documents = database.loadDocuments().getDocs();
        String name;
        for (Document document : documents) {
            name = document.getString(Database.UNIQUE_NAME_KEY);
            if (name != null)
                if (name.length() < 32) {
                    database.delete(document.getString(Database.UNIQUE_NAME_KEY));
                    database.insert(document.append(Database.UNIQUE_NAME_KEY, name.toLowerCase()));
                }
        }
        updateConfigurationDatabase.set(updateConfigurationDatabase.get().append("updated_database_from_2_1_Pv29", true));
        ((DatabaseImpl) database).save();
        ((DatabaseImpl) database).clear();
    }
}
Also used : DatabaseImpl(de.dytanic.cloudnet.database.DatabaseImpl) Document(de.dytanic.cloudnet.lib.utility.document.Document) DatabaseDocument(de.dytanic.cloudnet.lib.database.DatabaseDocument)

Example 7 with Document

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

the class PlayerDatabase method updatePlayer.

public PlayerDatabase updatePlayer(OfflinePlayer offlinePlayer) {
    Document document = database.getDocument(offlinePlayer.getUniqueId().toString());
    document.append("offlinePlayer", CloudPlayer.newOfflinePlayer(offlinePlayer));
    database.insert(document);
    return this;
}
Also used : Document(de.dytanic.cloudnet.lib.utility.document.Document) DatabaseDocument(de.dytanic.cloudnet.lib.database.DatabaseDocument)

Example 8 with Document

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

the class PlayerDatabase method updateName.

public PlayerDatabase updateName(UUID uuid, String name) {
    Document document = database.getDocument(uuid.toString());
    OfflinePlayer offlinePlayer = document.getObject("offlinePlayer", OfflinePlayer.TYPE);
    offlinePlayer.setName(name);
    database.insert(document);
    return this;
}
Also used : OfflinePlayer(de.dytanic.cloudnet.lib.player.OfflinePlayer) Document(de.dytanic.cloudnet.lib.utility.document.Document) DatabaseDocument(de.dytanic.cloudnet.lib.database.DatabaseDocument)

Example 9 with Document

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

the class StatisticManager method addPlayerLogin.

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

Example 10 with Document

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

the class StatisticManager method playerCommandExecutions.

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

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