Getting permissions of offline UUID
BenHall-1 opened this issue ยท 5 comments
Hi,
I'm trying to get the permissions of a UUID that is currently offline. I wrote the following code but it always returns false. Can you please advise whether I'm doing something wrong with the code? or whether it is a genuine bug
public CompletableFuture<Boolean> hasPermission(String permission) {
return Main.getLuckPermsAPI().getUserManager().loadUser(uuid)
.thenApplyAsync(user -> {
ContextManager contextManager = Main.getLuckPermsAPI().getContextManager();
ImmutableContextSet contextSet = contextManager.getContext(user).orElseGet(contextManager::getStaticContext);
CachedPermissionData permissionData = user.getCachedData().getPermissionData(QueryOptions.contextual(contextSet));
return permissionData.checkPermission(permission).asBoolean();
});
}
Instead of getting the Contexts, try the query options:
contextManager.getQueryOptions(user).orElseGet(contextManager::getStaticQueryOptions);