PermissionManager
Namespace Mc.Scripting.Permissions · Kind class (static)
public static class PermissionManagerThe 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.
Remarks
Section titled “Remarks”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.
Properties
Section titled “Properties”| 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. |
BuiltIn
Section titled “BuiltIn”public static FilePermissionProvider BuiltIn { get; }The built-in file backend (created on first use at permissions.json in the server directory).
Provider
Section titled “Provider”public static IPermissionProvider Provider { get; }The active backend.
Registered
Section titled “Registered”public static IReadOnlyList<Permission> Registered { get; }A snapshot of the declared nodes.
Methods
Section titled “Methods”| 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. |
GetExplicit
Section titled “GetExplicit”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
IsRegistered
Section titled “IsRegistered”public static bool IsRegistered(string node)Whether a node was declared.
Parameters
| Name | Type | Description |
|---|---|---|
node |
string |
The node. |
Returns bool
Register
Section titled “Register”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. |
Reload
Section titled “Reload”public static void Reload()Reloads the built-in backend’s file and fires PermissionsReloaded.
SetProvider
Section titled “SetProvider”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. |
See also
Section titled “See also”Entity · FilePermissionProvider · IPermissionProvider · Permission · PermissionValue · Player · Uuid