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 username)
Gets a loaded user.
|
@Nullable User |
getUser(@NonNull UUID uniqueId)
Gets a loaded user.
|
@NonNull CompletableFuture<List<HeldNode<UUID>>> |
getWithPermission(@NonNull String permission)
Searches for a list of users with a given permission.
|
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.
|
@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.
|
@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.@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<Set<UUID>> getUniqueUsers()
"Unique" meaning the user isn't just a member of the "default" group.
@NonNull CompletableFuture<List<HeldNode<UUID>>> getWithPermission(@NonNull String permission)
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