Interface PermissionDescription.Builder
- Enclosing interface:
- PermissionDescription
-
Method Summary
Modifier and TypeMethodDescriptionAssigns this permission to the given role-templateSubject
.defaultValue
(Tristate defaultValue) Sets a value that this permission should have by default.description
(@Nullable Component description) Sets the short description to use.Sets the permission id for the description this builder creates.register()
Creates and registers a newPermissionDescription
instance with the given settings.
-
Method Details
-
id
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
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
Assigns this permission to the given role-templateSubject
.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 inPermissionDescription
for common roles (not exhaustive).value
- The value to to assign- Returns:
- This builder for chaining
-
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 onceregister()
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
Creates and registers a newPermissionDescription
instance with the given settings.- Returns:
- The newly created permission description instance
- Throws:
IllegalStateException
- If there are any settings left unset or a description with the given permission id was already registered and thePermissionService
does not support overwriting descriptions
-