API reference / @jsprismarine/prismarine / PermissionManager
Class: PermissionManager
Defined in: prismarine/src/permission/PermissionManager.ts:82
Permission manager.
Implements
Constructors
Constructor
new PermissionManager(
server):PermissionManager
Defined in: prismarine/src/permission/PermissionManager.ts:95
Create a new permission manager.
Parameters
server
The server instance.
Returns
PermissionManager
Methods
can()
can(
executer?):object
Defined in: prismarine/src/permission/PermissionManager.ts:311
Check if a player can execute a command.
Parameters
executer?
The player or console to check.
Returns
object
An object with an execute method that takes a permission string and returns whether the executer can execute the command.
execute
execute: (
permission?) =>boolean
Parameters
permission?
string
Returns
boolean
not
not: () =>
object
Returns
object
execute
execute: (
permission?) =>boolean
Parameters
permission?
string
Returns
boolean
getDefaultPermissions()
getDefaultPermissions():
string[]
Defined in: prismarine/src/permission/PermissionManager.ts:124
Get the default permissions.
Returns
string[]
The default permissions.
getPermissions()
getPermissions(
player):Promise<string[]>
Defined in: prismarine/src/permission/PermissionManager.ts:153
Get a player's permissions.
Parameters
player
The player to get permissions for.
Returns
Promise<string[]>
A promise that resolves with the player's permissions.
See
PermissionManager.permissionsOf for the synchronous form.
isOp()
isOp(
uuid):boolean
Defined in: prismarine/src/permission/PermissionManager.ts:301
Check if a player is an operator.
Parameters
uuid
string
The player's UUID.
Returns
boolean
Whether the player is an operator.
permissionsOf()
permissionsOf(
player):string[]
Defined in: prismarine/src/permission/PermissionManager.ts:139
Get a player's effective permissions as they stand now: the defaults, the player's own grants, and the operator defaults while the player is an operator.
Parameters
player
Pick<Player, "getUUID" | "isOp">
The player to get permissions for.
Returns
string[]
The player's current permissions.
Remarks
Built on every call rather than cached, so revoking operator status or replacing a player's grants takes effect on the player's next command.
setOp()
setOp(
username,op):Promise<boolean>
Defined in: prismarine/src/permission/PermissionManager.ts:270
Set a player as an operator.
Parameters
username
string
The player to set as an operator.
op
boolean
Whether the player should be an operator.
Returns
Promise<boolean>
A promise that resolves with a boolean indicating whether the operation was successful.
setPermissions()
setPermissions(
player,permissions?):void
Defined in: prismarine/src/permission/PermissionManager.ts:166
Set a player's permissions.
Parameters
player
The player to set permissions for.
permissions?
string[] = []
The permissions to set.
Returns
void
Remarks
This will not be saved to the permissions.json file.
Lifecycle
disable()
disable():
Promise<void>
Defined in: prismarine/src/permission/PermissionManager.ts:114
Signifies that the manager is being disabled and all permissions should be unloaded.
Returns
Promise<void>
A promise that resolves when the manager is disabled.
Implementation of
enable()
enable():
Promise<void>
Defined in: prismarine/src/permission/PermissionManager.ts:104
Enable the manager and load all permissions.
Returns
Promise<void>
A promise that resolves when the manager is enabled.