Search in sources :

Example 1 with Result

use of de.dytanic.cloudnet.lib.network.protocol.packet.result.Result in project CloudNet by Dytanic.

the class CloudAPI method getOnlinePlayers.

/**
 * Returns all OnlinePlayers on Network
 */
public Collection<CloudPlayer> getOnlinePlayers() {
    Result result = networkConnection.getPacketManager().sendQuery(new PacketAPIOutGetPlayers(), networkConnection);
    Collection<CloudPlayer> cloudPlayers = result.getResult().getObject("players", new TypeToken<Collection<CloudPlayer>>() {
    }.getType());
    if (cloudPlayers == null)
        return new ArrayList<>();
    for (CloudPlayer cloudPlayer : cloudPlayers) cloudPlayer.setPlayerExecutor(PlayerExecutorBridge.INSTANCE);
    return cloudPlayers;
}
Also used : TypeToken(com.google.gson.reflect.TypeToken) CloudPlayer(de.dytanic.cloudnet.lib.player.CloudPlayer) Result(de.dytanic.cloudnet.lib.network.protocol.packet.result.Result)

Example 2 with Result

use of de.dytanic.cloudnet.lib.network.protocol.packet.result.Result in project CloudNet by Dytanic.

the class CloudAPI method getOfflinePlayer.

/**
 * Returns a offline player which registerd or null
 *
 * @param name
 */
public OfflinePlayer getOfflinePlayer(String name) {
    CloudPlayer cloudPlayer = checkAndGet(name);
    if (cloudPlayer != null)
        return cloudPlayer;
    Result result = networkConnection.getPacketManager().sendQuery(new PacketAPIOutGetOfflinePlayer(name), networkConnection);
    return result.getResult().getObject("player", new TypeToken<OfflinePlayer>() {
    }.getType());
}
Also used : TypeToken(com.google.gson.reflect.TypeToken) CloudPlayer(de.dytanic.cloudnet.lib.player.CloudPlayer) Result(de.dytanic.cloudnet.lib.network.protocol.packet.result.Result)

Example 3 with Result

use of de.dytanic.cloudnet.lib.network.protocol.packet.result.Result in project CloudNet by Dytanic.

the class CloudAPI method getOnlinePlayer.

/**
 * Retuns a online CloudPlayer on network or null if the player isn't online
 */
public CloudPlayer getOnlinePlayer(UUID uniqueId) {
    CloudPlayer instance = checkAndGet(uniqueId);
    if (instance != null)
        return instance;
    Result result = networkConnection.getPacketManager().sendQuery(new PacketAPIOutGetPlayer(uniqueId), networkConnection);
    CloudPlayer cloudPlayer = result.getResult().getObject("player", CloudPlayer.TYPE);
    if (cloudPlayer == null)
        return null;
    cloudPlayer.setPlayerExecutor(PlayerExecutorBridge.INSTANCE);
    return cloudPlayer;
}
Also used : CloudPlayer(de.dytanic.cloudnet.lib.player.CloudPlayer) Result(de.dytanic.cloudnet.lib.network.protocol.packet.result.Result)

Example 4 with Result

use of de.dytanic.cloudnet.lib.network.protocol.packet.result.Result in project CloudNet by Dytanic.

the class DatabaseImpl method getDocument.

@Override
public Document getDocument(String name) {
    Result result = CloudAPI.getInstance().getNetworkConnection().getPacketManager().sendQuery(new PacketDBOutGetDocument(name, this.name), CloudAPI.getInstance().getNetworkConnection());
    Document document = result.getResult().getDocument("result");
    this.docs.put(document.getString(Database.UNIQUE_NAME_KEY), document);
    return document;
}
Also used : Document(de.dytanic.cloudnet.lib.utility.document.Document) Result(de.dytanic.cloudnet.lib.network.protocol.packet.result.Result)

Example 5 with Result

use of de.dytanic.cloudnet.lib.network.protocol.packet.result.Result in project CloudNet by Dytanic.

the class CloudAPI method getOfflinePlayer.

/**
 * Returns a offline player which registerd or null
 *
 * @param uniqueId
 */
public OfflinePlayer getOfflinePlayer(UUID uniqueId) {
    CloudPlayer cloudPlayer = checkAndGet(uniqueId);
    if (cloudPlayer != null)
        return cloudPlayer;
    Result result = networkConnection.getPacketManager().sendQuery(new PacketAPIOutGetOfflinePlayer(uniqueId), networkConnection);
    return result.getResult().getObject("player", new TypeToken<OfflinePlayer>() {
    }.getType());
}
Also used : TypeToken(com.google.gson.reflect.TypeToken) CloudPlayer(de.dytanic.cloudnet.lib.player.CloudPlayer) Result(de.dytanic.cloudnet.lib.network.protocol.packet.result.Result)

Aggregations

Result (de.dytanic.cloudnet.lib.network.protocol.packet.result.Result)8 CloudPlayer (de.dytanic.cloudnet.lib.player.CloudPlayer)4 TypeToken (com.google.gson.reflect.TypeToken)3 Document (de.dytanic.cloudnet.lib.utility.document.Document)2 Value (de.dytanic.cloudnet.lib.Value)1 Map (java.util.Map)1