Class DefaultPermissionProvider
- java.lang.Object
-
- de.dytanic.cloudnet.driver.provider.DefaultPermissionProvider
-
- All Implemented Interfaces:
PermissionProvider
public class DefaultPermissionProvider extends java.lang.Object implements PermissionProvider
-
-
Constructor Summary
Constructors Constructor Description DefaultPermissionProvider(java.util.function.Supplier<IPermissionManagement> permissionManagementSupplier)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddGroup(@NotNull IPermissionGroup permissionGroup)Adds a new permission group to the list of groups.@NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.lang.Void>addGroupAsync(@NotNull IPermissionGroup permissionGroup)Adds a new permission group to the list of groups.voidaddUser(@NotNull IPermissionUser permissionUser)Adds a new user to the database.@NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.lang.Void>addUserAsync(@NotNull IPermissionUser permissionUser)Adds a new user to the database.booleancontainsGroup(@NotNull java.lang.String group)Checks if a specific group exists.@NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.lang.Boolean>containsGroupAsync(@NotNull java.lang.String group)Checks if a specific group exists.booleancontainsUser(@NotNull java.lang.String name)Checks if at least one user with the given name is stored in the database.booleancontainsUser(@NotNull java.util.UUID uniqueId)Checks if a user with the given uniqueId is stored in the database.@NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.lang.Boolean>containsUserAsync(@NotNull java.lang.String name)Checks if at least one user with the given name is stored in the database.@NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.lang.Boolean>containsUserAsync(@NotNull java.util.UUID uniqueId)Checks if a user with the given uniqueId is stored in the database.voiddeleteGroup(@NotNull IPermissionGroup permissionGroup)Deletes a group by its name out of the list of groups.voiddeleteGroup(@NotNull java.lang.String name)Deletes a group by its name out of the list of groups.@NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.lang.Void>deleteGroupAsync(@NotNull IPermissionGroup permissionGroup)Deletes a group by its name out of the list of groups.@NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.lang.Void>deleteGroupAsync(@NotNull java.lang.String name)Deletes a group by its name out of the list of groups.voiddeleteUser(@NotNull IPermissionUser permissionUser)Deletes one user with the uniqueId of the given user.voiddeleteUser(@NotNull java.lang.String name)Deletes all users in the database matching the given name.@NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.lang.Void>deleteUserAsync(@NotNull IPermissionUser permissionUser)Deletes one user with the uniqueId of the given user.@NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.lang.Void>deleteUserAsync(@NotNull java.lang.String name)Deletes all users in the database matching the given name.@Nullable IPermissionGroupgetGroup(@NotNull java.lang.String name)Gets a specific group by its name.@NotNull de.dytanic.cloudnet.common.concurrent.ITask<IPermissionGroup>getGroupAsync(@NotNull java.lang.String name)Gets a specific group by its name.java.util.Collection<IPermissionGroup>getGroups()Gets the list of all groups in the Cloud.@NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.util.Collection<IPermissionGroup>>getGroupsAsync()Gets the list of all groups in the Cloud.@Nullable IPermissionUsergetUser(@NotNull java.util.UUID uniqueId)Gets a user with the given uniqueId out of the database.@NotNull de.dytanic.cloudnet.common.concurrent.ITask<IPermissionUser>getUserAsync(@NotNull java.util.UUID uniqueId)Gets a user with the given uniqueId out of the database.java.util.Collection<IPermissionUser>getUsers()Gets a list of all users stored in the database.java.util.List<IPermissionUser>getUsers(@NotNull java.lang.String name)Gets a list of all users with the given name out of the database.@NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.util.Collection<IPermissionUser>>getUsersAsync()Gets a list of all users stored in the database.@NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.util.List<IPermissionUser>>getUsersAsync(@NotNull java.lang.String name)Gets a list of all users with the given name out of the database.java.util.Collection<IPermissionUser>getUsersByGroup(@NotNull java.lang.String group)Gets a list of all users stored in the database with the given group.@NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.util.Collection<IPermissionUser>>getUsersByGroupAsync(@NotNull java.lang.String group)Gets a list of all users stored in the database with the given group.voidsetGroups(@NotNull java.util.Collection<? extends IPermissionGroup> groups)Clears all groups in the Cloud and sets given groups.@NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.lang.Void>setGroupsAsync(@NotNull java.util.Collection<? extends IPermissionGroup> groups)Clears all groups in the Cloud and sets given groups.voidsetUsers(@Nullable java.util.Collection<? extends IPermissionUser> users)Clears all users stored in the database and inserts the given list.@NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.lang.Void>setUsersAsync(@NotNull java.util.Collection<? extends IPermissionUser> users)Clears all users stored in the database and inserts the given list.voidupdateGroup(@NotNull IPermissionGroup permissionGroup)Updates a permission group in the list of groups.@NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.lang.Void>updateGroupAsync(@NotNull IPermissionGroup permissionGroup)Updates a permission group in the list of groups.voidupdateUser(@NotNull IPermissionUser permissionUser)Updates an already existing user in the database.@NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.lang.Void>updateUserAsync(@NotNull IPermissionUser permissionUser)Updates an already existing user in the database.
-
-
-
Constructor Detail
-
DefaultPermissionProvider
public DefaultPermissionProvider(java.util.function.Supplier<IPermissionManagement> permissionManagementSupplier)
-
-
Method Detail
-
addUser
public void addUser(@NotNull @NotNull IPermissionUser permissionUser)Description copied from interface:PermissionProviderAdds a new user to the database.- Specified by:
addUserin interfacePermissionProvider- Parameters:
permissionUser- the user to be added
-
updateUser
public void updateUser(@NotNull @NotNull IPermissionUser permissionUser)Description copied from interface:PermissionProviderUpdates an already existing user in the database.- Specified by:
updateUserin interfacePermissionProvider- Parameters:
permissionUser- the user to be updated
-
deleteUser
public void deleteUser(@NotNull @NotNull java.lang.String name)Description copied from interface:PermissionProviderDeletes all users in the database matching the given name. This method is case-sensitive.- Specified by:
deleteUserin interfacePermissionProvider- Parameters:
name- the name of the users to be deleted
-
deleteUser
public void deleteUser(@NotNull @NotNull IPermissionUser permissionUser)Description copied from interface:PermissionProviderDeletes one user with the uniqueId of the given user.- Specified by:
deleteUserin interfacePermissionProvider- Parameters:
permissionUser- the user to be deleted
-
containsUser
public boolean containsUser(@NotNull @NotNull java.util.UUID uniqueId)Description copied from interface:PermissionProviderChecks if a user with the given uniqueId is stored in the database.- Specified by:
containsUserin interfacePermissionProvider- Parameters:
uniqueId- the uniqueId of the user- Returns:
trueif there is a user with that uniqueId,falseotherwise
-
containsUser
public boolean containsUser(@NotNull @NotNull java.lang.String name)Description copied from interface:PermissionProviderChecks if at least one user with the given name is stored in the database. This method is case-sensitive.- Specified by:
containsUserin interfacePermissionProvider- Parameters:
name- the name of the user- Returns:
trueif there is a user with that name,falseotherwise
-
getUser
@Nullable public @Nullable IPermissionUser getUser(@NotNull @NotNull java.util.UUID uniqueId)
Description copied from interface:PermissionProviderGets a user with the given uniqueId out of the database.- Specified by:
getUserin interfacePermissionProvider- Parameters:
uniqueId- the uniqueId of the user- Returns:
- the
IPermissionUserfrom the database ornullif there is no user with that uniqueId stored
-
getUsers
public java.util.List<IPermissionUser> getUsers(@NotNull @NotNull java.lang.String name)
Description copied from interface:PermissionProviderGets a list of all users with the given name out of the database. This can only return null when the connection to the database (or when it is executed in a Wrapper instance the connection to the cloud) times out.- Specified by:
getUsersin interfacePermissionProvider- Parameters:
name- the name of the users- Returns:
- a list of all
IPermissionUsers stored in the database or an empty list if there is no user with that name stored.
-
getUsers
public java.util.Collection<IPermissionUser> getUsers()
Description copied from interface:PermissionProviderGets a list of all users stored in the database. This can only return null when the connection to the database (or when it is executed in a Wrapper instance the connection to the cloud) times out.This method shouldn't be used when there are many users stored in the database, because that takes a lot of memory.
- Specified by:
getUsersin interfacePermissionProvider- Returns:
- a list of all
IPermissionUsers stored in the database or an empty list if there is no user with that name stored.
-
setUsers
public void setUsers(@Nullable @Nullable java.util.Collection<? extends IPermissionUser> users)Description copied from interface:PermissionProviderClears all users stored in the database and inserts the given list.- Specified by:
setUsersin interfacePermissionProvider- Parameters:
users- the newIPermissionUsers to be stored in the database
-
getUsersByGroup
public java.util.Collection<IPermissionUser> getUsersByGroup(@NotNull @NotNull java.lang.String group)
Description copied from interface:PermissionProviderGets a list of all users stored in the database with the given group. This can only return null when the connection to the database (or when it is executed in a Wrapper instance the connection to the cloud) times out.This method shouldn't be used when there are many users with that group stored in the database, because that takes a lot of memory.
- Specified by:
getUsersByGroupin interfacePermissionProvider- Returns:
- a list of all
IPermissionUsers stored in the database or an empty list if there is no user with that name stored.
-
addGroup
public void addGroup(@NotNull @NotNull IPermissionGroup permissionGroup)Description copied from interface:PermissionProviderAdds a new permission group to the list of groups. If a group with that name already exists, it will be deleted and created again.- Specified by:
addGroupin interfacePermissionProvider- Parameters:
permissionGroup- theIPermissionGroupto be added
-
updateGroup
public void updateGroup(@NotNull @NotNull IPermissionGroup permissionGroup)Description copied from interface:PermissionProviderUpdates a permission group in the list of groups. If a group with that name doesn't exist, it will be created.- Specified by:
updateGroupin interfacePermissionProvider- Parameters:
permissionGroup- theIPermissionGroupto be updated
-
deleteGroup
public void deleteGroup(@NotNull @NotNull java.lang.String name)Description copied from interface:PermissionProviderDeletes a group by its name out of the list of groups. If a group with that name doesn't exist, nothing happens.- Specified by:
deleteGroupin interfacePermissionProvider- Parameters:
name- the case-sensitive name of the group
-
deleteGroup
public void deleteGroup(@NotNull @NotNull IPermissionGroup permissionGroup)Description copied from interface:PermissionProviderDeletes a group by its name out of the list of groups. If a group with that name doesn't exist, nothing happens.- Specified by:
deleteGroupin interfacePermissionProvider- Parameters:
permissionGroup- theIPermissionGroupto be deleted
-
containsGroup
public boolean containsGroup(@NotNull @NotNull java.lang.String group)Description copied from interface:PermissionProviderChecks if a specific group exists.- Specified by:
containsGroupin interfacePermissionProvider- Parameters:
group- the case-sensitive name of the group- Returns:
trueif the group exists,falseotherwise
-
getGroup
@Nullable public @Nullable IPermissionGroup getGroup(@NotNull @NotNull java.lang.String name)
Description copied from interface:PermissionProviderGets a specific group by its name.- Specified by:
getGroupin interfacePermissionProvider- Parameters:
name- the case-sensitive name of the group- Returns:
- the
IPermissionUserif it exists,nullotherwise
-
getGroups
public java.util.Collection<IPermissionGroup> getGroups()
Description copied from interface:PermissionProviderGets the list of all groups in the Cloud.- Specified by:
getGroupsin interfacePermissionProvider- Returns:
- a list of
IPermissionGroups registered in the cloud or an empty list if there is no group registered
-
setGroups
public void setGroups(@NotNull @NotNull java.util.Collection<? extends IPermissionGroup> groups)Description copied from interface:PermissionProviderClears all groups in the Cloud and sets given groups.- Specified by:
setGroupsin interfacePermissionProvider- Parameters:
groups- the new groups
-
addUserAsync
@NotNull public @NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.lang.Void> addUserAsync(@NotNull @NotNull IPermissionUser permissionUser)Description copied from interface:PermissionProviderAdds a new user to the database.- Specified by:
addUserAsyncin interfacePermissionProvider- Parameters:
permissionUser- the user to be added
-
updateUserAsync
@NotNull public @NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.lang.Void> updateUserAsync(@NotNull @NotNull IPermissionUser permissionUser)Description copied from interface:PermissionProviderUpdates an already existing user in the database.- Specified by:
updateUserAsyncin interfacePermissionProvider- Parameters:
permissionUser- the user to be updated
-
deleteUserAsync
@NotNull public @NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.lang.Void> deleteUserAsync(@NotNull @NotNull java.lang.String name)Description copied from interface:PermissionProviderDeletes all users in the database matching the given name. This method is case-sensitive.- Specified by:
deleteUserAsyncin interfacePermissionProvider- Parameters:
name- the name of the users to be deleted
-
deleteUserAsync
@NotNull public @NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.lang.Void> deleteUserAsync(@NotNull @NotNull IPermissionUser permissionUser)Description copied from interface:PermissionProviderDeletes one user with the uniqueId of the given user.- Specified by:
deleteUserAsyncin interfacePermissionProvider- Parameters:
permissionUser- the user to be deleted
-
containsUserAsync
@NotNull public @NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.lang.Boolean> containsUserAsync(@NotNull @NotNull java.util.UUID uniqueId)Description copied from interface:PermissionProviderChecks if a user with the given uniqueId is stored in the database.- Specified by:
containsUserAsyncin interfacePermissionProvider- Parameters:
uniqueId- the uniqueId of the user- Returns:
trueif there is a user with that uniqueId,falseotherwise
-
containsUserAsync
@NotNull public @NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.lang.Boolean> containsUserAsync(@NotNull @NotNull java.lang.String name)Description copied from interface:PermissionProviderChecks if at least one user with the given name is stored in the database. This method is case-sensitive.- Specified by:
containsUserAsyncin interfacePermissionProvider- Parameters:
name- the name of the user- Returns:
trueif there is a user with that name,falseotherwise
-
getUserAsync
@NotNull public @NotNull de.dytanic.cloudnet.common.concurrent.ITask<IPermissionUser> getUserAsync(@NotNull @NotNull java.util.UUID uniqueId)
Description copied from interface:PermissionProviderGets a user with the given uniqueId out of the database.- Specified by:
getUserAsyncin interfacePermissionProvider- Parameters:
uniqueId- the uniqueId of the user- Returns:
- the
IPermissionUserfrom the database ornullif there is no user with that uniqueId stored
-
getUsersAsync
@NotNull public @NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.util.List<IPermissionUser>> getUsersAsync(@NotNull @NotNull java.lang.String name)
Description copied from interface:PermissionProviderGets a list of all users with the given name out of the database. This can only return null when the connection to the database (or when it is executed in a Wrapper instance the connection to the cloud) times out.- Specified by:
getUsersAsyncin interfacePermissionProvider- Parameters:
name- the name of the users- Returns:
- a list of all
IPermissionUsers stored in the database or an empty list if there is no user with that name stored.
-
getUsersAsync
@NotNull public @NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.util.Collection<IPermissionUser>> getUsersAsync()
Description copied from interface:PermissionProviderGets a list of all users stored in the database. This can only return null when the connection to the database (or when it is executed in a Wrapper instance the connection to the cloud) times out.This method shouldn't be used when there are many users stored in the database, because that takes a lot of memory.
- Specified by:
getUsersAsyncin interfacePermissionProvider- Returns:
- a list of all
IPermissionUsers stored in the database or an empty list if there is no user with that name stored.
-
setUsersAsync
@NotNull public @NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.lang.Void> setUsersAsync(@NotNull @NotNull java.util.Collection<? extends IPermissionUser> users)Description copied from interface:PermissionProviderClears all users stored in the database and inserts the given list.- Specified by:
setUsersAsyncin interfacePermissionProvider- Parameters:
users- the newIPermissionUsers to be stored in the database
-
getUsersByGroupAsync
@NotNull public @NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.util.Collection<IPermissionUser>> getUsersByGroupAsync(@NotNull @NotNull java.lang.String group)
Description copied from interface:PermissionProviderGets a list of all users stored in the database with the given group. This can only return null when the connection to the database (or when it is executed in a Wrapper instance the connection to the cloud) times out.This method shouldn't be used when there are many users with that group stored in the database, because that takes a lot of memory.
- Specified by:
getUsersByGroupAsyncin interfacePermissionProvider- Returns:
- a list of all
IPermissionUsers stored in the database or an empty list if there is no user with that name stored.
-
addGroupAsync
@NotNull public @NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.lang.Void> addGroupAsync(@NotNull @NotNull IPermissionGroup permissionGroup)Description copied from interface:PermissionProviderAdds a new permission group to the list of groups. If a group with that name already exists, it will be deleted and created again.- Specified by:
addGroupAsyncin interfacePermissionProvider- Parameters:
permissionGroup- theIPermissionGroupto be added
-
updateGroupAsync
@NotNull public @NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.lang.Void> updateGroupAsync(@NotNull @NotNull IPermissionGroup permissionGroup)Description copied from interface:PermissionProviderUpdates a permission group in the list of groups. If a group with that name doesn't exist, it will be created.- Specified by:
updateGroupAsyncin interfacePermissionProvider- Parameters:
permissionGroup- theIPermissionGroupto be updated
-
deleteGroupAsync
@NotNull public @NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.lang.Void> deleteGroupAsync(@NotNull @NotNull java.lang.String name)Description copied from interface:PermissionProviderDeletes a group by its name out of the list of groups. If a group with that name doesn't exist, nothing happens.- Specified by:
deleteGroupAsyncin interfacePermissionProvider- Parameters:
name- the case-sensitive name of the group
-
deleteGroupAsync
@NotNull public @NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.lang.Void> deleteGroupAsync(@NotNull @NotNull IPermissionGroup permissionGroup)Description copied from interface:PermissionProviderDeletes a group by its name out of the list of groups. If a group with that name doesn't exist, nothing happens.- Specified by:
deleteGroupAsyncin interfacePermissionProvider- Parameters:
permissionGroup- theIPermissionGroupto be deleted
-
containsGroupAsync
@NotNull public @NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.lang.Boolean> containsGroupAsync(@NotNull @NotNull java.lang.String group)Description copied from interface:PermissionProviderChecks if a specific group exists.- Specified by:
containsGroupAsyncin interfacePermissionProvider- Parameters:
group- the case-sensitive name of the group- Returns:
trueif the group exists,falseotherwise
-
getGroupAsync
@NotNull public @NotNull de.dytanic.cloudnet.common.concurrent.ITask<IPermissionGroup> getGroupAsync(@NotNull @NotNull java.lang.String name)
Description copied from interface:PermissionProviderGets a specific group by its name.- Specified by:
getGroupAsyncin interfacePermissionProvider- Parameters:
name- the case-sensitive name of the group- Returns:
- the
IPermissionUserif it exists,nullotherwise
-
getGroupsAsync
@NotNull public @NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.util.Collection<IPermissionGroup>> getGroupsAsync()
Description copied from interface:PermissionProviderGets the list of all groups in the Cloud.- Specified by:
getGroupsAsyncin interfacePermissionProvider- Returns:
- a list of
IPermissionGroups registered in the cloud or an empty list if there is no group registered
-
setGroupsAsync
@NotNull public @NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.lang.Void> setGroupsAsync(@NotNull @NotNull java.util.Collection<? extends IPermissionGroup> groups)Description copied from interface:PermissionProviderClears all groups in the Cloud and sets given groups.- Specified by:
setGroupsAsyncin interfacePermissionProvider- Parameters:
groups- the new groups
-
-