use of net.luckperms.api.model.data.DataMutateResult in project AuthMeReloaded by AuthMe.
the class LuckPermsHandler method setGroup.
@Override
public boolean setGroup(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 set group for offline user " + player.getName() + " but it isn't loaded!");
return false;
}
InheritanceNode groupNode = buildGroupNode(group);
DataMutateResult result = user.data().add(groupNode);
if (result == DataMutateResult.FAIL) {
return false;
}
user.data().clear(node -> {
if (!(node instanceof InheritanceNode)) {
return false;
}
InheritanceNode inheritanceNode = (InheritanceNode) node;
return !inheritanceNode.equals(groupNode);
});
luckPerms.getUserManager().saveUser(user);
return true;
}
use of net.luckperms.api.model.data.DataMutateResult 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;
}
Aggregations