Search in sources :

Example 11 with OfflinePlayer

use of de.dytanic.cloudnet.lib.player.OfflinePlayer in project CloudNet by Dytanic.

the class VaultChatImpl method setPlayerSuffix.

@Override
public void setPlayerSuffix(String s, String s1, String s2) {
    OfflinePlayer offlinePlayer = getPlayer(s1);
    offlinePlayer.getPermissionEntity().setSuffix(s2);
    update(offlinePlayer);
}
Also used : OfflinePlayer(de.dytanic.cloudnet.lib.player.OfflinePlayer)

Example 12 with OfflinePlayer

use of de.dytanic.cloudnet.lib.player.OfflinePlayer in project CloudNet by Dytanic.

the class VaultPermissionImpl method playerAddGroup.

@Override
public boolean playerAddGroup(String s, String s1, String s2) {
    OfflinePlayer offlinePlayer = getPlayer(s1);
    PermissionEntity permissionEntity = offlinePlayer.getPermissionEntity();
    GroupEntityData groupEntityData = CollectionWrapper.filter(permissionEntity.getGroups(), new Acceptable<GroupEntityData>() {

        @Override
        public boolean isAccepted(GroupEntityData groupEntityData) {
            return groupEntityData.getGroup().equalsIgnoreCase(s2);
        }
    });
    if (groupEntityData != null) {
        permissionEntity.getGroups().remove(groupEntityData);
        groupEntityData = new GroupEntityData(groupEntityData.getGroup(), 0);
    } else {
        groupEntityData = new GroupEntityData(groupEntityData.getGroup(), 0);
    }
    permissionEntity.getGroups().add(groupEntityData);
    offlinePlayer.setPermissionEntity(permissionEntity);
    updatePlayer(offlinePlayer);
    return true;
}
Also used : OfflinePlayer(de.dytanic.cloudnet.lib.player.OfflinePlayer) PermissionEntity(de.dytanic.cloudnet.lib.player.permission.PermissionEntity) GroupEntityData(de.dytanic.cloudnet.lib.player.permission.GroupEntityData)

Example 13 with OfflinePlayer

use of de.dytanic.cloudnet.lib.player.OfflinePlayer in project CloudNet by Dytanic.

the class VaultPermissionImpl method groupHas.

@Override
public boolean groupHas(String s, String s1, String s2) {
    OfflinePlayer offlinePlayer = getPlayer(s1);
    PermissionEntity permissionEntity = offlinePlayer.getPermissionEntity();
    return permissionEntity.isInGroup(s2);
}
Also used : OfflinePlayer(de.dytanic.cloudnet.lib.player.OfflinePlayer) PermissionEntity(de.dytanic.cloudnet.lib.player.permission.PermissionEntity)

Example 14 with OfflinePlayer

use of de.dytanic.cloudnet.lib.player.OfflinePlayer in project CloudNet by Dytanic.

the class VaultPermissionImpl method playerInGroup.

@Override
public boolean playerInGroup(String s, String s1, String s2) {
    OfflinePlayer offlinePlayer = getPlayer(s1);
    PermissionEntity permissionEntity = offlinePlayer.getPermissionEntity();
    return permissionEntity.isInGroup(s2);
}
Also used : OfflinePlayer(de.dytanic.cloudnet.lib.player.OfflinePlayer) PermissionEntity(de.dytanic.cloudnet.lib.player.permission.PermissionEntity)

Example 15 with OfflinePlayer

use of de.dytanic.cloudnet.lib.player.OfflinePlayer in project CloudNet by Dytanic.

the class NetworkManager method handlePlayerLoginRequest.

public void handlePlayerLoginRequest(ProxyServer proxyServer, PlayerConnection cloudPlayerConnection, UUID uniqueId) {
    if (this.onlinePlayers.containsKey(cloudPlayerConnection.getUniqueId())) {
        proxyServer.sendPacketSynchronized(new PacketOutLoginPlayer(uniqueId, null));
        return;
    }
    LoginRequestEvent loginRequestEvent = new LoginRequestEvent(proxyServer, cloudPlayerConnection);
    CloudNet.getInstance().getEventManager().callEvent(loginRequestEvent);
    PlayerDatabase playerDatabase = CloudNet.getInstance().getDbHandlers().getPlayerDatabase();
    OfflinePlayer offlinePlayer = null;
    if (!playerDatabase.containsPlayer(cloudPlayerConnection.getUniqueId()))
        offlinePlayer = playerDatabase.registerPlayer(cloudPlayerConnection);
    if (offlinePlayer == null)
        offlinePlayer = playerDatabase.getPlayer(cloudPlayerConnection.getUniqueId());
    CloudPlayer cloudPlayer = new CloudPlayer(offlinePlayer, cloudPlayerConnection, proxyServer.getServerId());
    cloudPlayer.setPlayerExecutor(CorePlayerExecutor.INSTANCE);
    if (cloudPlayer.getFirstLogin() != null)
        cloudPlayer.setFirstLogin(System.currentTimeMillis());
    CloudNet.getInstance().getEventManager().callEvent(new PlayerInitEvent(cloudPlayer));
    CloudNet.getInstance().getDbHandlers().getNameToUUIDDatabase().append(new MultiValue<>(cloudPlayerConnection.getName(), cloudPlayerConnection.getUniqueId()));
    CloudNet.getInstance().getDbHandlers().getNameToUUIDDatabase().replace(new MultiValue<>(cloudPlayerConnection.getUniqueId(), cloudPlayerConnection.getName()));
    cloudPlayer.setName(cloudPlayerConnection.getName());
    CloudNet.getInstance().getDbHandlers().getPlayerDatabase().updatePlayer(CloudPlayer.newOfflinePlayer(cloudPlayer));
    proxyServer.sendPacketSynchronized(new PacketOutLoginPlayer(uniqueId, cloudPlayer));
    this.waitingPlayers.put(cloudPlayer.getUniqueId(), cloudPlayer);
    handlePlayerLogin(cloudPlayer);
}
Also used : PlayerDatabase(de.dytanic.cloudnetcore.database.PlayerDatabase) CloudPlayer(de.dytanic.cloudnet.lib.player.CloudPlayer) OfflinePlayer(de.dytanic.cloudnet.lib.player.OfflinePlayer)

Aggregations

OfflinePlayer (de.dytanic.cloudnet.lib.player.OfflinePlayer)18 PermissionEntity (de.dytanic.cloudnet.lib.player.permission.PermissionEntity)7 Document (de.dytanic.cloudnet.lib.utility.document.Document)5 DatabaseDocument (de.dytanic.cloudnet.lib.database.DatabaseDocument)4 GroupEntityData (de.dytanic.cloudnet.lib.player.permission.GroupEntityData)4 CloudPlayer (de.dytanic.cloudnet.lib.player.CloudPlayer)3 UUID (java.util.UUID)3 PacketOutUpdateOfflinePlayer (de.dytanic.cloudnetcore.network.packet.out.PacketOutUpdateOfflinePlayer)2 SimpleDateFormat (java.text.SimpleDateFormat)2 TypeToken (com.google.gson.reflect.TypeToken)1 PlayerConnection (de.dytanic.cloudnet.lib.player.PlayerConnection)1 PlayerExecutor (de.dytanic.cloudnet.lib.player.PlayerExecutor)1 DefaultPermissionGroup (de.dytanic.cloudnet.lib.player.permission.DefaultPermissionGroup)1 PermissionGroup (de.dytanic.cloudnet.lib.player.permission.PermissionGroup)1 PermissionPool (de.dytanic.cloudnet.lib.player.permission.PermissionPool)1 PlayerDatabase (de.dytanic.cloudnetcore.database.PlayerDatabase)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1