endstone/permissions
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. |
Enums
| Name | Description |
|---|---|
PermissionDefault | Represents the possible default values for permissions. |
PermissionLevel |
Type Aliases
| Name | Description |
|---|---|
PermissionRemovedExecutor |
classPermissible
Defined in <endstone/permissions/permissible.h>
Represents an object that may become a server operator and can be assigned permissions.
Methods
| Name | Description |
|---|---|
~Permissible | |
getPermissionLevel | Gets the permission level of this object. |
isPermissionSet | Checks if this object contains an override for the specified permission, by fully qualified name. |
isPermissionSet | Checks if this object contains an override for the specified Permission. |
hasPermission | 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. |
hasPermission | 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. |
addAttachment | Adds a new PermissionAttachment with a single permission by name and value. |
addAttachment | Adds a new empty PermissionAttachment to this object. |
removeAttachment | Removes the given PermissionAttachment from this object. |
recalculatePermissions | Recalculates the permissions for this object, if the attachments have changed values. This should very rarely need to be called from a plugin. |
getEffectivePermissions | Gets a set containing all the permissions currently in effect by this object. |
asCommandSender | Casts a Permissible as CommandSender. |
meth~Permissiblevirtual
~Permissible() =defaultmethgetPermissionLevelabstractconst
PermissionLevel getPermissionLevel() const =0Gets the permission level of this object.
Returns
| Type | Description |
|---|---|
PermissionLevel | The permission level |
methisPermissionSetabstractconst
bool isPermissionSet(std::string name) const =0Checks if this object contains an override for the specified permission, by fully qualified name.
Parameters
| Name | Type | Description |
|---|---|---|
name | std::string | Name of the permission |
Returns
| Type | Description |
|---|---|
bool | true if the permission is set, otherwise false |
methisPermissionSetabstractconst
bool isPermissionSet(const Permission& perm) const =0Checks if this object contains an override for the specified Permission.
Parameters
| Name | Type | Description |
|---|---|---|
perm | const Permission& | Permission to check |
Returns
| Type | Description |
|---|---|
bool | true if the permission is set, otherwise false |
methhasPermissionabstractconst
bool hasPermission(std::string name) const =0Gets 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
| Name | Type | Description |
|---|---|---|
name | std::string | Name of the permission |
Returns
| Type | Description |
|---|---|
bool | Value of the permission |
methhasPermissionabstractconst
bool hasPermission(const Permission& perm) const =0Gets 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
| Name | Type | Description |
|---|---|---|
perm | const Permission& | Permission to get |
Returns
| Type | Description |
|---|---|
bool | Value of the permission |
methaddAttachmentabstract
PermissionAttachment* addAttachment(Plugin& plugin, const std::string& name, bool value) =0Adds a new PermissionAttachment with a single permission by name and value.
Parameters
| Name | Type | Description |
|---|---|---|
plugin | Plugin& | Plugin responsible for this attachment, may not be null or disabled |
name | const std::string& | Name of the permission to attach |
value | bool | Value of the permission |
Returns
| Type | Description |
|---|---|
PermissionAttachment* | The PermissionAttachment that was just created |
methaddAttachmentabstract
PermissionAttachment* addAttachment(Plugin& plugin) =0Adds a new empty PermissionAttachment to this object.
Parameters
Returns
| Type | Description |
|---|---|
PermissionAttachment* | The PermissionAttachment that was just created |
methremoveAttachmentabstract
bool removeAttachment(PermissionAttachment& attachment) =0Removes the given PermissionAttachment from this object.
Parameters
| Name | Type | Description |
|---|---|---|
attachment | PermissionAttachment& | Attachment to remove |
Returns
| Type | Description |
|---|---|
bool | true if the specified attachment was removed successfully, false when it isn't part of this object |
methrecalculatePermissionsabstract
void recalculatePermissions() =0Recalculates 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 =0Gets a set containing all the permissions currently in effect by this object.
Returns
| Type | Description |
|---|---|
std::unordered_set<PermissionAttachmentInfo*> | Set of currently effective permissions |
methasCommandSenderabstractconst
CommandSender* asCommandSender() const =0Casts a Permissible as CommandSender.
Returns
| Type | Description |
|---|---|
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
| Name | Description |
|---|---|
DefaultPermission |
Methods
varDefaultPermissionstaticconstexpr
auto DefaultPermissionmethPermissionexplicit
Permission(std::string name, std::string description = "", PermissionDefault default_value = DefaultPermission, std::unordered_map<std::string, bool> children = {})methgetNameconst
std::string getName() constReturns the unique fully qualified name of this Permission
Returns
| Type | Description |
|---|---|
std::string | Fully 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
| Type | Description |
|---|---|
std::unordered_map<std::string, bool>& | Permission children |
methgetDefaultconst
PermissionDefault getDefault() constGets the default value of this permission.
Returns
| Type | Description |
|---|---|
PermissionDefault | Default 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
| Name | Type | Description |
|---|---|---|
value | PermissionDefault | The new default to set |
methgetDescriptionconst
std::string getDescription() constGets a brief description of this permission, may be empty
Returns
| Type | Description |
|---|---|
std::string | Brief 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
| Name | Type | Description |
|---|---|---|
value | std::string | The new description to set |
methgetPermissiblesconst
std::unordered_set<Permissible*> getPermissibles() constGets a set containing every Permissible that has this permission. This set cannot be modified.
Returns
| Type | Description |
|---|---|
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
| Name | Type | Description |
|---|---|---|
name | std::string | Name of the parent permission |
value | bool | The value to set this permission to |
Returns
| Type | Description |
|---|---|
Permission* | Parent permission it created or loaded |
methaddParentconst
void addParent(Permission& perm, bool value) constAdds this permission to the specified parent permission.
Parameters
| Name | Type | Description |
|---|---|---|
perm | Permission& | Parent permission to register with |
value | bool | The 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() constGets the plugin responsible for this 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
| Name | Type | Description |
|---|---|---|
ex | PermissionRemovedExecutor | Executor to be called when this is removed |
methgetRemovalCallbackconst
PermissionRemovedExecutor getRemovalCallback() constGets the class that was previously set to be called when this attachment was removed from a Permissible. May be empty.
Returns
| Type | Description |
|---|---|
PermissionRemovedExecutor | Executor to be called when this is removed |
methgetPermissibleconst
Permissible& getPermissible() constGets the Permissible that this is attached to
Returns
| Type | Description |
|---|---|
Permissible& | Permissible containing this attachment |
methgetPermissionsconst
std::unordered_map<std::string, bool> getPermissions() constGets 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
| Type | Description |
|---|---|
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
| Name | Type | Description |
|---|---|---|
name | std::string | Name of the permission |
value | bool | New value of the permission |
methsetPermission
void setPermission(Permission& perm, bool value)Sets a permission to the given value
Parameters
| Name | Type | Description |
|---|---|---|
perm | Permission& | Permission to set |
value | bool | New 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
| Name | Type | Description |
|---|---|---|
name | std::string | Name 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
| Name | Type | Description |
|---|---|---|
perm | Permission& | Permission to remove |
methremove
bool remove()Removes this attachment from its registered Permissible
Returns
| Type | Description |
|---|---|
bool | true 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() constGets the permissible this is attached to
Returns
| Type | Description |
|---|---|
Permissible& | Permissible this permission is for |
methgetPermissionconst
std::string getPermission() constGets the permission being set
Returns
| Type | Description |
|---|---|
std::string | Name of the permission |
methgetAttachmentconst
PermissionAttachment* getAttachment() constGets the attachment providing this permission. This may be null for default permissions (usually parent permissions).
Returns
| Type | Description |
|---|---|
PermissionAttachment* | Attachment |
methgetValueconst
bool getValue() constGets the value of this permission
Returns
| Type | Description |
|---|---|
bool | Value of the permission |
enumPermissionDefault
PermissionDefaultRepresents the possible default values for permissions.
Values
| Name | Value | Description |
|---|---|---|
True | ||
False | ||
Operator | ||
NotOperator | ||
Console |
enumPermissionLevel
PermissionLevelValues
| Name | Value | Description |
|---|---|---|
Default | 0 | |
Operator | 1 | |
Console | 2 |
typePermissionRemovedExecutor
std::function<void(const PermissionAttachment&)> PermissionRemovedExecutor