Guest User

Untitled

a guest
Mar 1st, 2023
18
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. /**
  2. * Gives specified permission to certain player
  3. *
  4. * @param uuid - player uuid to give permission
  5. * @param permission - specified to give perm
  6. */
  7. public synchronized void givePermission(UUID uuid, String permission) {
  8. userManager.modifyUser(uuid, user -> user.data().add(Node.builder(permission).build()));
  9. }
  10.  
  11. /**
  12. * Takes permissions from player
  13. *
  14. * @param uuid - from whom to take permission
  15. * @param permissions - permission which will be deleted
  16. */
  17. public synchronized void takePermissions(UUID uuid, String[] permissions) {
  18. for (String permission : permissions)
  19. takePermission(uuid, permission);
  20. }
  21.  
  22. /**
  23. * Takes specified permission from player
  24. *
  25. * @param uuid - from whom to take permission
  26. * @param permission - specified to delete perm
  27. */
  28. public synchronized void takePermission(UUID uuid, String permission) {
  29. userManager.modifyUser(uuid, user -> {
  30. //get result of remove operation
  31. DataMutateResult mutateResult = user.data().remove(Node.builder(permission).build());
  32. //if the result is not successful, then repeat the operation until it becomes successful. (hardcode enabled xD)
  33. if (!mutateResult.wasSuccessful()) {
  34. takePermission(uuid, permission);
  35. }
  36. });
  37. }
Advertisement
Add Comment
Please, Sign In to add comment