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).
-
Method Summary
Modifier and TypeMethodDescriptioncreateAndLoadGroup(@NonNull String name) Creates a new group in the plugin's storage provider and then loads it into memory.deleteGroup(@NonNull Group group) Permanently deletes a group from the plugin's storage provider.Gets a loaded group.Gets a set of all loaded groups.getWithPermission(@NonNull String permission) Deprecated.booleanCheck if a group is loaded in memoryLoads all groups into memory.Loads a group from the plugin's storage provider into memory.default @NonNull CompletableFuture<Void>Loads (or creates) a group from the plugin's storage provider, applies the givenaction, then saves the group's data back to storage.Saves a group's data back to the plugin's storage provider.<T extends Node>
@NonNull CompletableFuture<@Unmodifiable Map<String,Collection<T>>> searchAll(@NonNull NodeMatcher<? extends T> matcher)
-
Method Details
-
createAndLoadGroup
Creates a new group in the plugin's storage provider and then loads it into memory.If a group by the same name already exists, it will be loaded.
- Parameters:
name- the name of the group- Returns:
- the resultant group
- Throws:
NullPointerException- if the name is null
-
loadGroup
Loads a group from the plugin's storage provider into memory.Returns an
empty optionalif the group does not exist.- Parameters:
name- the name of the group- Returns:
- the resultant group
- Throws:
NullPointerException- if the name is null
-
saveGroup
Saves a group's data back to the plugin's storage provider.You should call this after you make any changes to a group.
- Parameters:
group- the group to save- Returns:
- a future to encapsulate the operation.
- Throws:
NullPointerException- if group is nullIllegalStateException- if the group instance was not obtained from LuckPerms.
-
deleteGroup
Permanently deletes a group from the plugin's storage provider.- Parameters:
group- the group to delete- Returns:
- a future to encapsulate the operation.
- Throws:
NullPointerException- if group is nullIllegalStateException- if the group instance was not obtained from LuckPerms.
-
modifyGroup
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 givenaction, then saves the group's data back to storage.This method effectively calls
createAndLoadGroup(String), followed by theaction, thensaveGroup(Group), and returns an encapsulation of the whole process as aCompletableFuture.- Parameters:
name- the name of the groupaction- the action to apply to the group- Returns:
- a future to encapsulate the operation
- Since:
- 5.1
-
loadAllGroups
@NonNull CompletableFuture<Void> loadAllGroups()Loads all groups into memory.- Returns:
- a future to encapsulate the operation.
-
searchAll
<T extends Node> @NonNull CompletableFuture<@Unmodifiable Map<String,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<String>>> getWithPermission(@NonNull String permission) Deprecated.UsesearchAll(NodeMatcher)insteadSearches for a list of groups with a given permission.- Parameters:
permission- the permission to search for- Returns:
- a list of held permissions, or null if the operation failed
- Throws:
NullPointerException- if the permission is null
-
getGroup
Gets a loaded group.- Parameters:
name- the name of the group to get- Returns:
- a
Groupobject, if one matching the name exists, or null if not - Throws:
NullPointerException- if the name is null
-
getLoadedGroups
@NonNull @Unmodifiable Set<Group> getLoadedGroups()Gets a set of all loaded groups. -
isLoaded
Check if a group is loaded in memory- Parameters:
name- the name to check for- Returns:
- true if the group is loaded
- Throws:
NullPointerException- if the name is null
-
searchAll(NodeMatcher)instead