LuckPerms

LuckPerms

41.4k Downloads

LuckPerms Doesn't Fully Use Vault's API

ethsmith opened this issue ยท 4 comments

commented

Description

My plugin PromotionEssentials works with every other permissions plugin for removing and adding ranks via Vault's API. However, LuckPerms seems to ignore Vaults API for removing the parent rank / other ranks and then applying a new one.

For example, this would remove all other groups and then add a new group for a plugin such as GroupManager or Pex when using Vaults Permission service:

   ` // Get permissions provider
    Permission permissions = plugin.getPermissionProvider().getProvider();

    // Remove all groups
    for (String role : permissions.getPlayerGroups(player)) {
        permissions.playerRemoveGroup(player, role);
    }

    // Add new group
    permissions.playerAddGroup(player, group);

`

LuckPerms ignores the request like you intended to only support Vault to the very minimum and make plugins use LuckPerms API as a whole other soft dependency. (The function to remove the player primary group also does not work for LuckPerms but does for every other promotion plugin.)

Reproduction steps

  1. Use VaultAPI
  2. Use Above Code with Vaults Permission Registered Service
  3. LuckPerms will ignore the function call

Expected behaviour

LuckPerms to fully support the Vault API so that plugin developers do not have to check for specifically LuckPerms and add new code just for it.

Environment details

  • Server type/version: Any version. I havee specifically tested 1.8, 1.12.2, and 1.16
  • LuckPerms version: latest, any
commented

LuckPerms aims to support Vault fully - the notion that I would purposely implement it badly in order to to encourage usage of the native LP API is pretty crazy...

Anyway, I suspect the issue is being caused by an internal requirement in LP that all users must have at least one group. If a user is left in a state where they have no groups, they are automatically added back to the default group.

Since each Vault method call is treated as a distinct operation, when you clear all groups, LP doesn't know that you're going to be shortly adding one back.

A suggestion that will resolve this, and also retain compatibility with all other plugins would be to adjust your code as follows:

Permission permissions = plugin.getPermissionProvider().getProvider();

// Add new group
permissions.playerAddGroup(player, group);

// Remove all groups, except the one we just added
for (String existing : permissions.getPlayerGroups(player)) {
  if (!existing.equalsIgnoreCase(group) {
    permissions.playerRemoveGroup(player, existing);
  }
}

I think that will work, but of course please let me know if it doesn't / if you have any further issues, and I will happily look into it. :)

commented

Pretty sure that wouldn't work as if you still remove all groups with that it still adds them back to the default group.

I'd propose adding the group first and then removing all others.

commented

Ah, you're absolutely right - just updated to fix that :)

commented

Thanks. I didn't mean purposefully add it badly. Just didn't know if you implemented only the parts needed to hook with Vault and then expected people to use the API due to a change in how you do permissions or something.