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 |
|---|---|
CompletableFuture<Group> |
createAndLoadGroup(String name)
Creates a new group in the plugin's storage provider and then loads it
into memory.
|
CompletableFuture<Void> |
deleteGroup(Group group)
Permanently deletes a group from the plugin's storage provider.
|
Group |
getGroup(String name)
Gets a loaded group.
|
default Optional<Group> |
getGroupOpt(String name)
Gets a loaded group.
|
Set<Group> |
getLoadedGroups()
Gets a set of all loaded groups.
|
CompletableFuture<List<HeldPermission<String>>> |
getWithPermission(String permission)
Searches for a list of groups with a given permission.
|
boolean |
isLoaded(String name)
Check if a group is loaded in memory
|
CompletableFuture<Void> |
loadAllGroups()
Loads all groups into memory.
|
CompletableFuture<Optional<Group>> |
loadGroup(String name)
Loads a group from the plugin's storage provider into memory.
|
CompletableFuture<Void> |
saveGroup(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 null@Nonnull default 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 nullCopyright © 2018. All rights reserved.