Interface UserManager
-
public interface UserManagerRepresents the object responsible for managingUserinstances.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 usingCompletableFuture.thenAcceptAsync(Consumer, Executor).
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description voidcleanupUser(@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 @Unmodifiable Set<User>getLoadedUsers()Gets a set of all loaded users.@NonNull CompletableFuture<@Unmodifiable Set<UUID>>getUniqueUsers()Gets a set all "unique" user UUIDs.@Nullable UsergetUser(@NonNull String username)Gets a loaded user.@Nullable UsergetUser(@NonNull UUID uniqueId)Gets a loaded user.@NonNull CompletableFuture<@Unmodifiable List<HeldNode<UUID>>>getWithPermission(@NonNull String permission)Deprecated.UsesearchAll(NodeMatcher)insteadbooleanisLoaded(@NonNull UUID uniqueId)Check if a user is loaded in memorydefault @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 givenaction, 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>
@NonNull CompletableFuture<@Unmodifiable Map<UUID,Collection<T>>>searchAll(@NonNull NodeMatcher<? extends T> matcher)
-
-
-
Method Detail
-
loadUser
@NonNull CompletableFuture<User> loadUser(@NonNull UUID uniqueId, @Nullable String username)
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
default @NonNull CompletableFuture<User> loadUser(@NonNull UUID uniqueId)
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
@NonNull CompletableFuture<UUID> lookupUniqueId(@NonNull String username)
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
@NonNull CompletableFuture<String> lookupUsername(@NonNull UUID uniqueId)
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
@NonNull CompletableFuture<Void> saveUser(@NonNull User user)
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
@NonNull CompletableFuture<Void> deletePlayerData(@NonNull UUID uniqueId)
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
@Nullable User getUser(@NonNull UUID uniqueId)
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
@Nullable User getUser(@NonNull String username)
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
boolean isLoaded(@NonNull UUID uniqueId)
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
void cleanupUser(@NonNull User user)
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
-
-