Search in sources :

Example 6 with User

use of net.luckperms.api.model.user.User in project AuthMeReloaded by AuthMe.

the class LuckPermsHandler method addToGroup.

@Override
public boolean addToGroup(OfflinePlayer player, UserGroup group) {
    Group newGroup = luckPerms.getGroupManager().getGroup(group.getGroupName());
    if (newGroup == null) {
        return false;
    }
    String playerName = player.getName();
    if (playerName == null) {
        return false;
    }
    User user = luckPerms.getUserManager().getUser(playerName);
    if (user == null) {
        return false;
    }
    InheritanceNode node = buildGroupNode(group);
    DataMutateResult result = user.data().add(node);
    if (result == DataMutateResult.FAIL) {
        return false;
    }
    luckPerms.getUserManager().saveUser(user);
    return true;
}
Also used : UserGroup(fr.xephi.authme.data.limbo.UserGroup) Group(net.luckperms.api.model.group.Group) User(net.luckperms.api.model.user.User) InheritanceNode(net.luckperms.api.node.types.InheritanceNode) DataMutateResult(net.luckperms.api.model.data.DataMutateResult)

Example 7 with User

use of net.luckperms.api.model.user.User in project AuthMeReloaded by AuthMe.

the class LuckPermsHandler method removeFromGroup.

@Override
public boolean removeFromGroup(OfflinePlayer player, UserGroup group) {
    String playerName = player.getName();
    if (playerName == null) {
        return false;
    }
    User user = luckPerms.getUserManager().getUser(playerName);
    if (user == null) {
        logger.warning("LuckPermsHandler: tried to remove group for offline user " + player.getName() + " but it isn't loaded!");
        return false;
    }
    InheritanceNode groupNode = InheritanceNode.builder(group.getGroupName()).build();
    boolean result = user.data().remove(groupNode) != DataMutateResult.FAIL;
    luckPerms.getUserManager().saveUser(user);
    return result;
}
Also used : User(net.luckperms.api.model.user.User) InheritanceNode(net.luckperms.api.node.types.InheritanceNode)

Aggregations

User (net.luckperms.api.model.user.User)7 InheritanceNode (net.luckperms.api.node.types.InheritanceNode)5 DataMutateResult (net.luckperms.api.model.data.DataMutateResult)3 UserGroup (fr.xephi.authme.data.limbo.UserGroup)2 CachedPermissionData (net.luckperms.api.cacheddata.CachedPermissionData)2 Group (net.luckperms.api.model.group.Group)2 ConsoleLogger (fr.xephi.authme.ConsoleLogger)1 ConsoleLoggerFactory (fr.xephi.authme.output.ConsoleLoggerFactory)1 PermissionNode (fr.xephi.authme.permission.PermissionNode)1 PermissionsSystemType (fr.xephi.authme.permission.PermissionsSystemType)1 Collections (java.util.Collections)1 List (java.util.List)1 Objects (java.util.Objects)1 UUID (java.util.UUID)1 ExecutionException (java.util.concurrent.ExecutionException)1 TimeUnit (java.util.concurrent.TimeUnit)1 TimeoutException (java.util.concurrent.TimeoutException)1 Collectors (java.util.stream.Collectors)1 LuckPerms (net.luckperms.api.LuckPerms)1 LuckPermsProvider (net.luckperms.api.LuckPermsProvider)1