πPermissions
LabAPI provides a way to handle players through the use of permissions.
Check if a player has a permission
Checking if a player has a permission or multiple permissions is really easy using the permission provider extensions.
// We can check for one permission in specific.
bool hasPerm = player.HasPermissions("myplugin.permission");
// Or for multipe at the same time
bool hasPerms = player.HasPermissions("perm1", "perm2");
// In the case of multiple permissions we can check if the player has any of them
bool hasAnyPerm = player.HasAnyPermission("perm1", "perm2");Modifying permissions of a certain player
You can modify the permissions of a certain player using the following methods.
// Adds the given permissions to the player
player.AddPermissions("perm1", "perm2", "perm3");
// Removes the given permissions from the player
player.RemovePermissions("perm1", "perm2");Please note that each permission provider will take care of saving the changes in permissions.
Getting all the permissions of a player
You can use the following method to retrieve all the permissions of a player.
Permission Providers
Permission Providers are instances that handle a way of retrieving, saving and accessing permissions of all the players.
You can read more about permission providers in here:
πΏCustom ProviderYou can get all the permissions of a player based on their permission provider using the following methods.
LabAPI provides a DefaultPermissionsProvider, which uses a file with name permissions.yml where the permissions are saved.
Last updated
Was this helpful?