Vault

Vault

7M Downloads

Permission#getPlayerGroups(Player) is inconsistent

Opened this issue ยท 1 comments

commented

Assuming the following code is present within a class, the method #onEnable() is guaranteed to be executed, Vault is guaranteed to be present, the Player 'TheLunarFrog' exists and is online (reference the #issue() method):

private Permission permission;

public void onEnable(){
    this.setupPermissions();
    this.issue();
}

private boolean setupPermissions(){
    RegisteredServiceProvider<Permission> permissionProvider = Bukkit.getServer().getServicesManager().getRegistration(net.milkbowl.vault.permission.Permission.class);
    if(permissionProvider != null)
        this.permission = permissionProvider.getProvider();
    return (this.permission != null);
}

public void issue(){
    this.permission.getPlayerGroups(Bukkit.getPlayerExact("TheLunarFrog"));
}

... and PermissionsEX is present with the structure:
A is default and inherits nothing, B inherits A, and C inherits neither...

If TheLunarFrog is a member of A, Vault will return A. If TheLunarFrog is part of B, it will return only B, and not A. This is fine, but...

Suppose I decided I wanted to switch from PermissionsEX to GroupManager for some reason. The group inheritance is the same, where A inherits nothing and is default, B inherits A, and C inherits neither:

If TheLunarFrog is only part of group B, Permission#getPlayerGroups(Player) will return both B and A.

For both examples, invoking the method if the player is in only C, it returns only C.

Please make this method more consistent, or create methods to do both of these actions. Personally, I use this method to get the groups which are explicitly defined for a given player, meaning it could be more than one group, and not just the primary group (or I'd just use Permission#getPrimaryGroup(Player)), but not the inherited groups.

commented

The code provided for GM is a call-through to their own method. This is not an issue in Vault:

https://github.com/MilkBowl/Vault/blob/master/src/net/milkbowl/vault/permission/plugins/Permission_GroupManager.java#L308

This is also the same for PEX:

https://github.com/MilkBowl/Vault/blob/master/src/net/milkbowl/vault/permission/plugins/Permission_PermissionsEx.java#L190

different permission Plugins operate under different ideals of what constitutes having a group, Vault makes no gaurantee that getGroups will or wont return inherited groups because it has no control over this, and can't regulate permission plugins directly.