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(User user)
Unload a user from the internal storage, if they're not currently online.
|
Set<User> |
getLoadedUsers()
Gets a set of all loaded users.
|
CompletableFuture<Set<UUID>> |
getUniqueUsers()
Gets a set all "unique" user UUIDs.
|
User |
getUser(String name)
Gets a loaded user.
|
User |
getUser(UUID uuid)
Gets a loaded user.
|
default Optional<User> |
getUserOpt(String name)
Gets a loaded user.
|
default Optional<User> |
getUserOpt(UUID uuid)
Gets a loaded user.
|
CompletableFuture<List<HeldPermission<UUID>>> |
getWithPermission(String permission)
Searches for a list of users with a given permission.
|
boolean |
isLoaded(UUID uuid)
Check if a user is loaded in memory
|
default CompletableFuture<User> |
loadUser(UUID uuid)
Loads a user from the plugin's storage provider into memory.
|
CompletableFuture<User> |
loadUser(UUID uuid,
String username)
Loads a user from the plugin's storage provider into memory.
|
CompletableFuture<String> |
lookupUsername(UUID uuid)
Uses the LuckPerms cache to find a username for the given uuid.
|
CompletableFuture<UUID> |
lookupUuid(String username)
Uses the LuckPerms cache to find a uuid for the given username.
|
CompletableFuture<PlayerSaveResult> |
savePlayerData(UUID uuid,
String username)
Saves data about a player to the uuid caching system.
|
CompletableFuture<Void> |
saveUser(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 null@Nonnull default 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 null@Nonnull default 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 null@Nonnull default 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 nullCopyright © 2018. All rights reserved.