Interface GroupManager
-
public interface GroupManagerRepresents the object responsible for managingGroupinstances.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 @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 GroupgetGroup(@NonNull String name)Gets a loaded group.@NonNull @Unmodifiable Set<Group>getLoadedGroups()Gets a set of all loaded groups.@NonNull CompletableFuture<@Unmodifiable List<HeldNode<String>>>getWithPermission(@NonNull String permission)Deprecated.UsesearchAll(NodeMatcher)insteadbooleanisLoaded(@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 givenaction, 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>
@NonNull CompletableFuture<@Unmodifiable Map<String,Collection<T>>>searchAll(@NonNull NodeMatcher<? extends T> matcher)
-
-
-
Method Detail
-
createAndLoadGroup
@NonNull CompletableFuture<Group> createAndLoadGroup(@NonNull String name)
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
@NonNull CompletableFuture<Optional<Group>> loadGroup(@NonNull String name)
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
@NonNull CompletableFuture<Void> saveGroup(@NonNull Group group)
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
@NonNull CompletableFuture<Void> deleteGroup(@NonNull Group group)
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
@Nullable Group getGroup(@NonNull String name)
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
boolean isLoaded(@NonNull String name)
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
-
-