endstone/permissions

Classes

NameDescription
PermissibleRepresents an object that may become a server operator and can be assigned permissions.
PermissionRepresents a unique permission that may be attached to a Permissible.
PermissionAttachmentHolds information about a permission attachment on a Permissible object.
PermissionAttachmentInfoHolds information on a permission and which PermissionAttachment provides it.

Enums

NameDescription
PermissionDefaultRepresents the possible default values for permissions.
PermissionLevel

Type Aliases

classPermissible

Defined in <endstone/permissions/permissible.h>

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

Methods

NameDescription
~Permissible
getPermissionLevelGets the permission level of this object.
isPermissionSetChecks if this object contains an override for the specified permission, by fully qualified name.
isPermissionSetChecks if this object contains an override for the specified Permission.
hasPermissionGets the value of the specified permission, if set. If a permission override is not set on this object, the default value of the permission will be returned.
hasPermissionGets the value of the specified permission, if set. If a permission override is not set on this object, the default value of the permission will be returned.
addAttachmentAdds a new PermissionAttachment with a single permission by name and value.
addAttachmentAdds a new empty PermissionAttachment to this object.
removeAttachmentRemoves the given PermissionAttachment from this object.
recalculatePermissionsRecalculates the permissions for this object, if the attachments have changed values. This should very rarely need to be called from a plugin.
getEffectivePermissionsGets a set containing all the permissions currently in effect by this object.
asCommandSenderCasts a Permissible as CommandSender.

meth~Permissiblevirtual

~Permissible() =default

methgetPermissionLevelabstractconst

PermissionLevel getPermissionLevel() const =0

Gets the permission level of this object.

Returns

TypeDescription
PermissionLevelThe permission level

methisPermissionSetabstractconst

bool isPermissionSet(std::string name) const =0

Checks if this object contains an override for the specified permission, by fully qualified name.

Parameters

NameTypeDescription
namestd::stringName of the permission

Returns

TypeDescription
booltrue if the permission is set, otherwise false

methisPermissionSetabstractconst

bool isPermissionSet(const Permission& perm) const =0

Checks if this object contains an override for the specified Permission.

Parameters

NameTypeDescription
permconst Permission&Permission to check

Returns

TypeDescription
booltrue if the permission is set, otherwise false

methhasPermissionabstractconst

bool hasPermission(std::string name) const =0

Gets the value of the specified permission, if set. If a permission override is not set on this object, the default value of the permission will be returned.

Parameters

NameTypeDescription
namestd::stringName of the permission

Returns

TypeDescription
boolValue of the permission

methhasPermissionabstractconst

bool hasPermission(const Permission& perm) const =0

Gets the value of the specified permission, if set. If a permission override is not set on this object, the default value of the permission will be returned.

Parameters

NameTypeDescription
permconst Permission&Permission to get

Returns

TypeDescription
boolValue of the permission

methaddAttachmentabstract

PermissionAttachment* addAttachment(Plugin& plugin, const std::string& name, bool value) =0

Adds a new PermissionAttachment with a single permission by name and value.

Parameters

NameTypeDescription
pluginPlugin&Plugin responsible for this attachment, may not be null or disabled
nameconst std::string&Name of the permission to attach
valueboolValue of the permission

Returns

TypeDescription
PermissionAttachment*The PermissionAttachment that was just created

methaddAttachmentabstract

PermissionAttachment* addAttachment(Plugin& plugin) =0

Adds a new empty PermissionAttachment to this object.

Parameters

NameTypeDescription
pluginPlugin&Plugin responsible for this attachment, may not be null or disabled

Returns

TypeDescription
PermissionAttachment*The PermissionAttachment that was just created

methremoveAttachmentabstract

bool removeAttachment(PermissionAttachment& attachment) =0

Removes the given PermissionAttachment from this object.

Parameters

NameTypeDescription
attachmentPermissionAttachment&Attachment to remove

Returns

TypeDescription
booltrue if the specified attachment was removed successfully, false when it isn't part of this object

methrecalculatePermissionsabstract

void recalculatePermissions() =0

Recalculates the permissions for this object, if the attachments have changed values. This should very rarely need to be called from a plugin.

methgetEffectivePermissionsabstractconst

std::unordered_set<PermissionAttachmentInfo*> getEffectivePermissions() const =0

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

Returns

TypeDescription
std::unordered_set<PermissionAttachmentInfo*>Set of currently effective permissions

methasCommandSenderabstractconst

CommandSender* asCommandSender() const =0

Casts a Permissible as CommandSender.

Returns

TypeDescription
CommandSender*CommandSender, nullptr if not a CommandSender

classPermission

Defined in <endstone/permissions/permission.h>

Represents a unique permission that may be attached to a Permissible.

Variables

NameDescription
DefaultPermission

Methods

varDefaultPermissionstaticconstexpr

auto DefaultPermission

methPermissionexplicit

Permission(std::string name, std::string description = "", PermissionDefault default_value = DefaultPermission, std::unordered_map<std::string, bool> children = {})

methgetNameconst

std::string getName() const

Returns the unique fully qualified name of this Permission

Returns

TypeDescription
std::stringFully qualified name

methgetChildren

std::unordered_map<std::string, bool>& getChildren()

Gets the children of this permission. If you change this map in any form, you must call recalculatePermissibles() to recalculate all Permissibles

Returns

TypeDescription
std::unordered_map<std::string, bool>&Permission children

methgetDefaultconst

PermissionDefault getDefault() const

Gets the default value of this permission.

Returns

TypeDescription
PermissionDefaultDefault value of this permission.

methsetDefault

void setDefault(PermissionDefault value)

Sets the default value of this permission.

This will not be saved to disk, and is a temporary operation until the server reloads permissions. Changing this default will cause all Permissibles that contain this permission to recalculate their permissions

Parameters

NameTypeDescription
valuePermissionDefaultThe new default to set

methgetDescriptionconst

std::string getDescription() const

Gets a brief description of this permission, may be empty

Returns

TypeDescription
std::stringBrief description of this permission

methsetDescription

void setDescription(std::string value)

Sets the description of this permission.

This will not be saved to disk, and is a temporary operation until the server reloads permissions.

Parameters

NameTypeDescription
valuestd::stringThe new description to set

methgetPermissiblesconst

std::unordered_set<Permissible*> getPermissibles() const

Gets a set containing every Permissible that has this permission. This set cannot be modified.

Returns

TypeDescription
std::unordered_set<Permissible*>Set containing permissibles with this permission

methrecalculatePermissibles

void recalculatePermissibles()

Recalculates all Permissibles that contain this permission.

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

methaddParent

Permission* addParent(std::string name, bool value)

Adds this permission to the specified parent permission.

If the parent permission does not exist, it will be created and registered.

Parameters

NameTypeDescription
namestd::stringName of the parent permission
valueboolThe value to set this permission to

Returns

TypeDescription
Permission*Parent permission it created or loaded

methaddParentconst

void addParent(Permission& perm, bool value) const

Adds this permission to the specified parent permission.

Parameters

NameTypeDescription
permPermission&Parent permission to register with
valueboolThe value to set this permission to

methinit

void init(PluginManager& plugin_manager)

classPermissionAttachment

Defined in <endstone/permissions/permission_attachment.h>

Holds information about a permission attachment on a Permissible object.

Methods

methPermissionAttachment

PermissionAttachment(Plugin& plugin, Permissible& permissible)

methgetPluginconst

Plugin& getPlugin() const

Gets the plugin responsible for this attachment

Returns

TypeDescription
Plugin&Plugin responsible for this permission attachment

methsetRemovalCallback

void setRemovalCallback(PermissionRemovedExecutor ex)

Sets an executor to be called for when this attachment is removed from a Permissible. May be empty.

Parameters

NameTypeDescription
exPermissionRemovedExecutorExecutor to be called when this is removed

methgetRemovalCallbackconst

PermissionRemovedExecutor getRemovalCallback() const

Gets the class that was previously set to be called when this attachment was removed from a Permissible. May be empty.

Returns

TypeDescription
PermissionRemovedExecutorExecutor to be called when this is removed

methgetPermissibleconst

Permissible& getPermissible() const

Gets the Permissible that this is attached to

Returns

TypeDescription
Permissible&Permissible containing this attachment

methgetPermissionsconst

std::unordered_map<std::string, bool> getPermissions() const

Gets 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.

Returns

TypeDescription
std::unordered_map<std::string, bool>Copy of all permissions and values expressed by this attachment

methsetPermission

void setPermission(std::string name, bool value)

Sets a permission to the given value, by its fully qualified name

Parameters

NameTypeDescription
namestd::stringName of the permission
valueboolNew value of the permission

methsetPermission

void setPermission(Permission& perm, bool value)

Sets a permission to the given value

Parameters

NameTypeDescription
permPermission&Permission to set
valueboolNew value of the permission

methunsetPermission

void unsetPermission(std::string name)

Removes the specified permission from this attachment. If the permission does not exist in this attachment, nothing will happen.

Parameters

NameTypeDescription
namestd::stringName of the permission to remove

methunsetPermission

void unsetPermission(Permission& perm)

Removes the specified permission from this attachment. If the permission does not exist in this attachment, nothing will happen.

Parameters

NameTypeDescription
permPermission&Permission to remove

methremove

bool remove()

Removes this attachment from its registered Permissible

Returns

TypeDescription
booltrue if the permissible was removed successfully, false if it did not exist

classPermissionAttachmentInfo

Defined in <endstone/permissions/permission_attachment_info.h>

Holds information on a permission and which PermissionAttachment provides it.

Methods

methPermissionAttachmentInfo

PermissionAttachmentInfo(Permissible& permissible, std::string permission, PermissionAttachment* attachment, bool value)

methgetPermissibleconst

Permissible& getPermissible() const

Gets the permissible this is attached to

Returns

TypeDescription
Permissible&Permissible this permission is for

methgetPermissionconst

std::string getPermission() const

Gets the permission being set

Returns

TypeDescription
std::stringName of the permission

methgetAttachmentconst

PermissionAttachment* getAttachment() const

Gets the attachment providing this permission. This may be null for default permissions (usually parent permissions).

Returns

TypeDescription
PermissionAttachment*Attachment

methgetValueconst

bool getValue() const

Gets the value of this permission

Returns

TypeDescription
boolValue of the permission

enumPermissionDefault

PermissionDefault

Represents the possible default values for permissions.

Values

NameValueDescription
True
False
Operator
NotOperator
Console

enumPermissionLevel

PermissionLevel

Values

NameValueDescription
Default0
Operator1
Console2

typePermissionRemovedExecutor

std::function<void(const PermissionAttachment&)> PermissionRemovedExecutor

On this page