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;
}
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;
}
Aggregations