PERMISSIONS

Force a player to execute a command with operator rights

This allows you to execute a command as an operator, even if the player does not have operator rights.

[execute] [the] command %strings% [by %-commandsenders%] as op
[execute] [the] %commandsenders% command %strings% as op
(let|make) %commandsenders% execute [[the] command] %strings% as op

User permission management

This section explains how to manage and modify player permissions programmatically.

%player%'s perm[ission][s]
perm[ission][s] of %player%

If this confuses you, you can use the following tutorial to understand how to use it.

command /permissionTest:
    permission: example.permission.test # we can set a permission for the command here instead of checking it in the code
    trigger:
        # Check if the player has a specific permission
        # This permission check is used for checking if the sender can execute the command
        # This check is redundant as it can be set directly in the command itself ( as seen above)
        if player does not have permission "example.permission.test":
            send "You don't have the permission `example.permission.test`!"
            stop

        # Add permissions
        add "example.permission.A" to player's perms
        add "example.permission.B" to player's perms

        # Display the player's permissions after adding permissions
        broadcast "%player's permissions%"

        # Remove permissions
        remove "example.permission.A" from player's permissions
        remove "example.permission.B" from player's permissions

        # Display the player's permissions after removing permissions
        broadcast "%player's permissions%"

This tutorial demonstrates how to check, add, and remove player permissions programmatically using a command.
In this example, the command /permissionTest checks if the player has a specific permission. It then adds and removes permissions from the player’s permission list and broadcasts the updated permissions to all players.

Let’s go through the code step by step:

First, we check if the player has the example.permission.test permission
We are utilizing the player does not have permission expression, which evaluates whether the player lacks a specific permission.

Second, we send a message to the player if they lack the permission.
If the player does not have the permission, we send a message informing them and use the stop keyword to halt further execution of the command.
This ensures that no subsequent actions in the command are performed.

Third, we add two permissions to the player’s permissions list.
The add expression is used to add permissions to the player’s permission list.
In this case, we add example.permission.A and example.permission.B to the player’s permissions.

Fourth, we display the player’s permissions after adding the permissions.
This outputs the player’s permissions to all players in the server.
The output will show the player’s permissions, including the newly added permissions.

Fifth, we remove the two permissions from the player’s permissions.
The remove expression is used to remove permissions from the player’s permission list.
In this case, we remove example.permission.A and example.permission.B from the player’s permissions.

Finally, we display the player’s permissions after removing the permissions.
This outputs the player’s permissions to all players in the server.
The output will show the player’s permissions, notice how the player is no longer granted the newly removed permissions.

This example demonstrates how to manage player permissions programmatically using the add and remove expressions.
You can use these expressions to check, add, and remove permissions as needed in your Skript code.

Tutorial written by @GuavaDealer