Interface PermissionDescription


  • public interface PermissionDescription
    A description object for permissions.

    The description is meant to provide human readable descriptions and metadata for a permission, and a central point for the plugin registering each permission.

    Descriptions are primarily informational, but some default value information may be provided here.

    Instances can be built using PermissionService.newDescriptionBuilder(PluginContainer).

    • Field Detail

      • ROLE_USER

        static final String ROLE_USER
        The standard role for users.

        The user role should be assigned to permissions where everyone should have basic access. For example: joining in an arena.

        See Also:
        Constant Field Values
      • ROLE_STAFF

        static final String ROLE_STAFF
        The standard role for staff.

        The staff role should be assigned to permissions only meant for users with elevated access permissions. For example: force start an arena.

        See Also:
        Constant Field Values
      • ROLE_ADMIN

        static final String ROLE_ADMIN
        The standard role for admins.

        The admin role should be assigned to permissions only meant for users with full access to administrate the server. For example: setup an arena.

        See Also:
        Constant Field Values
    • Method Detail

      • id

        String id()
        Gets the permission id this description belongs to.

        The permission id must be of the specified format as specified using EBNF:

        • CHARACTER = "A" - "Z" | "a" - "z" | "0" - "9" | "_" | "-"
        • NAME = CHARACTER , { CHARACTER }
        • TEMPLATE = "<" , NAME , ">"
        • PERMISSION = NAME , { "." , NAME }, {".", TEMPLATE}

        The following examples shall help you to structure your permissions well:

        • "myplugin" - Grants everything in myPlugin
        • "myplugin.give" - Grants everything related to give including all ItemTypes and Enchantments
        • "myplugin.give.execute" - Allows the execution of give
        • "myplugin.give.type" - Grants all ItemTypes
        • "myplugin.give.type.<item-type>" - A template should not be granted to anybody
        • "myplugin.give.type.minecraft.diamond" - Only grants minecraft:diamond
        • "myplugin.give.enchantment" - Grants all Enchantments
        • "myplugin.give.others" - Allow giving to other players
        The addition of the "execute" permission instead of just "myPlugin.give" permission is useful to prevent unauthorized access to sub-permissions that are not documented or have been added lately.

        So if you want to allow someone to give themself only DIAMONDs, you would assign them the following permissions:

        • "myplugin.give.execute"
        • "myplugin.give.type.minecraft.diamond"

        Note: Permission ids are case insensitive! If permission ids do not start with the plugin ID, implementations will prepend the plugin ID (so command.give will turn into myplugin.command.give)

        Returns:
        The permission id
      • description

        Optional<Component> description()
        Gets a short description of the linked permission.

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

        Will return an empty optional for descriptions which have been automatically generated, or where a description was omitted when the PermissionDescription was created.

        Returns:
        A short description of the linked permission
      • owner

        Optional<org.spongepowered.plugin.PluginContainer> owner()
        Gets the owning plugin the permission belongs to.

        Will return an empty optional for descriptions which have been automatically generated.

        Returns:
        The owning plugin the permission belongs to
      • defaultValue

        Tristate defaultValue()
        Gets the default value this permission should have on this server. This value will have been applied to the default subject.
        Returns:
        The default value for this permission.
      • query

        boolean query​(Subject subj)
        Check if the given subject has the permission described.

        If id() contains any template parameters, they will be stripped out. See overloads if parameters are desired.

        Parameters:
        subj - The subject to query
        Returns:
        Whether the given subject has this permission.
      • query

        boolean query​(Subject subj,
                      ResourceKey key)
        Check if the given subject has the permission described.

        Template parameters will be trimmed, and the catalog key will be appended in the format Key.namespace().Key.value().

        Parameters:
        subj - The subject to query
        key - The catalog key to relativize this permission for
        Returns:
        Whether the given subject has this permission.
      • query

        boolean query​(Subject subj,
                      String... parameters)
        Check if the given subject has the permission described.

        Template parameters will be trimmed from the permission, and the given parameters will be appended joined by ..

        Parameters:
        subj - The subject to query
        parameters - The parameters to append to the permission being checked
        Returns:
        Whether the given subject has this permission.
      • query

        boolean query​(Subject subj,
                      String parameter)
        Check if the given subject has the permission described.

        Template parameters will be trimmed from the permission, and the given parameter will be appended

        Parameters:
        subj - The subject to query
        parameter - The parameter to append to the permission when checking
        Returns:
        Whether the given subject has this permission.