aberdeener / luckperms-api-wrapper
PHP wrapper for LuckPerms REST API
v1.0.0
2023-03-02 10:01 UTC
Requires
- guzzlehttp/guzzle: ^7.4.5
- illuminate/collections: ^9.21
- illuminate/container: ^9.22
Requires (Dev)
- phpstan/phpstan: ^1.8
- phpunit/phpunit: ^9.5
- roave/security-advisories: dev-latest
- symfony/var-dumper: ^6.1
This package is auto-updated.
Last update: 2024-10-29 00:01:47 UTC
README
Examples
<?php use LuckPermsAPI\LuckPermsClient; use LuckPermsAPI\Config\ConfigBuilder; use LuckPermsAPI\Repository\Search; use LuckPermsAPI\QueryOptions\QueryOptions; use LuckPermsAPI\QueryOptions\QueryMode; use LuckPermsAPI\QueryOptions\QueryFlag; use LuckPermsAPI\Context\Context; use LuckPermsAPI\Context\ContextKey; $session = LuckPermsClient::make( ConfigBuilder::make() ->withApiKey('<your-api-key>') ->withBaseUri('<your-rest-api-url>') ->build() ); // Get a user $user = $session->userRepository()->load('<user-uuid>'); // Get all user UUIDs $uuids = $session->userRepository()->allIdentifiers(); // Get a group $group = $session->groupRepository()->load('<group-name>'); // Get all group names $names = $session->groupRepository()->allIdentifiers(); // Search for a group (or user) with the `minecraft.command.ban` node key $groups = $session->groupRepository()->search(Search::withKey('minecraft.command.ban')); // Perform a permission check on a user (or group) $permissionCheck = $user->hasPermission('permission.node'); if ($permissionCheck->result()) { // Yay! $node = $permissionCheck->node(); echo "User has permission via node {$node->key()}"; } // Apply QueryOptions to a permission check $permissionCheck = $group->hasPermission( 'permission.node', QueryOptions::make() ->setMode(QueryMode::Contextual) ->withFlag(QueryFlag::IncludeNodesWithoutServerContext) ->withContext(new Context(ContextKey::Dimension, 'nether')) );