Skip to content

Permissions

endstone.permissions

Classes relating to permissions of players.

Classes:

Name Description
Permissible

Represents an object that may become a server operator and can be assigned permissions.

Permission

Represents a unique permission that may be attached to a Permissible

PermissionAttachment

Holds information about a permission attachment on a Permissible object.

PermissionAttachmentInfo

Holds information on a permission and which PermissionAttachment provides it.

PermissionDefault

Represents the possible default values for permissions

PermissionLevel

Permissible

Represents an object that may become a server operator and can be assigned permissions.

Methods:

Name Description
add_attachment
has_permission
is_permission_set
recalculate_permissions

Recalculates the permissions for this object, if the attachments have changed values.

remove_attachment

Removes the given PermissionAttachment from this object.

Attributes:

Name Type Description
effective_permissions set[PermissionAttachmentInfo]

A set containing all the permissions currently in effect by this object.

permission_level PermissionLevel

The permission level of this object.

effective_permissions property

effective_permissions: set[PermissionAttachmentInfo]

A set containing all the permissions currently in effect by this object.

permission_level property

permission_level: PermissionLevel

The permission level of this object.

add_attachment

add_attachment(
    plugin: Plugin, name: str, value: bool
) -> PermissionAttachment
add_attachment(plugin: Plugin) -> PermissionAttachment

has_permission

has_permission(name: str) -> bool
has_permission(perm: Permission) -> bool

is_permission_set

is_permission_set(name: str) -> bool
is_permission_set(perm: Permission) -> bool

recalculate_permissions

recalculate_permissions() -> None

Recalculates the permissions for this object, if the attachments have changed values.

This should very rarely need to be called from a plugin.

remove_attachment

remove_attachment(attachment: PermissionAttachment) -> bool

Removes the given PermissionAttachment from this object.

Parameters:

Name Type Description Default
attachment PermissionAttachment

Attachment to remove.

required

Returns:

Type Description
bool

True if the specified attachment was removed successfully, False when it isn't part of this object.

Permission

Permission(
    name: str,
    description: str | None = None,
    default: PermissionDefault | None = None,
    children: Mapping[str, bool] | None = None,
    *args,
    **kwargs
)

Represents a unique permission that may be attached to a Permissible

Methods:

Name Description
add_parent
recalculate_permissibles

Recalculates all Permissibles that contain this permission.

Attributes:

Name Type Description
children dict[str, bool]

The children of this permission.

default PermissionDefault

The default value of this permission.

description str

A brief description of this permission.

name str

The unique fully qualified name of this Permission.

permissibles set[Permissible]

A set containing every Permissible that has this permission.

children property

children: dict[str, bool]

The children of this permission.

If you change this map in any form, you must call recalculate_permissibles() to recalculate all Permissibles.

default property writable

The default value of this permission.

description property writable

description: str

A brief description of this permission.

name property

name: str

The unique fully qualified name of this Permission.

permissibles property

permissibles: set[Permissible]

A set containing every Permissible that has this permission.

add_parent

add_parent(name: str, value: bool) -> Permission
add_parent(perm: Permission, value: bool) -> None

recalculate_permissibles

recalculate_permissibles() -> None

Recalculates all Permissibles that contain this permission.

This should be called after modifying the children, and is automatically called after modifying the default value.

PermissionAttachment

PermissionAttachment(
    plugin: Plugin, permissible: Permissible
)

Holds information about a permission attachment on a Permissible object.

Methods:

Name Description
remove

Removes this attachment from its registered Permissible.

set_permission
unset_permission

Attributes:

Name Type Description
permissible Permissible

The Permissible that this is attached to.

permissions dict[str, bool]

A copy of all set permissions and values contained within this attachment.

plugin Plugin

The plugin responsible for this permission attachment.

removal_callback Callable[[PermissionAttachment], None]

The callback to be called when this attachment is removed. May be empty.

permissible property

permissible: Permissible

The Permissible that this is attached to.

permissions property

permissions: dict[str, bool]

A copy of all set permissions and values contained within this attachment.

This map may be modified but will not affect the attachment, as it is a copy.

plugin property

plugin: Plugin

The plugin responsible for this permission attachment.

removal_callback property writable

removal_callback: Callable[[PermissionAttachment], None]

The callback to be called when this attachment is removed. May be empty.

remove

remove() -> bool

Removes this attachment from its registered Permissible.

Returns:

Type Description
bool

True if the attachment was removed successfully, False if it did not exist.

set_permission

set_permission(name: str, value: bool) -> None
set_permission(perm: Permission, value: bool) -> None

unset_permission

unset_permission(name: str) -> None
unset_permission(perm: Permission) -> None

PermissionAttachmentInfo

PermissionAttachmentInfo(
    permissible: Permissible,
    permission: str,
    attachment: PermissionAttachment,
    value: bool,
)

Holds information on a permission and which PermissionAttachment provides it.

Attributes:

Name Type Description
attachment PermissionAttachment

The attachment providing this permission.

permissible Permissible

The Permissible this permission is for.

permission str

The name of the permission being set.

value bool

The value of this permission.

attachment property

The attachment providing this permission.

This may be None for default permissions (usually parent permissions).

permissible property

permissible: Permissible

The Permissible this permission is for.

permission property

permission: str

The name of the permission being set.

value property

value: bool

The value of this permission.

PermissionDefault

Bases: Enum

Represents the possible default values for permissions

Attributes:

Name Type Description
CONSOLE
FALSE
NOT_OP
OP
TRUE

CONSOLE class-attribute instance-attribute

CONSOLE = 4

FALSE class-attribute instance-attribute

FALSE = 1

NOT_OP class-attribute instance-attribute

NOT_OP = 3

OP class-attribute instance-attribute

OP = 2

TRUE class-attribute instance-attribute

TRUE = 0

PermissionLevel

Bases: IntEnum

Attributes:

Name Type Description
CONSOLE
DEFAULT
OP

CONSOLE class-attribute instance-attribute

CONSOLE = 2

DEFAULT class-attribute instance-attribute

DEFAULT = 0

OP class-attribute instance-attribute

OP = 1