Search in sources :

Example 1 with PacketOutUpdateOfflinePlayer

use of de.dytanic.cloudnetcore.network.packet.out.PacketOutUpdateOfflinePlayer in project CloudNet by Dytanic.

the class PacketInUpdatePlayer method handleInput.

@Override
public void handleInput(Document data, PacketSender packetSender) {
    OfflinePlayer offlinePlayer = data.getObject("player", new TypeToken<OfflinePlayer>() {
    }.getType());
    CloudNet.getInstance().getDbHandlers().getPlayerDatabase().updatePlayer(offlinePlayer);
    if (CloudNet.getInstance().getNetworkManager().getOnlinePlayers().containsKey(offlinePlayer.getUniqueId())) {
        CloudPlayer cloudPlayer = CloudNet.getInstance().getNetworkManager().getOnlinePlayers().get(offlinePlayer.getUniqueId());
        cloudPlayer.setMetaData(offlinePlayer.getMetaData());
        cloudPlayer.setPermissionEntity(offlinePlayer.getPermissionEntity());
        CloudNet.getInstance().getNetworkManager().handlePlayerUpdate(cloudPlayer);
    } else
        CloudNet.getInstance().getNetworkManager().sendAllUpdate(new PacketOutUpdateOfflinePlayer(offlinePlayer));
}
Also used : TypeToken(com.google.gson.reflect.TypeToken) CloudPlayer(de.dytanic.cloudnet.lib.player.CloudPlayer) PacketOutUpdateOfflinePlayer(de.dytanic.cloudnetcore.network.packet.out.PacketOutUpdateOfflinePlayer) OfflinePlayer(de.dytanic.cloudnet.lib.player.OfflinePlayer) PacketOutUpdateOfflinePlayer(de.dytanic.cloudnetcore.network.packet.out.PacketOutUpdateOfflinePlayer)

Example 2 with PacketOutUpdateOfflinePlayer

use of de.dytanic.cloudnetcore.network.packet.out.PacketOutUpdateOfflinePlayer in project CloudNet by Dytanic.

the class CommandPermissions method updatePlayer.

private void updatePlayer(OfflinePlayer offlinePlayer) {
    CloudNet.getInstance().getDbHandlers().getPlayerDatabase().updatePlayer(offlinePlayer);
    if (CloudNet.getInstance().getNetworkManager().getOnlinePlayers().containsKey(offlinePlayer.getUniqueId())) {
        CloudNet.getInstance().getNetworkManager().getOnlinePlayers().get(offlinePlayer.getUniqueId()).setPermissionEntity(offlinePlayer.getPermissionEntity());
        CloudNet.getInstance().getNetworkManager().handlePlayerUpdate(CloudNet.getInstance().getNetworkManager().getOnlinePlayers().get(offlinePlayer.getUniqueId()));
    }
    CloudNet.getInstance().getNetworkManager().sendAllUpdate(new PacketOutUpdateOfflinePlayer(offlinePlayer));
}
Also used : PacketOutUpdateOfflinePlayer(de.dytanic.cloudnetcore.network.packet.out.PacketOutUpdateOfflinePlayer)

Aggregations

PacketOutUpdateOfflinePlayer (de.dytanic.cloudnetcore.network.packet.out.PacketOutUpdateOfflinePlayer)2 TypeToken (com.google.gson.reflect.TypeToken)1 CloudPlayer (de.dytanic.cloudnet.lib.player.CloudPlayer)1 OfflinePlayer (de.dytanic.cloudnet.lib.player.OfflinePlayer)1