mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2026-11-08 18:44:44 +00:00
Add API bulk user lookup method (#4285)
This commit is contained in:
1 parent
cb77ed09be
commit
d07dcacab4
2 files changed
+22
No files matched your search
@@ -81,6 +81,15 @@ public interface UserManager {
|
||||
return loadUser(uniqueId, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads multiple users from the plugin's storage provider into memory.
|
||||
*
|
||||
* @param uniqueIds the uuids of the users to load
|
||||
* @return a future for an unmodifiable map of loaded users
|
||||
* @throws NullPointerException if the uuid set is null
|
||||
*/
|
||||
@NonNull CompletableFuture<@Unmodifiable Map<UUID, User>> loadUsers(@NonNull Set<@NonNull UUID> uniqueIds);
|
||||
|
||||
/**
|
||||
* Uses the LuckPerms cache to find a uuid for the given username.
|
||||
*
|
||||
|
||||
@@ -49,6 +49,7 @@ import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ApiUserManager extends ApiAbstractManager<User, net.luckperms.api.model.user.User, UserManager<?>> implements net.luckperms.api.model.user.UserManager {
|
||||
public ApiUserManager(LuckPermsPlugin plugin, UserManager<?> handle) {
|
||||
@@ -76,6 +77,18 @@ public class ApiUserManager extends ApiAbstractManager<User, net.luckperms.api.m
|
||||
.thenApply(this::proxyAndRegisterUsage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull CompletableFuture<Map<UUID, net.luckperms.api.model.user.User>> loadUsers(@NonNull Set<@NonNull UUID> uniqueIds) {
|
||||
Objects.requireNonNull(uniqueIds, "uuid set");
|
||||
|
||||
if (uniqueIds.isEmpty()) {
|
||||
return CompletableFuture.completedFuture(Map.of());
|
||||
}
|
||||
|
||||
return this.plugin.getStorage().loadUsers(uniqueIds)
|
||||
.thenApply(map -> map.entrySet().stream().collect(Collectors.toUnmodifiableMap(Map.Entry::getKey, entry -> this.proxyAndRegisterUsage(entry.getValue()))));
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull CompletableFuture<UUID> lookupUniqueId(@NonNull String username) {
|
||||
Objects.requireNonNull(username, "username");
|
||||
|
||||
Reference in new issue
Block a user