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 CompletableFuture<Void> |
deletePlayerData(@NonNull UUID uniqueId)
Deletes any data about a given player from the uuid caching system.
|
@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 username)
Gets a loaded user.
|
@Nullable User |
getUser(@NonNull UUID uniqueId)
Gets a loaded user.
|
@NonNull CompletableFuture<List<HeldNode<UUID>>> |
getWithPermission(@NonNull String permission)
Deprecated.
|
boolean |
isLoaded(@NonNull UUID uniqueId)
Check if a user is loaded in memory
|
default @NonNull CompletableFuture<User> |
loadUser(@NonNull UUID uniqueId)
Loads a user from the plugin's storage provider into memory.
|
@NonNull CompletableFuture<User> |
loadUser(@NonNull UUID uniqueId,
@Nullable String username)
Loads a user from the plugin's storage provider into memory.
|
@NonNull CompletableFuture<UUID> |
lookupUniqueId(@NonNull String username)
Uses the LuckPerms cache to find a uuid for the given username.
|
@NonNull CompletableFuture<String> |
lookupUsername(@NonNull UUID uniqueId)
Uses the LuckPerms cache to find a username for the given uuid.
|
default @NonNull CompletableFuture<Void> |
modifyUser(@NonNull UUID uniqueId,
@NonNull Consumer<? super User> action)
Loads a user from the plugin's storage provider, applies the given
action,
then saves the user's data back to storage. |
@NonNull CompletableFuture<PlayerSaveResult> |
savePlayerData(@NonNull UUID uniqueId,
@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.
|
<T extends Node> |
searchAll(@NonNull NodeMatcher<? extends T> matcher)
|
@NonNull CompletableFuture<User> loadUser(@NonNull UUID uniqueId, @Nullable String username)
uniqueId - the uuid of the userusername - the username, if knownNullPointerException - if the uuid is nulldefault @NonNull CompletableFuture<User> loadUser(@NonNull UUID uniqueId)
uniqueId - the uuid of the userNullPointerException - if the uuid is null@NonNull CompletableFuture<UUID> lookupUniqueId(@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 uniqueId)
uniqueId - 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.
user - the user to saveNullPointerException - if user is nullIllegalStateException - if the user instance was not obtained from LuckPerms.default @NonNull CompletableFuture<Void> modifyUser(@NonNull UUID uniqueId, @NonNull Consumer<? super User> action)
action,
then saves the user's data back to storage.
This method effectively calls loadUser(UUID), followed by the action,
then saveUser(User), and returns an encapsulation of the whole process as a
CompletableFuture.
uniqueId - the uuid of the useraction - the action to apply to the user@NonNull CompletableFuture<PlayerSaveResult> savePlayerData(@NonNull UUID uniqueId, @NonNull String username)
uniqueId - the users mojang unique idusername - the users usernameNullPointerException - if either parameters are nullIllegalArgumentException - if the username is invalid@NonNull CompletableFuture<Void> deletePlayerData(@NonNull UUID uniqueId)
Note that this method does not affect any saved user/permissions data.
uniqueId - the users mojang unique id@NonNull CompletableFuture<Set<UUID>> getUniqueUsers()
"Unique" meaning the user isn't just a member of the "default" group.
<T extends Node> @NonNull CompletableFuture<Map<UUID,Collection<T>>> searchAll(@NonNull NodeMatcher<? extends T> matcher)
matcher - the matcher@Deprecated @NonNull CompletableFuture<List<HeldNode<UUID>>> getWithPermission(@NonNull String permission)
searchAll(NodeMatcher)permission - the permission to search forNullPointerException - if the permission is null@Nullable User getUser(@NonNull UUID uniqueId)
uniqueId - the uuid of the user to getUser object, if one matching the uuid is loaded, or null if notNullPointerException - if the uuid is null@Nullable User getUser(@NonNull String username)
username - the username of the user to getUser object, if one matching the uuid is loaded, or null if notNullPointerException - if the name is nullboolean isLoaded(@NonNull UUID uniqueId)
uniqueId - the uuid to check forNullPointerException - if the uuid is nullvoid cleanupUser(@NonNull User user)
user - the user to unloadNullPointerException - if the user is null