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:

src/my_plugin.cpp
#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:

ValueWho holds it
PermissionDefault::TrueEveryone
PermissionDefault::FalseNo one, unless explicitly granted
PermissionDefault::OperatorOperators only
PermissionDefault::NotOperatorNon-operators only
PermissionDefault::ConsoleConsole only

On this page