Get LuckPerms prefix from CompletableFuture

Discussion in 'BungeeCord Plugin Development' started by EVILCAT6, Mar 30, 2020.

  1. Hi. So I have some code that asynchronously gets the user's prefix from LuckPerms Bungee, but it returns a CompletableFuture<String>. How do I get the result of this into a String that I can use in messages without blocking the main server thread?

    Code (Java):
    public static CompletableFuture<String> getChatMeta(UUID uuid) {
        return luckPerms.getUserManager().loadUser(uuid)
                .thenApplyAsync(user -> user.getOwnNodes().stream()
                .filter(Node::isPrefix).collect(Collectors.toList())
                .get(0))
                .thenApplyAsync(Node::getPrefix)
                .thenApplyAsync(Map.Entry::getValue);
    }
    Please help, thank you.
     
  2. You should ask this question in the LuckPerms Discord. You will find help from their development team and other LuckPerms users there.