Class DefaultPermissionProvider

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addGroup​(@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.
      void addUser​(@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.
      boolean containsGroup​(@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.
      boolean containsUser​(@NotNull java.lang.String name)
      Checks if at least one user with the given name is stored in the database.
      boolean containsUser​(@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.
      void deleteGroup​(@NotNull IPermissionGroup permissionGroup)
      Deletes a group by its name out of the list of groups.
      void deleteGroup​(@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.
      void deleteUser​(@NotNull IPermissionUser permissionUser)
      Deletes one user with the uniqueId of the given user.
      void deleteUser​(@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 IPermissionGroup getGroup​(@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 IPermissionUser getUser​(@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.
      void setGroups​(@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.
      void setUsers​(@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.
      void updateGroup​(@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.
      void updateUser​(@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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DefaultPermissionProvider

        public DefaultPermissionProvider​(java.util.function.Supplier<IPermissionManagement> permissionManagementSupplier)
    • Method Detail

      • updateUser

        public void updateUser​(@NotNull
                               @NotNull IPermissionUser permissionUser)
        Description copied from interface: PermissionProvider
        Updates an already existing user in the database.
        Specified by:
        updateUser in interface PermissionProvider
        Parameters:
        permissionUser - the user to be updated
      • deleteUser

        public void deleteUser​(@NotNull
                               @NotNull java.lang.String name)
        Description copied from interface: PermissionProvider
        Deletes all users in the database matching the given name. This method is case-sensitive.
        Specified by:
        deleteUser in interface PermissionProvider
        Parameters:
        name - the name of the users to be deleted
      • deleteUser

        public void deleteUser​(@NotNull
                               @NotNull IPermissionUser permissionUser)
        Description copied from interface: PermissionProvider
        Deletes one user with the uniqueId of the given user.
        Specified by:
        deleteUser in interface PermissionProvider
        Parameters:
        permissionUser - the user to be deleted
      • containsUser

        public boolean containsUser​(@NotNull
                                    @NotNull java.util.UUID uniqueId)
        Description copied from interface: PermissionProvider
        Checks if a user with the given uniqueId is stored in the database.
        Specified by:
        containsUser in interface PermissionProvider
        Parameters:
        uniqueId - the uniqueId of the user
        Returns:
        true if there is a user with that uniqueId, false otherwise
      • containsUser

        public boolean containsUser​(@NotNull
                                    @NotNull java.lang.String name)
        Description copied from interface: PermissionProvider
        Checks if at least one user with the given name is stored in the database. This method is case-sensitive.
        Specified by:
        containsUser in interface PermissionProvider
        Parameters:
        name - the name of the user
        Returns:
        true if there is a user with that name, false otherwise
      • getUser

        @Nullable
        public @Nullable IPermissionUser getUser​(@NotNull
                                                 @NotNull java.util.UUID uniqueId)
        Description copied from interface: PermissionProvider
        Gets a user with the given uniqueId out of the database.
        Specified by:
        getUser in interface PermissionProvider
        Parameters:
        uniqueId - the uniqueId of the user
        Returns:
        the IPermissionUser from the database or null if 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: PermissionProvider
        Gets 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:
        getUsers in interface PermissionProvider
        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: PermissionProvider
        Gets 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:
        getUsers in interface PermissionProvider
        Returns:
        a list of all IPermissionUsers stored in the database or an empty list if there is no user with that name stored.
      • getUsersByGroup

        public java.util.Collection<IPermissionUser> getUsersByGroup​(@NotNull
                                                                     @NotNull java.lang.String group)
        Description copied from interface: PermissionProvider
        Gets 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:
        getUsersByGroup in interface PermissionProvider
        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: PermissionProvider
        Adds 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:
        addGroup in interface PermissionProvider
        Parameters:
        permissionGroup - the IPermissionGroup to be added
      • deleteGroup

        public void deleteGroup​(@NotNull
                                @NotNull java.lang.String name)
        Description copied from interface: PermissionProvider
        Deletes a group by its name out of the list of groups. If a group with that name doesn't exist, nothing happens.
        Specified by:
        deleteGroup in interface PermissionProvider
        Parameters:
        name - the case-sensitive name of the group
      • containsGroup

        public boolean containsGroup​(@NotNull
                                     @NotNull java.lang.String group)
        Description copied from interface: PermissionProvider
        Checks if a specific group exists.
        Specified by:
        containsGroup in interface PermissionProvider
        Parameters:
        group - the case-sensitive name of the group
        Returns:
        true if the group exists, false otherwise
      • setGroups

        public void setGroups​(@NotNull
                              @NotNull java.util.Collection<? extends IPermissionGroup> groups)
        Description copied from interface: PermissionProvider
        Clears all groups in the Cloud and sets given groups.
        Specified by:
        setGroups in interface PermissionProvider
        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: PermissionProvider
        Adds a new user to the database.
        Specified by:
        addUserAsync in interface PermissionProvider
        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: PermissionProvider
        Updates an already existing user in the database.
        Specified by:
        updateUserAsync in interface PermissionProvider
        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: PermissionProvider
        Deletes all users in the database matching the given name. This method is case-sensitive.
        Specified by:
        deleteUserAsync in interface PermissionProvider
        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: PermissionProvider
        Deletes one user with the uniqueId of the given user.
        Specified by:
        deleteUserAsync in interface PermissionProvider
        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: PermissionProvider
        Checks if a user with the given uniqueId is stored in the database.
        Specified by:
        containsUserAsync in interface PermissionProvider
        Parameters:
        uniqueId - the uniqueId of the user
        Returns:
        true if there is a user with that uniqueId, false otherwise
      • containsUserAsync

        @NotNull
        public @NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.lang.Boolean> containsUserAsync​(@NotNull
                                                                                                         @NotNull java.lang.String name)
        Description copied from interface: PermissionProvider
        Checks if at least one user with the given name is stored in the database. This method is case-sensitive.
        Specified by:
        containsUserAsync in interface PermissionProvider
        Parameters:
        name - the name of the user
        Returns:
        true if there is a user with that name, false otherwise
      • getUserAsync

        @NotNull
        public @NotNull de.dytanic.cloudnet.common.concurrent.ITask<IPermissionUser> getUserAsync​(@NotNull
                                                                                                  @NotNull java.util.UUID uniqueId)
        Description copied from interface: PermissionProvider
        Gets a user with the given uniqueId out of the database.
        Specified by:
        getUserAsync in interface PermissionProvider
        Parameters:
        uniqueId - the uniqueId of the user
        Returns:
        the IPermissionUser from the database or null if 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: PermissionProvider
        Gets 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:
        getUsersAsync in interface PermissionProvider
        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: PermissionProvider
        Gets 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:
        getUsersAsync in interface PermissionProvider
        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: PermissionProvider
        Clears all users stored in the database and inserts the given list.
        Specified by:
        setUsersAsync in interface PermissionProvider
        Parameters:
        users - the new IPermissionUsers 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: PermissionProvider
        Gets 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:
        getUsersByGroupAsync in interface PermissionProvider
        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: PermissionProvider
        Adds 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:
        addGroupAsync in interface PermissionProvider
        Parameters:
        permissionGroup - the IPermissionGroup to be added
      • updateGroupAsync

        @NotNull
        public @NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.lang.Void> updateGroupAsync​(@NotNull
                                                                                                     @NotNull IPermissionGroup permissionGroup)
        Description copied from interface: PermissionProvider
        Updates a permission group in the list of groups. If a group with that name doesn't exist, it will be created.
        Specified by:
        updateGroupAsync in interface PermissionProvider
        Parameters:
        permissionGroup - the IPermissionGroup to 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: PermissionProvider
        Deletes a group by its name out of the list of groups. If a group with that name doesn't exist, nothing happens.
        Specified by:
        deleteGroupAsync in interface PermissionProvider
        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: PermissionProvider
        Deletes a group by its name out of the list of groups. If a group with that name doesn't exist, nothing happens.
        Specified by:
        deleteGroupAsync in interface PermissionProvider
        Parameters:
        permissionGroup - the IPermissionGroup to 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: PermissionProvider
        Checks if a specific group exists.
        Specified by:
        containsGroupAsync in interface PermissionProvider
        Parameters:
        group - the case-sensitive name of the group
        Returns:
        true if the group exists, false otherwise
      • getGroupAsync

        @NotNull
        public @NotNull de.dytanic.cloudnet.common.concurrent.ITask<IPermissionGroup> getGroupAsync​(@NotNull
                                                                                                    @NotNull java.lang.String name)
        Description copied from interface: PermissionProvider
        Gets a specific group by its name.
        Specified by:
        getGroupAsync in interface PermissionProvider
        Parameters:
        name - the case-sensitive name of the group
        Returns:
        the IPermissionUser if it exists, null otherwise
      • getGroupsAsync

        @NotNull
        public @NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.util.Collection<IPermissionGroup>> getGroupsAsync()
        Description copied from interface: PermissionProvider
        Gets the list of all groups in the Cloud.
        Specified by:
        getGroupsAsync in interface PermissionProvider
        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: PermissionProvider
        Clears all groups in the Cloud and sets given groups.
        Specified by:
        setGroupsAsync in interface PermissionProvider
        Parameters:
        groups - the new groups