Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Gives specified permission to certain player
- *
- * @param uuid - player uuid to give permission
- * @param permission - specified to give perm
- */
- public synchronized void givePermission(UUID uuid, String permission) {
- userManager.modifyUser(uuid, user -> user.data().add(Node.builder(permission).build()));
- }
- /**
- * Takes permissions from player
- *
- * @param uuid - from whom to take permission
- * @param permissions - permission which will be deleted
- */
- public synchronized void takePermissions(UUID uuid, String[] permissions) {
- for (String permission : permissions)
- takePermission(uuid, permission);
- }
- /**
- * Takes specified permission from player
- *
- * @param uuid - from whom to take permission
- * @param permission - specified to delete perm
- */
- public synchronized void takePermission(UUID uuid, String permission) {
- userManager.modifyUser(uuid, user -> {
- //get result of remove operation
- DataMutateResult mutateResult = user.data().remove(Node.builder(permission).build());
- //if the result is not successful, then repeat the operation until it becomes successful. (hardcode enabled xD)
- if (!mutateResult.wasSuccessful()) {
- takePermission(uuid, permission);
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment