public interface GroupManager
Group instances.
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 |
|---|---|
@NonNull CompletableFuture<Group> |
createAndLoadGroup(@NonNull String name)
Creates a new group in the plugin's storage provider and then loads it
into memory.
|
@NonNull CompletableFuture<Void> |
deleteGroup(@NonNull Group group)
Permanently deletes a group from the plugin's storage provider.
|
@Nullable Group |
getGroup(@NonNull String name)
Gets a loaded group.
|
@NonNull Set<Group> |
getLoadedGroups()
Gets a set of all loaded groups.
|
@NonNull CompletableFuture<List<HeldNode<String>>> |
getWithPermission(@NonNull String permission)
Deprecated.
|
boolean |
isLoaded(@NonNull String name)
Check if a group is loaded in memory
|
@NonNull CompletableFuture<Void> |
loadAllGroups()
Loads all groups into memory.
|
@NonNull CompletableFuture<Optional<Group>> |
loadGroup(@NonNull String name)
Loads a group from the plugin's storage provider into memory.
|
default @NonNull CompletableFuture<Void> |
modifyGroup(@NonNull String name,
@NonNull Consumer<? super Group> action)
Loads (or creates) a group from the plugin's storage provider, applies the given
action, then saves the group's data back to storage. |
@NonNull CompletableFuture<Void> |
saveGroup(@NonNull Group group)
Saves a group's data back to the plugin's storage provider.
|
<T extends Node> |
searchAll(@NonNull NodeMatcher<? extends T> matcher)
|
@NonNull CompletableFuture<Group> createAndLoadGroup(@NonNull String name)
If a group by the same name already exists, it will be loaded.
name - the name of the groupNullPointerException - if the name is null@NonNull CompletableFuture<Optional<Group>> loadGroup(@NonNull String name)
Returns an empty optional if the group does
not exist.
name - the name of the groupNullPointerException - if the name is null@NonNull CompletableFuture<Void> saveGroup(@NonNull Group group)
You should call this after you make any changes to a group.
group - the group to saveNullPointerException - if group is nullIllegalStateException - if the group instance was not obtained from LuckPerms.@NonNull CompletableFuture<Void> deleteGroup(@NonNull Group group)
group - the group to deleteNullPointerException - if group is nullIllegalStateException - if the group instance was not obtained from LuckPerms.default @NonNull CompletableFuture<Void> modifyGroup(@NonNull String name, @NonNull Consumer<? super Group> action)
action, then saves the group's data back to storage.
This method effectively calls createAndLoadGroup(String), followed by the
action, then saveGroup(Group), and returns an encapsulation of the whole
process as a CompletableFuture.
name - the name of the groupaction - the action to apply to the group@NonNull CompletableFuture<Void> loadAllGroups()
<T extends Node> @NonNull CompletableFuture<Map<String,Collection<T>>> searchAll(@NonNull NodeMatcher<? extends T> matcher)
matcher - the matcher@Deprecated @NonNull CompletableFuture<List<HeldNode<String>>> getWithPermission(@NonNull String permission)
searchAll(NodeMatcher)permission - the permission to search forNullPointerException - if the permission is null@Nullable Group getGroup(@NonNull String name)
name - the name of the group to getGroup object, if one matching the name exists, or null if notNullPointerException - if the name is nullboolean isLoaded(@NonNull String name)
name - the name to check forNullPointerException - if the name is null