Interface PermissionDescription.Builder

  • Enclosing interface:
    PermissionDescription

    public static interface PermissionDescription.Builder
    A builder for permission descriptions.
    • Method Detail

      • id

        PermissionDescription.Builder id​(java.lang.String permissionId)
        Sets the permission id for the description this builder creates.

        See PermissionDescription.id() for format specifications.

        Parameters:
        permissionId - The permission id
        Returns:
        This builder for chaining
      • description

        PermissionDescription.Builder description​(@Nullable Component description)
        Sets the short description to use.

        May include a link to a more detailed description on the plugin's web page.

        Can be null if the permission does not have a description.

        Parameters:
        description - The short description to use
        Returns:
        This builder for chaining
      • assign

        PermissionDescription.Builder assign​(java.lang.String role,
                                             boolean value)
        Assigns this permission to the given role-template Subject.

        Role templates will be namespaced by the plugin that owns each registered permission. The expected format of the namespaced subject identifier is <plugin id>:<role>. Implementations must provide an un-namespaced role template that inherits its permissions from every plugin-namespaced role template.

        If the given subject does not exist it will be created.

        It is recommended to use the standard role suggestions expressed as static parameters in PermissionDescription.

        Do not assign a permission to user, staff and admin at the same time but solve this with subject inheritance if possible.

        Note: The permissions are only assigned during register().

        Parameters:
        role - The role-template to assign the permission to. See constants in PermissionDescription for common roles (not exhaustive).
        value - The value to to assign
        Returns:
        This builder for chaining
      • defaultValue

        PermissionDescription.Builder defaultValue​(Tristate defaultValue)
        Sets a value that this permission should have by default. This can be used to exclude permissions from node tree inheritance, or to provide a permission to users by default.

        This is shorthand for giving PermissionDescription.id() (with templates stripped) a value on the default subject, except that the default value will only be applied once register() is called.

        Assigning default permissions should be used sparingly, and by convention, only in situations where "default" game behaviour is restored by granting a certain permission.

        Parameters:
        defaultValue - The value this permission should have for subjects where none has been assigned.
        Returns:
        The builder for chaining.
      • register

        PermissionDescription register()
                                throws java.lang.IllegalStateException
        Creates and registers a new PermissionDescription instance with the given settings.
        Returns:
        The newly created permission description instance
        Throws:
        java.lang.IllegalStateException - If there are any settings left unset or a description with the given permission id was already registered and the PermissionService does not support overwriting descriptions