Interface PermissionManagement
- All Known Subinterfaces:
CachedPermissionManagement
- All Known Implementing Classes:
DefaultCachedPermissionManagement,DefaultPermissionManagement
The main api point for accessing and managing permissions, permission users and permission groups. This management
contains some helpful methods to check a permissible for a certain permission and removing outdated permissions.
Updating the permissible is handled by the permission management too.
- Since:
- 4.0
-
Method Summary
Modifier and TypeMethodDescriptiondefault @NonNull eu.cloudnetservice.common.concurrent.Task<PermissionGroup>addGroupAsync(@NonNull String name, int potency) Creates a new permission group with the given name and potency.addPermissionGroup(@NonNull PermissionGroup permissionGroup) Stores the given permission group.addPermissionGroup(@NonNull String name, int potency) Creates a new permission group with the given name and potency.default @NonNull eu.cloudnetservice.common.concurrent.Task<PermissionGroup>addPermissionGroupAsync(@NonNull PermissionGroup permissionGroup) Stores the given permission group.addPermissionUser(@NonNull PermissionUser permissionUser) Inserts the given permission user into the database.addPermissionUser(@NonNull String name, @NonNull String password, int potency) Creates a new permission user and inserts it into the database.default @NonNull eu.cloudnetservice.common.concurrent.Task<PermissionUser>addPermissionUserAsync(@NonNull PermissionUser permissionUser) Inserts the given permission user into the database.default @NonNull eu.cloudnetservice.common.concurrent.Task<PermissionUser>addUserAsync(@NonNull String name, @NonNull String password, int potency) Creates a new permission user and inserts it into the database.allGroupPermissions(@NonNull Permissible permissible, @Nullable String group) Gets all permission of the specified permissible on the given group.allPermissions(@NonNull Permissible permissible) Gets all permission of the specified permissible.Gets the child permission management of this permission management.voidclose()Closes the permission management.booleancontainsGroup(@NonNull String group) Checks if the given group exists.containsGroupAsync(@NonNull String group) Checks if the given group exists.booleancontainsOneUser(@NonNull String name) Checks if at least one user with the given name is stored in the database.Checks if at least one user with the given name is stored in the database.booleancontainsUser(@NonNull UUID uniqueId) Checks if a user with the given unique id is stored in the database.containsUserAsync(@NonNull UUID uniqueId) Checks if a user with the given unique id is stored in the database.Gets the default permission group.default @NonNull eu.cloudnetservice.common.concurrent.Task<PermissionGroup>Gets the default permission group.booleandeleteGroup(@NonNull String name) Deletes the group by the given name.deleteGroupAsync(@NonNull String name) Deletes the group by the given name.booleandeletePermissionGroup(@NonNull PermissionGroup permissionGroup) Deletes the given permission group.deletePermissionGroupAsync(@NonNull PermissionGroup permissionGroup) Deletes the given permission group.booleandeletePermissionUser(@NonNull PermissionUser permissionUser) Deletes the given user from the database.deletePermissionUserAsync(@NonNull PermissionUser permissionUser) Deletes the given user from the database.booleandeleteUser(@NonNull String name) Deletes all users in the database matching the given name.deleteUserAsync(@NonNull String name) Deletes all users in the database matching the given name.findHighestPermission(@NonNull Collection<Permission> permissions, @NonNull Permission permission) Finds the highest permission (sorted by the potency) in the given permission collection using the given permission potency as the starting point.Searches all users matching the given name and selecting the first one.default @NonNull eu.cloudnetservice.common.concurrent.Task<PermissionUser>firstUserAsync(String name) Searches all users matching the given name and selecting the first one.getOrCreateUser(@NonNull UUID uniqueId, @NonNull String name) Searches the database for a permission user with the given unique id.default @NonNull eu.cloudnetservice.common.concurrent.Task<PermissionUser>getOrCreateUserAsync(@NonNull UUID uniqueId, @NonNull String name) Searches the database for a permission user with the given unique id.Gets the permission group by the given name.default @NonNull eu.cloudnetservice.common.concurrent.Task<PermissionGroup>groupAsync(@NonNull String name) Gets the permission group by the given name.groupPermissionResult(@NonNull Permissible permissible, @NonNull String group, @NonNull Permission permission) Checks if the given permissible has the given permission for the given group.groups()Gets all known permission groups.voidgroups(@Nullable Collection<PermissionGroup> groups) Overwrites all known groups with the given collection of groups.default @NonNull eu.cloudnetservice.common.concurrent.Task<Collection<PermissionGroup>>Gets all known permission groups.groupsAsync(@Nullable Collection<PermissionGroup> groups) Overwrites all known groups with the given collection of groups.groupsOf(@Nullable Permissible permissible) Gets all groups that are associated with the given permissible.default @NonNull eu.cloudnetservice.common.concurrent.Task<Collection<PermissionGroup>>groupsOfAsync(@Nullable Permissible permissible) Gets all groups that are associated with the given permissible.groupsPermissionResult(@NonNull Permissible permissible, @NonNull String[] groups, @NonNull Permission permission) Checks if the given permissible has the given permission for the given groups.default booleanhasGroupPermission(@NonNull Permissible permissible, @NonNull String group, @NonNull Permission permission) Checks if the given permissible has the given permission for the given group.default booleanhasPermission(@NonNull Permissible permissible, @NonNull Permission permission) Checks if the given permissible or any group that is associated with the permissible has the permission, and it is not overriden by another permission with a negative potency.highestPermissionGroup(@NonNull PermissionUser permissionUser) Gets the highest permission group for the given user.voidinit()Initializes this permission management.modifyGroup(@NonNull String name, @NonNull BiConsumer<PermissionGroup, PermissionGroup.Builder> modifier) Gets the permission group with the given name by usinggroup(String)and, if not null, puts it into the consumer, after that, the group will be updated by usingupdateGroup(PermissionGroup).default @NonNull eu.cloudnetservice.common.concurrent.Task<PermissionGroup>modifyGroupAsync(@NonNull String name, @NonNull BiConsumer<PermissionGroup, PermissionGroup.Builder> modifier) Gets the permission group with the given name by usinggroup(String)and, if not null, puts it into the consumer, after that, the group will be updated by usingupdateGroup(PermissionGroup).modifyUser(@NonNull UUID uniqueId, @NonNull BiConsumer<PermissionUser, PermissionUser.Builder> modifier) Gets the permission user with the given unique id usinguser(UUID)and, if not null, puts them into the consumer, after that, the user will be updated by usingupdateUser(PermissionUser).default @NonNull eu.cloudnetservice.common.concurrent.Task<PermissionUser>modifyUserAsync(@NonNull UUID uniqueId, @NonNull BiConsumer<PermissionUser, PermissionUser.Builder> modifier) Gets the permission user with the given unique id usinguser(UUID)and, if not null, puts them into the consumer, after that, the user will be updated by usingupdateUser(PermissionUser).modifyUsers(@NonNull String name, @NonNull BiConsumer<PermissionUser, PermissionUser.Builder> modifier) Gets every user matching the given name usingusersByName(String)and puts them into the consumer, after that, every user will be updated by usingupdateUser(PermissionUser).default @NonNull eu.cloudnetservice.common.concurrent.Task<List<PermissionUser>>modifyUsersAsync(@NonNull String name, @NonNull BiConsumer<PermissionUser, PermissionUser.Builder> modifier) Gets every user matching the given name usingusersByName(String)and puts them into the consumer, after that, every user will be updated by usingupdateUser(PermissionUser).permissionResult(@NonNull Permissible permissible, @NonNull Permission permission) Checks if the given permissible or any group that is associated with the permissible has the permission, and it is not overriden by another permission with a negative potency.booleanreload()Reloads this permission management.sendCommandLine(@NonNull PermissionUser user, @NonNull String commandLine) Sends a command line to the node the method is called on or the node the wrapper is connected to.default @NonNull eu.cloudnetservice.common.concurrent.Task<Collection<String>>sendCommandLineAsync(@NonNull PermissionUser user, @NonNull String commandLine) Sends a command line to the node the method is called on or the node the wrapper is connected to.booleantestPermissible(@Nullable Permissible permissible) Removes the timed-out permissions of the given permissible.booleantestPermissionUser(@Nullable PermissionUser permissionUser) Removes all timed-out permissions and groups of the given permission user.voidupdateGroup(@NonNull PermissionGroup permissionGroup) Updates the given permission group.updateGroupAsync(@NonNull PermissionGroup permissionGroup) Updates the given permission group.voidupdateUser(@NonNull PermissionUser permissionUser) Updates the given permission user in the database.updateUserAsync(@NonNull PermissionUser permissionUser) Updates the given permission user in the database.Searches for the user with the given unique id.default @NonNull eu.cloudnetservice.common.concurrent.Task<PermissionUser>Searches for the user with the given unique id.users()Gets a list of all stored permission users in the database.default @NonNull eu.cloudnetservice.common.concurrent.Task<Collection<PermissionUser>>Gets a list of all stored permission users in the database.usersByGroup(@NonNull String group) Gets a list of all stored permission users in the database that are in the given group.default @NonNull eu.cloudnetservice.common.concurrent.Task<Collection<PermissionUser>>usersByGroupAsync(@NonNull String group) Gets a list of all stored permission users in the database that are in the given group.usersByName(@NonNull String name) Gets a list of all users with the given name out of the database.default @NonNull eu.cloudnetservice.common.concurrent.Task<List<PermissionUser>>usersByNameAsync(@NonNull String name) Gets a list of all users with the given name out of the database.
-
Method Details
-
childPermissionManagement
Gets the child permission management of this permission management. The child is null if there is no child permission management.- Returns:
- the child management, null if there is no child.
-
init
void init()Initializes this permission management. -
close
void close()Closes the permission management. -
reload
boolean reload()Reloads this permission management.- Returns:
- true if reloading was successful, false otherwise.
-
testPermissionUser
Removes all timed-out permissions and groups of the given permission user.- Parameters:
permissionUser- the permission user to check.- Returns:
- true if at least one permission was removed, false otherwise.
-
testPermissible
Removes the timed-out permissions of the given permissible.- Parameters:
permissible- the permissible to check.- Returns:
- true if at least one permission was removed, false otherwise.
-
addPermissionUser
@NonNull @NonNull PermissionUser addPermissionUser(@NonNull @NonNull String name, @NonNull @NonNull String password, int potency) Creates a new permission user and inserts it into the database. If the there already is a user in the database the user is updated.- Parameters:
name- the name of the new user.password- the password of the new user.potency- the potency of the new user.- Returns:
- the newly created permission user.
- Throws:
NullPointerException- if the given name or password is null.
-
addPermissionUser
Inserts the given permission user into the database. If there already is a permission user with the same unique id the old one is replaced by the given permission user.- Parameters:
permissionUser- the user to add.- Returns:
- the same instance that was given.
- Throws:
NullPointerException- if the given user is null.
-
groupsOf
Gets all groups that are associated with the given permissible.- Parameters:
permissible- the permissible to retrieve the groups for.- Returns:
- all found groups.
-
hasPermission
default boolean hasPermission(@NonNull @NonNull Permissible permissible, @NonNull @NonNull Permission permission) Checks if the given permissible or any group that is associated with the permissible has the permission, and it is not overriden by another permission with a negative potency.- Parameters:
permissible- the permissible to check if the permission is set.permission- the permission to check for.- Returns:
- true if the permissible has the permission, false otherwise.
- Throws:
NullPointerException- if the given permissible or permission is null.- See Also:
-
hasGroupPermission
default boolean hasGroupPermission(@NonNull @NonNull Permissible permissible, @NonNull @NonNull String group, @NonNull @NonNull Permission permission) Checks if the given permissible has the given permission for the given group.- Parameters:
permissible- the permissible to check if the permission is set.group- the group that the permission is assigned to.permission- the permission to check.- Returns:
- true if the permissible has the permission on the given group, false otherwise.
- Throws:
NullPointerException- if the given permissible, group or permission is null.- See Also:
-
permissionResult
@NonNull @NonNull PermissionCheckResult permissionResult(@NonNull @NonNull Permissible permissible, @NonNull @NonNull Permission permission) Checks if the given permissible or any group that is associated with the permissible has the permission, and it is not overriden by another permission with a negative potency.- Parameters:
permissible- the permissible to check if the permission is set.permission- the permission to check.- Returns:
- the result of the permission check.
- Throws:
NullPointerException- if the given permissible or permission is null.
-
groupPermissionResult
@NonNull @NonNull PermissionCheckResult groupPermissionResult(@NonNull @NonNull Permissible permissible, @NonNull @NonNull String group, @NonNull @NonNull Permission permission) Checks if the given permissible has the given permission for the given group.- Parameters:
permissible- the permissible to check if the permission is set.group- the group to get the permissions on.permission- the permission to check.- Returns:
- the result of the permission check.
- Throws:
NullPointerException- if the given permissible, group or permission is null.
-
groupsPermissionResult
@NonNull @NonNull PermissionCheckResult groupsPermissionResult(@NonNull @NonNull Permissible permissible, @NonNull @NonNull String[] groups, @NonNull @NonNull Permission permission) Checks if the given permissible has the given permission for the given groups.- Parameters:
permissible- the permissible to check if the permission is set.groups- the groups to get the permissions on.permission- the permission to check.- Returns:
- the result of the permission check.
- Throws:
NullPointerException- if the given permissible, groups or permission is null.
-
findHighestPermission
@Nullable @Nullable Permission findHighestPermission(@NonNull @NonNull Collection<Permission> permissions, @NonNull @NonNull Permission permission) Finds the highest permission (sorted by the potency) in the given permission collection using the given permission potency as the starting point.- Parameters:
permissions- the permissions to check through.permission- the starting point for the check to run.- Returns:
- the highest permission in the given permission or null if there is no permission with a higher potency in the given collection.
- Throws:
NullPointerException- if the given permissions or permission is null.
-
allPermissions
Gets all permission of the specified permissible.- Parameters:
permissible- the permissible to get the permission of.- Returns:
- all permissions of the permissible.
- Throws:
NullPointerException- if the given permissible is null.
-
allGroupPermissions
@NonNull @NonNull Collection<Permission> allGroupPermissions(@NonNull @NonNull Permissible permissible, @Nullable @Nullable String group) Gets all permission of the specified permissible on the given group.- Parameters:
permissible- the permissible to get the permission of.group- the group to get the permission on or null if no specific group should be used.- Returns:
- all permissions of the permissible on the specified group if provided.
- Throws:
NullPointerException- if the given permissible or group is null.
-
updateUser
Updates the given permission user in the database. If there is no user with the unique id the user is just inserted into the database.- Parameters:
permissionUser- the user to update in the database.- Throws:
NullPointerException- if the given user is null.
-
deleteUser
Deletes all users in the database matching the given name. The given name is case-sensitive.- Parameters:
name- the name of the users to be deleted- Returns:
- true if any user was deleted, false if none was deleted.
- Throws:
NullPointerException- if the given name is null.
-
deletePermissionUser
Deletes the given user from the database.- Parameters:
permissionUser- the user to delete from the database.- Returns:
- if there was a user with the unique id of the given user, false otherwise.
- Throws:
NullPointerException- if the given user is null.
-
containsUser
Checks if a user with the given unique id is stored in the database.- Parameters:
uniqueId- the unique id of the user.- Returns:
- true if there is a user with the given unique id, false otherwise.
- Throws:
NullPointerException- if the given unique id is null.
-
containsOneUser
Checks if at least one user with the given name is stored in the database. This given name is case-sensitive.- Parameters:
name- the name of the user- Returns:
- true if there is a user with that name, false otherwise
- Throws:
NullPointerException- if the given name is null.
-
user
Searches for the user with the given unique id.- Parameters:
uniqueId- the unique id of the user.- Returns:
- the found permission user, null if no user was found.
- Throws:
NullPointerException- if the given unique id is null.
-
getOrCreateUser
@NonNull @NonNull PermissionUser getOrCreateUser(@NonNull @NonNull UUID uniqueId, @NonNull @NonNull String name) Searches the database for a permission user with the given unique id. If no user with the given id is found a new user is stored in the database.The given name is not used to search for the user.
- Parameters:
uniqueId- the uniqueId of the user.name- the name of the user.- Returns:
- the found or created permission user.
- Throws:
NullPointerException- if the given unique id or name is null.
-
firstUser
Searches all users matching the given name and selecting the first one.- Parameters:
name- the name of the user to search.- Returns:
- the found user or null if no user with this name exists.
- Throws:
NullPointerException- if the given name is null.
-
usersByName
Gets a list of all users with the given name out of the database.- Parameters:
name- the name to search in the database for.- Returns:
- all found users that have the given name.
- Throws:
NullPointerException- if the given name is null.
-
users
Gets a list of all stored permission users in the database.Note: If there are many users in the database this might lead to memory issues as all of them are loaded into memory.
- Returns:
- all permission users.
-
usersByGroup
Gets a list of all stored permission users in the database that are in the given group.Note: If there are many users in the database this might lead to memory issues as all of them are loaded into memory.
- Returns:
- all permission users in the given group.
- Throws:
NullPointerException- if the given group is null.
-
defaultPermissionGroup
Gets the default permission group. The default group is determined by thePermissionGroup.defaultGroup()property. If multiple groups are the default group this method might return another result for each call.- Returns:
- the default permission group, null if no group is marked as default.
-
highestPermissionGroup
@Nullable @Nullable PermissionGroup highestPermissionGroup(@NonNull @NonNull PermissionUser permissionUser) Gets the highest permission group for the given user. The highest permission group is determined by the potency of the group. A higher potency results in the highest group.- Parameters:
permissionUser- the user to get the group for.- Returns:
- the highest permission group, null if the user is not in any group and there is no default group.
- Throws:
NullPointerException- if the given user is null.
-
addPermissionGroup
Creates a new permission group with the given name and potency. If there already is group with the given name the old group is replaced by the newly created one.- Parameters:
name- the case-sensitive name of the new group.potency- the potency of the new group.- Returns:
- the newly created permission group.
- Throws:
NullPointerException- if the given name is null.
-
addPermissionGroup
@NonNull @NonNull PermissionGroup addPermissionGroup(@NonNull @NonNull PermissionGroup permissionGroup) Stores the given permission group. If there already is a group with the same name the old group is replaced by the given one.- Parameters:
permissionGroup- the group to add.- Returns:
- the same instance that was given.
- Throws:
NullPointerException- if the given permission group is null.
-
updateGroup
Updates the given permission group. If there is no group with the given name the group is added.- Parameters:
permissionGroup- the group to update.- Throws:
NullPointerException- if the given permission group is null.
-
deleteGroup
Deletes the group by the given name.- Parameters:
name- the name of the group to delete.- Returns:
- true if a group with the name was found and deleted, false otherwise.
- Throws:
NullPointerException- if the given name is null.
-
deletePermissionGroup
Deletes the given permission group.- Parameters:
permissionGroup- the permission group to delete.- Returns:
- always true as the group is already present.
- Throws:
NullPointerException- if the given group is null.
-
containsGroup
Checks if the given group exists.- Parameters:
group- the case-sensitive name of the group.- Returns:
- true if the group exists, false otherwise.
- Throws:
NullPointerException- if the given group is null.
-
group
Gets the permission group by the given name.- Parameters:
name- the case-sensitive name of the group.- Returns:
- the permission group with the given name, null if there is no group with the given name.
- Throws:
NullPointerException- if the given name is null.
-
groups
Gets all known permission groups.- Returns:
- all permissions groups.
-
groups
Overwrites all known groups with the given collection of groups. Null is allowed and results in the removal of all groups without a replacement.- Parameters:
groups- the groups to add after clearing all other groups.
-
modifyGroup
@Nullable @Nullable PermissionGroup modifyGroup(@NonNull @NonNull String name, @NonNull @NonNull BiConsumer<PermissionGroup, PermissionGroup.Builder> modifier) Gets the permission group with the given name by usinggroup(String)and, if not null, puts it into the consumer, after that, the group will be updated by usingupdateGroup(PermissionGroup).- Parameters:
name- the name of the group.modifier- the consumer to modify the user.- Returns:
- the modified group, null if no group was found with the given name.
- Throws:
NullPointerException- if the given name or consumer is null.
-
modifyUser
@Nullable @Nullable PermissionUser modifyUser(@NonNull @NonNull UUID uniqueId, @NonNull @NonNull BiConsumer<PermissionUser, PermissionUser.Builder> modifier) Gets the permission user with the given unique id usinguser(UUID)and, if not null, puts them into the consumer, after that, the user will be updated by usingupdateUser(PermissionUser).- Parameters:
uniqueId- the unique id of the usermodifier- the consumer to modify the user- Returns:
- the modified user, null if no user was found with the given unique id.
- Throws:
NullPointerException- if the given unique id or consumer is null.
-
modifyUsers
@NonNull @NonNull List<PermissionUser> modifyUsers(@NonNull @NonNull String name, @NonNull @NonNull BiConsumer<PermissionUser, PermissionUser.Builder> modifier) Gets every user matching the given name usingusersByName(String)and puts them into the consumer, after that, every user will be updated by usingupdateUser(PermissionUser).- Parameters:
name- the name of the users.modifier- the consumer to modify the available users.- Returns:
- a list containing all modified users.
- Throws:
NullPointerException- if the given name or consumer is null.
-
sendCommandLine
@NonNull @NonNull Collection<String> sendCommandLine(@NonNull @NonNull PermissionUser user, @NonNull @NonNull String commandLine) Sends a command line to the node the method is called on or the node the wrapper is connected to. The command line is executed and all resulting messages are collected in the collection of strings.- Parameters:
user- the user to execute the command line with.commandLine- the command line to execute on the node.- Returns:
- all messages regarding the command execution.
- Throws:
NullPointerException- if the given user or command line is null.
-
groupsOfAsync
@NonNull default @NonNull eu.cloudnetservice.common.concurrent.Task<Collection<PermissionGroup>> groupsOfAsync(@Nullable @Nullable Permissible permissible) Gets all groups that are associated with the given permissible.- Parameters:
permissible- the permissible to retrieve the groups for.- Returns:
- a task containing all found groups.
-
addPermissionUserAsync
@NonNull default @NonNull eu.cloudnetservice.common.concurrent.Task<PermissionUser> addPermissionUserAsync(@NonNull @NonNull PermissionUser permissionUser) Inserts the given permission user into the database. If there already is a permission user with the same unique id the old one is replaced by the given permission user.- Parameters:
permissionUser- the user to add.- Returns:
- a task containing the same instance that was given.
- Throws:
NullPointerException- if the given user is null.
-
addUserAsync
@NonNull default @NonNull eu.cloudnetservice.common.concurrent.Task<PermissionUser> addUserAsync(@NonNull @NonNull String name, @NonNull @NonNull String password, int potency) Creates a new permission user and inserts it into the database. If the there already is a user in the database the user is updated.- Parameters:
name- the name of the new user.password- the password of the new user.potency- the potency of the new user.- Returns:
- a task containing the newly created permission user.
- Throws:
NullPointerException- if the given name or password is null.
-
updateUserAsync
@NonNull default @NonNull eu.cloudnetservice.common.concurrent.Task<Void> updateUserAsync(@NonNull @NonNull PermissionUser permissionUser) Updates the given permission user in the database. If there is no user with the unique id the user is just inserted into the database.- Parameters:
permissionUser- the user to update in the database.- Returns:
- a task that completes when the user was updated.
- Throws:
NullPointerException- if the given user is null.
-
deleteUserAsync
@NonNull default @NonNull eu.cloudnetservice.common.concurrent.Task<Boolean> deleteUserAsync(@NonNull @NonNull String name) Deletes all users in the database matching the given name. The given name is case-sensitive.- Parameters:
name- the name of the users to be deleted- Returns:
- a task containing true if any user was deleted, false if none was deleted.
- Throws:
NullPointerException- if the given name is null.
-
deletePermissionUserAsync
@NonNull default @NonNull eu.cloudnetservice.common.concurrent.Task<Boolean> deletePermissionUserAsync(@NonNull @NonNull PermissionUser permissionUser) Deletes the given user from the database.- Parameters:
permissionUser- the user to delete from the database.- Returns:
- a task containing if there was a user with the unique id of the given user, false otherwise.
- Throws:
NullPointerException- if the given user is null.
-
containsUserAsync
@NonNull default @NonNull eu.cloudnetservice.common.concurrent.Task<Boolean> containsUserAsync(@NonNull @NonNull UUID uniqueId) Checks if a user with the given unique id is stored in the database.- Parameters:
uniqueId- the unique id of the user.- Returns:
- a task containing true if there is a user with the given unique id, false otherwise.
- Throws:
NullPointerException- if the given unique id is null.
-
containsOneUserAsync
@NonNull default @NonNull eu.cloudnetservice.common.concurrent.Task<Boolean> containsOneUserAsync(@NonNull @NonNull String name) Checks if at least one user with the given name is stored in the database. This given name is case-sensitive.- Parameters:
name- the name of the user- Returns:
- a task containing true if there is a user with that name, false otherwise
- Throws:
NullPointerException- if the given name is null.
-
userAsync
@NonNull default @NonNull eu.cloudnetservice.common.concurrent.Task<PermissionUser> userAsync(@NonNull @NonNull UUID uniqueId) Searches for the user with the given unique id.- Parameters:
uniqueId- the unique id of the user.- Returns:
- a task containing the found permission user, null if no user was found.
- Throws:
NullPointerException- if the given unique id is null.
-
getOrCreateUserAsync
@NonNull default @NonNull eu.cloudnetservice.common.concurrent.Task<PermissionUser> getOrCreateUserAsync(@NonNull @NonNull UUID uniqueId, @NonNull @NonNull String name) Searches the database for a permission user with the given unique id. If no user with the given id is found a new user is stored in the database.The given name is not used to search for the user.
- Parameters:
uniqueId- the uniqueId of the user.name- the name of the user.- Returns:
- a task containing the found or created permission user.
- Throws:
NullPointerException- if the given unique id or name is null.
-
usersByNameAsync
@NonNull default @NonNull eu.cloudnetservice.common.concurrent.Task<List<PermissionUser>> usersByNameAsync(@NonNull @NonNull String name) Gets a list of all users with the given name out of the database.- Parameters:
name- the name to search in the database for.- Returns:
- a task containing all found users that have the given name.
- Throws:
NullPointerException- if the given name is null.
-
firstUserAsync
@NonNull default @NonNull eu.cloudnetservice.common.concurrent.Task<PermissionUser> firstUserAsync(String name) Searches all users matching the given name and selecting the first one.- Parameters:
name- the name of the user to search.- Returns:
- a task containing the found user or null if no user with this name exists.
- Throws:
NullPointerException- if the given name is null.
-
usersAsync
@NonNull default @NonNull eu.cloudnetservice.common.concurrent.Task<Collection<PermissionUser>> usersAsync()Gets a list of all stored permission users in the database.Note: If there are many users in the database this might lead to memory issues as all of them are loaded into memory.
- Returns:
- a task containing all permission users.
-
usersByGroupAsync
@NonNull default @NonNull eu.cloudnetservice.common.concurrent.Task<Collection<PermissionUser>> usersByGroupAsync(@NonNull @NonNull String group) Gets a list of all stored permission users in the database that are in the given group.Note: If there are many users in the database this might lead to memory issues as all of them are loaded into memory.
- Returns:
- a task containing all permission users in the given group.
- Throws:
NullPointerException- if the given group is null.
-
addPermissionGroupAsync
@NonNull default @NonNull eu.cloudnetservice.common.concurrent.Task<PermissionGroup> addPermissionGroupAsync(@NonNull @NonNull PermissionGroup permissionGroup) Stores the given permission group. If there already is a group with the same name the old group is replaced by the given one.- Parameters:
permissionGroup- the group to add.- Returns:
- a task containing the same instance that was given.
- Throws:
NullPointerException- if the given permission group is null.
-
addGroupAsync
@NonNull default @NonNull eu.cloudnetservice.common.concurrent.Task<PermissionGroup> addGroupAsync(@NonNull @NonNull String name, int potency) Creates a new permission group with the given name and potency. If there already is group with the given name the old group is replaced by the newly created one.- Parameters:
name- the case-sensitive name of the new group.potency- the potency of the new group.- Returns:
- a task containing the newly created permission group.
- Throws:
NullPointerException- if the given name is null.
-
updateGroupAsync
@NonNull default @NonNull eu.cloudnetservice.common.concurrent.Task<Void> updateGroupAsync(@NonNull @NonNull PermissionGroup permissionGroup) Updates the given permission group. If there is no group with the given name the group is added.- Parameters:
permissionGroup- the group to update.- Returns:
- a task that completes after the group is updated.
- Throws:
NullPointerException- if the given permission group is null.
-
deleteGroupAsync
@NonNull default @NonNull eu.cloudnetservice.common.concurrent.Task<Boolean> deleteGroupAsync(@NonNull @NonNull String name) Deletes the group by the given name.- Parameters:
name- the name of the group to delete.- Returns:
- a task containing true if a group with the name was found and deleted, false otherwise.
- Throws:
NullPointerException- if the given name is null.
-
deletePermissionGroupAsync
@NonNull default @NonNull eu.cloudnetservice.common.concurrent.Task<Boolean> deletePermissionGroupAsync(@NonNull @NonNull PermissionGroup permissionGroup) Deletes the given permission group.- Parameters:
permissionGroup- the permission group to delete.- Returns:
- a task containing always true as the group is already present.
- Throws:
NullPointerException- if the given group is null.
-
containsGroupAsync
@NonNull default @NonNull eu.cloudnetservice.common.concurrent.Task<Boolean> containsGroupAsync(@NonNull @NonNull String group) Checks if the given group exists.- Parameters:
group- the case-sensitive name of the group.- Returns:
- a task containing true if the group exists, false otherwise.
- Throws:
NullPointerException- if the given group is null.
-
groupAsync
@NonNull default @NonNull eu.cloudnetservice.common.concurrent.Task<PermissionGroup> groupAsync(@NonNull @NonNull String name) Gets the permission group by the given name.- Parameters:
name- the case-sensitive name of the group.- Returns:
- a task containing the permission group with the given name, null if there is no group with the given name.
- Throws:
NullPointerException- if the given name is null.
-
defaultPermissionGroupAsync
@NonNull default @NonNull eu.cloudnetservice.common.concurrent.Task<PermissionGroup> defaultPermissionGroupAsync()Gets the default permission group. The default group is determined by thePermissionGroup.defaultGroup()property. If multiple groups are the default group this method might return another result for each call.- Returns:
- a task containing the default permission group, null if no group is marked as default.
-
groupsAsync
@NonNull default @NonNull eu.cloudnetservice.common.concurrent.Task<Collection<PermissionGroup>> groupsAsync()Gets all known permission groups.- Returns:
- a task containing all permissions groups.
-
groupsAsync
@NonNull default @NonNull eu.cloudnetservice.common.concurrent.Task<Void> groupsAsync(@Nullable @Nullable Collection<PermissionGroup> groups) Overwrites all known groups with the given collection of groups. Null is allowed and results in the removal of all groups without a replacement.- Parameters:
groups- the groups to add after clearing all other groups.- Returns:
- a task that completes after the groups were replaced.
-
modifyGroupAsync
@NonNull default @NonNull eu.cloudnetservice.common.concurrent.Task<PermissionGroup> modifyGroupAsync(@NonNull @NonNull String name, @NonNull @NonNull BiConsumer<PermissionGroup, PermissionGroup.Builder> modifier) Gets the permission group with the given name by usinggroup(String)and, if not null, puts it into the consumer, after that, the group will be updated by usingupdateGroup(PermissionGroup).- Parameters:
name- the name of the group.modifier- the consumer to modify the user.- Returns:
- a task containing the modified group, null if no group was found with the given name.
- Throws:
NullPointerException- if the given name or consumer is null.
-
modifyUserAsync
@NonNull default @NonNull eu.cloudnetservice.common.concurrent.Task<PermissionUser> modifyUserAsync(@NonNull @NonNull UUID uniqueId, @NonNull @NonNull BiConsumer<PermissionUser, PermissionUser.Builder> modifier) Gets the permission user with the given unique id usinguser(UUID)and, if not null, puts them into the consumer, after that, the user will be updated by usingupdateUser(PermissionUser).- Parameters:
uniqueId- the unique id of the usermodifier- the consumer to modify the user- Returns:
- a task containing the modified user, null if no user was found with the given unique id.
- Throws:
NullPointerException- if the given unique id or consumer is null.
-
modifyUsersAsync
@NonNull default @NonNull eu.cloudnetservice.common.concurrent.Task<List<PermissionUser>> modifyUsersAsync(@NonNull @NonNull String name, @NonNull @NonNull BiConsumer<PermissionUser, PermissionUser.Builder> modifier) Gets every user matching the given name usingusersByName(String)and puts them into the consumer, after that, every user will be updated by usingupdateUser(PermissionUser).- Parameters:
name- the name of the users.modifier- the consumer to modify the available users.- Returns:
- a task containing a list containing all modified users.
- Throws:
NullPointerException- if the given name or consumer is null.
-
sendCommandLineAsync
@NonNull default @NonNull eu.cloudnetservice.common.concurrent.Task<Collection<String>> sendCommandLineAsync(@NonNull @NonNull PermissionUser user, @NonNull @NonNull String commandLine) Sends a command line to the node the method is called on or the node the wrapper is connected to. The command line is executed and all resulting messages are collected in the collection of strings.- Parameters:
user- the user to execute the command line with.commandLine- the command line to execute on the node.- Returns:
- a task containing all messages regarding the command execution.
- Throws:
NullPointerException- if the given user or command line is null.
-