public interface GroupManager
Group
instances.
All blocking methods return CompletableFuture
s, 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.
|
default @NonNull Optional<Group> |
getGroupOpt(@NonNull String name)
Gets a loaded group.
|
@NonNull Set<Group> |
getLoadedGroups()
Gets a set of all loaded groups.
|
@NonNull CompletableFuture<List<HeldPermission<String>>> |
getWithPermission(@NonNull String permission)
Searches for a list of groups with a given permission.
|
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.
|
@NonNull CompletableFuture<Void> |
saveGroup(@NonNull Group group)
Saves a group's data back to the plugin's storage provider.
|
@NonNull CompletableFuture<Group> createAndLoadGroup(@NonNull String name)
If a group by the same name already exists, it will be loaded.
This method is effectively the same as
Storage.createAndLoadGroup(String)
, however, the Future returns
the resultant group instance instead of a boolean flag.
Unlike the method in Storage
, when a group cannot be loaded,
the future will be completed exceptionally
.
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.
This method is effectively the same as
Storage.loadGroup(String)
, however, the Future returns
the resultant group instance instead of a boolean flag.
Unlike the method in Storage
, when a group cannot be loaded,
the future will be completed exceptionally
.
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.
This method is effectively the same as Storage.saveGroup(Group)
,
however, the Future returns void instead of a boolean flag.
Unlike the method in Storage
, when a group cannot be saved,
the future will be completed exceptionally
.
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)
This method is effectively the same as Storage.deleteGroup(Group)
,
however, the Future returns void instead of a boolean flag.
Unlike the method in Storage
, when a group cannot be deleted,
the future will be completed exceptionally
.
group
- the group to deleteNullPointerException
- if group is nullIllegalStateException
- if the group instance was not obtained from LuckPerms.@NonNull CompletableFuture<Void> loadAllGroups()
This method is effectively the same as Storage.loadAllTracks()
,
however, the Future returns void instead of a boolean flag.
Unlike the method in Storage
, when a group cannot be loaded,
the future will be completed exceptionally
.
@NonNull CompletableFuture<List<HeldPermission<String>>> getWithPermission(@NonNull String permission)
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 nulldefault @NonNull Optional<Group> getGroupOpt(@NonNull String name)
This method does not return null, unlike getGroup(java.lang.String)
name
- the name of the group to getGroup
objectNullPointerException
- if the name is nullboolean isLoaded(@NonNull String name)
name
- the name to check forNullPointerException
- if the name is null