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).
-
Method Summary
Modifier and TypeMethodDescriptionvoidcleanupUser(@NonNull User user) Unload a user from the internal storage, if they're not currently online.deletePlayerData(@NonNull UUID uniqueId) Deletes any data about a given player from the uuid caching system.Gets a set of all loaded users.Gets a set all "unique" user UUIDs.Gets a loaded user.Gets a loaded user.getWithPermission(@NonNull String permission) Deprecated.booleanCheck if a user is loaded in memorydefault @NonNull CompletableFuture<User>Loads a user from the plugin's storage provider into memory.Loads a user from the plugin's storage provider into memory.lookupUniqueId(@NonNull String username) Uses the LuckPerms cache to find a uuid for the given username.lookupUsername(@NonNull UUID uniqueId) Uses the LuckPerms cache to find a username for the given uuid.default @NonNull CompletableFuture<Void>Loads a user from the plugin's storage provider, applies the givenaction, then saves the user's data back to storage.savePlayerData(@NonNull UUID uniqueId, @NonNull String username) Saves data about a player to the uuid caching system.Saves a user's data back to the plugin's storage provider.<T extends Node>
@NonNull CompletableFuture<@Unmodifiable Map<UUID,Collection<T>>> searchAll(@NonNull NodeMatcher<? extends T> matcher)
-
Method Details
-
loadUser
Loads a user from the plugin's storage provider into memory.- Parameters:
uniqueId- the uuid of the userusername- the username, if known- Returns:
- the resultant user
- Throws:
NullPointerException- if the uuid is null
-
loadUser
Loads a user from the plugin's storage provider into memory.- Parameters:
uniqueId- the uuid of the user- Returns:
- the resultant user
- Throws:
NullPointerException- if the uuid is null
-
lookupUniqueId
Uses the LuckPerms cache to find a uuid for the given username.This lookup is case insensitive.
- Parameters:
username- the username- Returns:
- a uuid, could be null
- Throws:
NullPointerException- if either parameters are nullIllegalArgumentException- if the username is invalid
-
lookupUsername
Uses the LuckPerms cache to find a username for the given uuid.- Parameters:
uniqueId- the uuid- Returns:
- a username, could be null
- Throws:
NullPointerException- if either parameters are nullIllegalArgumentException- if the username is invalid
-
saveUser
Saves a user's data back to the plugin's storage provider.You should call this after you make any changes to a user.
- Parameters:
user- the user to save- Returns:
- a future to encapsulate the operation.
- Throws:
NullPointerException- if user is nullIllegalStateException- if the user instance was not obtained from LuckPerms.
-
modifyUser
default @NonNull CompletableFuture<Void> modifyUser(@NonNull UUID uniqueId, @NonNull Consumer<? super User> action) Loads a user from the plugin's storage provider, applies the givenaction, then saves the user's data back to storage.This method effectively calls
loadUser(UUID), followed by theaction, thensaveUser(User), and returns an encapsulation of the whole process as aCompletableFuture.- Parameters:
uniqueId- the uuid of the useraction- the action to apply to the user- Returns:
- a future to encapsulate the operation
- Since:
- 5.1
-
savePlayerData
@NonNull CompletableFuture<PlayerSaveResult> savePlayerData(@NonNull UUID uniqueId, @NonNull String username) Saves data about a player to the uuid caching system.- Parameters:
uniqueId- the users mojang unique idusername- the users username- Returns:
- the result of the operation.
- Throws:
NullPointerException- if either parameters are nullIllegalArgumentException- if the username is invalid
-
deletePlayerData
Deletes any data about a given player from the uuid caching system.Note that this method does not affect any saved user/permissions data.
- Parameters:
uniqueId- the users mojang unique id- Returns:
- a future encapsulating the result of the operation
- Since:
- 5.2
-
getUniqueUsers
@NonNull CompletableFuture<@Unmodifiable Set<UUID>> getUniqueUsers()Gets a set all "unique" user UUIDs."Unique" meaning the user isn't just a member of the "default" group.
- Returns:
- a set of uuids
-
searchAll
<T extends Node> @NonNull CompletableFuture<@Unmodifiable Map<UUID,Collection<T>>> searchAll(@NonNull NodeMatcher<? extends T> matcher) - Parameters:
matcher- the matcher- Returns:
- the entries which matched
- Since:
- 5.1
-
getWithPermission
@Deprecated @NonNull CompletableFuture<@Unmodifiable List<HeldNode<UUID>>> getWithPermission(@NonNull String permission) Deprecated.UsesearchAll(NodeMatcher)insteadSearches for a list of users with a given permission.- Parameters:
permission- the permission to search for- Returns:
- a list of held permissions
- Throws:
NullPointerException- if the permission is null
-
getUser
Gets a loaded user.- Parameters:
uniqueId- the uuid of the user to get- Returns:
- a
Userobject, if one matching the uuid is loaded, or null if not - Throws:
NullPointerException- if the uuid is null
-
getUser
Gets a loaded user.- Parameters:
username- the username of the user to get- Returns:
- a
Userobject, if one matching the uuid is loaded, or null if not - Throws:
NullPointerException- if the name is null
-
getLoadedUsers
@NonNull @Unmodifiable Set<User> getLoadedUsers()Gets a set of all loaded users. -
isLoaded
Check if a user is loaded in memory- Parameters:
uniqueId- the uuid to check for- Returns:
- true if the user is loaded
- Throws:
NullPointerException- if the uuid is null
-
cleanupUser
Unload a user from the internal storage, if they're not currently online.- Parameters:
user- the user to unload- Throws:
NullPointerException- if the user is null
-
searchAll(NodeMatcher)instead