Permissions
Gate commands behind permissions and set who holds them by default.
Permissions decide who may do what. Every command requires the operator permission by default; attach your own permission to open a command up or lock it down, and set the permission's default to say who holds it.
Attach a permission to a command
Attach a permission with .permissions(...), then define its default level with the permission(...) builder:
#include "my_plugin.h"
ENDSTONE_PLUGIN("my_plugin", "0.1.0", MyPlugin)
{
description = "My first C++ plugin for Endstone servers";
command("hello")
.description("Greet the command sender.")
.usages("/hello")
.permissions("my_plugin.command.hello");
permission("my_plugin.command.hello")
.description("Allow users to use the /hello command.")
.default_(es::PermissionDefault::True);
}Permission defaults
default_ sets who holds the permission:
| Value | Who holds it |
|---|---|
PermissionDefault::True | Everyone |
PermissionDefault::False | No one, unless explicitly granted |
PermissionDefault::Operator | Operators only |
PermissionDefault::NotOperator | Non-operators only |
PermissionDefault::Console | Console only |