public interface UserManager
User instances.
Note that User instances are automatically loaded for online players. It's likely that offline players will not have an instance pre-loaded.
All blocking methods return CompletableFutures, which will be
populated with the result once the data has been loaded/saved asynchronously.
Care should be taken when using such methods to ensure that the main server
thread is not blocked.
Methods such as CompletableFuture.get() and equivalent should
not be called on the main server thread. If you need to use
the result of these operations on the main server thread, register a
callback using CompletableFuture.thenAcceptAsync(Consumer, Executor).
| Modifier and Type | Method and Description |
|---|---|
void |
cleanupUser(@NonNull User user)
Unload a user from the internal storage, if they're not currently online.
|
@NonNull Set<User> |
getLoadedUsers()
Gets a set of all loaded users.
|
@NonNull CompletableFuture<Set<UUID>> |
getUniqueUsers()
Gets a set all "unique" user UUIDs.
|
@Nullable User |
getUser(@NonNull String name)
Gets a loaded user.
|
@Nullable User |
getUser(@NonNull UUID uuid)
Gets a loaded user.
|
default @NonNull Optional<User> |
getUserOpt(@NonNull String name)
Gets a loaded user.
|
default @NonNull Optional<User> |
getUserOpt(@NonNull UUID uuid)
Gets a loaded user.
|
@NonNull CompletableFuture<List<HeldPermission<UUID>>> |
getWithPermission(@NonNull String permission)
Searches for a list of users with a given permission.
|
boolean |
isLoaded(@NonNull UUID uuid)
Check if a user is loaded in memory
|
default @NonNull CompletableFuture<User> |
loadUser(@NonNull UUID uuid)
Loads a user from the plugin's storage provider into memory.
|
@NonNull CompletableFuture<User> |
loadUser(@NonNull UUID uuid,
@Nullable String username)
Loads a user from the plugin's storage provider into memory.
|
@NonNull CompletableFuture<String> |
lookupUsername(@NonNull UUID uuid)
Uses the LuckPerms cache to find a username for the given uuid.
|
@NonNull CompletableFuture<UUID> |
lookupUuid(@NonNull String username)
Uses the LuckPerms cache to find a uuid for the given username.
|
@NonNull CompletableFuture<PlayerSaveResult> |
savePlayerData(@NonNull UUID uuid,
@NonNull String username)
Saves data about a player to the uuid caching system.
|
@NonNull CompletableFuture<Void> |
saveUser(@NonNull User user)
Saves a user's data back to the plugin's storage provider.
|
@NonNull CompletableFuture<User> loadUser(@NonNull UUID uuid, @Nullable String username)
This method is effectively the same as
Storage.loadUser(UUID, String), however, the Future returns the
resultant user instance instead of a boolean flag.
Unlike the method in Storage, when a user cannot be loaded,
the future will be completed exceptionally.
uuid - the uuid of the userusername - the username, if knownNullPointerException - if the uuid is nulldefault @NonNull CompletableFuture<User> loadUser(@NonNull UUID uuid)
This method is effectively the same as Storage.loadUser(UUID),
however, the Future returns the resultant user instance instead of a
boolean flag.
Unlike the method in Storage, when a user cannot be loaded,
the future will be completed exceptionally.
uuid - the uuid of the userNullPointerException - if the uuid is null@NonNull CompletableFuture<UUID> lookupUuid(@NonNull String username)
This lookup is case insensitive.
username - the usernameNullPointerException - if either parameters are nullIllegalArgumentException - if the username is invalid@NonNull CompletableFuture<String> lookupUsername(@NonNull UUID uuid)
uuid - the uuidNullPointerException - if either parameters are nullIllegalArgumentException - if the username is invalid@NonNull CompletableFuture<Void> saveUser(@NonNull User user)
You should call this after you make any changes to a user.
This method is effectively the same as Storage.saveUser(User),
however, the Future returns void instead of a boolean flag.
Unlike the method in Storage, when a user cannot be saved,
the future will be completed exceptionally.
user - the user to saveNullPointerException - if user is nullIllegalStateException - if the user instance was not obtained from LuckPerms.@NonNull CompletableFuture<PlayerSaveResult> savePlayerData(@NonNull UUID uuid, @NonNull String username)
uuid - the users mojang unique idusername - the users usernameNullPointerException - if either parameters are nullIllegalArgumentException - if the username is invalid@NonNull CompletableFuture<Set<UUID>> getUniqueUsers()
"Unique" meaning the user isn't just a member of the "default" group.
@NonNull CompletableFuture<List<HeldPermission<UUID>>> getWithPermission(@NonNull String permission)
permission - the permission to search forNullPointerException - if the permission is null@Nullable User getUser(@NonNull UUID uuid)
uuid - the uuid of the user to getUser object, if one matching the uuid is loaded, or null if notNullPointerException - if the uuid is nulldefault @NonNull Optional<User> getUserOpt(@NonNull UUID uuid)
uuid - the uuid of the user to getUser objectNullPointerException - if the uuid is null@Nullable User getUser(@NonNull String name)
name - the username of the user to getUser object, if one matching the uuid is loaded, or null if notNullPointerException - if the name is nulldefault @NonNull Optional<User> getUserOpt(@NonNull String name)
name - the username of the user to getUser objectNullPointerException - if the name is nullboolean isLoaded(@NonNull UUID uuid)
uuid - the uuid to check forNullPointerException - if the uuid is nullvoid cleanupUser(@NonNull User user)
user - the user to unloadNullPointerException - if the user is null