Skip to content

PermissionManager

Namespace Mc.Scripting.Permissions · Kind class (static)

public static class PermissionManager

The server’s permission system: declared nodes with defaults, the active backend (IPermissionProvider) and the question “does this player have this node?”. The default backend is a FilePermissionProvider on permissions.json; a plugin may replace it.

Resolution: the provider’s explicit value (wildcards, groups and player overrides are its business); if it has no opinion, the node’s registered default decides (PermissionDefault.Op and friends are evaluated against the player’s vanilla operator level); an unregistered node without an entry is denied, except minecraft.command.<name> which defaults to the vanilla operator level of that command. The console always has every permission. Everything here runs on the tick thread.

Member Description
static FilePermissionProvider BuiltIn { get; } The built-in file backend (created on first use at permissions.json in the server directory).
static IPermissionProvider Provider { get; } The active backend.
static IReadOnlyList<Permission> Registered { get; } A snapshot of the declared nodes.
public static FilePermissionProvider BuiltIn { get; }

The built-in file backend (created on first use at permissions.json in the server directory).

public static IPermissionProvider Provider { get; }

The active backend.

public static IReadOnlyList<Permission> Registered { get; }

A snapshot of the declared nodes.

Member Description
static PermissionValue GetExplicit(Uuid player, string node) The tri-state value the backend holds for the player, without applying defaults.
static bool Has(Player player, string node) Whether the player has the permission.
static bool Has(Uuid player, string node) Whether the player (online or not) has the permission.
static bool Has(Entity entity, string node) Whether the entity has the permission (Entity.Null is the console and has everything).
static bool IsRegistered(string node) Whether a node was declared.
static void Register(Permission permission) Declares a permission node (the plugin-scoped plugin.Permissions.Register unregisters it on unload).
static void Reload() Reloads the built-in backend’s file and fires PermissionsReloaded.
static void SetProvider(IPermissionProvider provider) Replaces the backend.
public static PermissionValue GetExplicit(Uuid player, string node)

The tri-state value the backend holds for the player, without applying defaults.

Parameters

Name Type Description
player Uuid The profile id.
node string The node.

Returns PermissionValue

public static bool Has(Player player, string node)

Whether the player has the permission.

Parameters

Name Type Description
player Player The player (a stale handle has nothing).
node string The node.

Returns bool

public static bool Has(Uuid player, string node)

Whether the player (online or not) has the permission. The operator level is looked up in the server’s ops list.

Parameters

Name Type Description
player Uuid The profile id.
node string The node.

Returns bool

public static bool Has(Entity entity, string node)

Whether the entity has the permission (Entity.Null is the console and has everything).

Parameters

Name Type Description
entity Entity A player entity or the null entity.
node string The node.

Returns bool

public static bool IsRegistered(string node)

Whether a node was declared.

Parameters

Name Type Description
node string The node.

Returns bool

public static void Register(Permission permission)

Declares a permission node (the plugin-scoped plugin.Permissions.Register unregisters it on unload).

Parameters

Name Type Description
permission Permission The node, default and description.
public static void Reload()

Reloads the built-in backend’s file and fires PermissionsReloaded.

public static void SetProvider(IPermissionProvider provider)

Replaces the backend. The previous one is restored when the owning plugin unloads (use the plugin-scoped overload from plugins).

Parameters

Name Type Description
provider IPermissionProvider The new backend.

Entity · FilePermissionProvider · IPermissionProvider · Permission · PermissionValue · Player · Uuid