mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-23 10:45:23 +01:00
Use the latest LuckPerms api methods
This commit is contained in:
parent
a1a909c01d
commit
6251a69d3e
@ -1,5 +1,6 @@
|
||||
package fr.xephi.authme.permission.handlers;
|
||||
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.permission.PermissionNode;
|
||||
import fr.xephi.authme.permission.PermissionsSystemType;
|
||||
import me.lucko.luckperms.LuckPerms;
|
||||
@ -41,13 +42,8 @@ public class LuckPermsHandler implements PermissionHandler {
|
||||
}
|
||||
|
||||
private void saveUser(User user) {
|
||||
luckPermsApi.getStorage().saveUser(user)
|
||||
.thenAcceptAsync(wasSuccessful -> {
|
||||
if (!wasSuccessful) {
|
||||
return;
|
||||
}
|
||||
user.refreshPermissions();
|
||||
}, luckPermsApi.getStorage().getAsyncExecutor());
|
||||
luckPermsApi.getUserManager().saveUser(user)
|
||||
.thenAcceptAsync(wasSuccessful -> user.refreshCachedData());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -62,7 +58,7 @@ public class LuckPermsHandler implements PermissionHandler {
|
||||
return false;
|
||||
}
|
||||
|
||||
DataMutateResult result = user.setPermissionUnchecked(
|
||||
DataMutateResult result = user.setPermission(
|
||||
luckPermsApi.getNodeFactory().makeGroupNode(newGroup).build());
|
||||
if (result == DataMutateResult.FAIL) {
|
||||
return false;
|
||||
@ -83,6 +79,8 @@ public class LuckPermsHandler implements PermissionHandler {
|
||||
public boolean hasPermissionOffline(String name, PermissionNode node) {
|
||||
User user = luckPermsApi.getUser(name);
|
||||
if (user == null) {
|
||||
ConsoleLogger.warning("LuckPermsHandler: tried to check permission for offline user "
|
||||
+ name + " but it isn't loaded!");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -98,6 +96,8 @@ public class LuckPermsHandler implements PermissionHandler {
|
||||
public boolean isInGroup(OfflinePlayer player, String group) {
|
||||
User user = luckPermsApi.getUser(player.getName());
|
||||
if (user == null) {
|
||||
ConsoleLogger.warning("LuckPermsHandler: tried to check group for offline user "
|
||||
+ player.getName() + " but it isn't loaded!");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -112,6 +112,8 @@ public class LuckPermsHandler implements PermissionHandler {
|
||||
public boolean removeFromGroup(OfflinePlayer player, String group) {
|
||||
User user = luckPermsApi.getUser(player.getName());
|
||||
if (user == null) {
|
||||
ConsoleLogger.warning("LuckPermsHandler: tried to remove group for offline user "
|
||||
+ player.getName() + " but it isn't loaded!");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -121,7 +123,7 @@ public class LuckPermsHandler implements PermissionHandler {
|
||||
}
|
||||
|
||||
Node groupNode = luckPermsApi.getNodeFactory().makeGroupNode(permissionGroup).build();
|
||||
boolean result = user.unsetPermissionUnchecked(groupNode) != DataMutateResult.FAIL;
|
||||
boolean result = user.unsetPermission(groupNode) != DataMutateResult.FAIL;
|
||||
|
||||
luckPermsApi.cleanupUser(user);
|
||||
return result;
|
||||
@ -131,6 +133,8 @@ public class LuckPermsHandler implements PermissionHandler {
|
||||
public boolean setGroup(OfflinePlayer player, String group) {
|
||||
User user = luckPermsApi.getUser(player.getName());
|
||||
if (user == null) {
|
||||
ConsoleLogger.warning("LuckPermsHandler: tried to set group for offline user "
|
||||
+ player.getName() + " but it isn't loaded!");
|
||||
return false;
|
||||
}
|
||||
Group permissionGroup = luckPermsApi.getGroup(group);
|
||||
@ -138,7 +142,7 @@ public class LuckPermsHandler implements PermissionHandler {
|
||||
return false;
|
||||
}
|
||||
Node groupNode = luckPermsApi.getNodeFactory().makeGroupNode(permissionGroup).build();
|
||||
DataMutateResult result = user.setPermissionUnchecked(groupNode);
|
||||
DataMutateResult result = user.setPermission(groupNode);
|
||||
if (result == DataMutateResult.FAIL) {
|
||||
return false;
|
||||
}
|
||||
@ -153,6 +157,8 @@ public class LuckPermsHandler implements PermissionHandler {
|
||||
public List<String> getGroups(OfflinePlayer player) {
|
||||
User user = luckPermsApi.getUser(player.getName());
|
||||
if (user == null) {
|
||||
ConsoleLogger.warning("LuckPermsHandler: tried to get groups for offline user "
|
||||
+ player.getName() + " but it isn't loaded!");
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@ -185,7 +191,7 @@ public class LuckPermsHandler implements PermissionHandler {
|
||||
@Override
|
||||
public void loadUserData(UUID uuid) {
|
||||
try {
|
||||
luckPermsApi.getStorage().loadUser(uuid).get(5, TimeUnit.SECONDS);
|
||||
luckPermsApi.getUserManager().loadUser(uuid).get(5, TimeUnit.SECONDS);
|
||||
} catch (InterruptedException | ExecutionException | TimeoutException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user