Solved Adding permissions to players using Vault

Discussion in 'Plugin Development' started by NewDevOnTheBlock, May 7, 2015.

Thread Status:
Not open for further replies.
  1. I'm sure this same title has been used before, and I've seen the thread. None of them are working for me, and I've tried about 5 different methods of doing it. I am using Vault for my plugin (economy), and have tried using Vaults linking method, but I'm getting an error on the RegisteredServiceProvider.

    I always see that there is an easy way to add a permission to a player using the Bukkit API, and have tried peoples examples it's just that they do not work.

    Anyone have a good tutorial (possible video) of how to use Vault to give permissions, or using the Bukkit API.

    Much appreciated!
     
  2. Offline

    Konato_K

    @NewDevOnTheBlock As far I know Vault can't give permissions itself, but tells an actual permission plugin to add the permission, if there is no permission plugin then Vault will fail.

    For Bukkit super perms, I think this tutorial covers well what is needed.
     
  3. @Konato_K So, I tried to follow that tutorial. I added everything it asked for, but I'm not sure why I even need a HashMap. In the documentation it says to create a HashMap to store it, but I don't need to store the players UUID, Name, or the permission I want to give the player. What I'm trying to get to... Is that it didn't work for me.
     
  4. Offline

    Konato_K

    @NewDevOnTheBlock Well, that's if you need to use the attachment for something in the future (setting another permission, removing some, etc)

    If you just want to give a permission you can do this
    Code:
    player.addAttachment(pluginInstance, "some.permission", true);
     
  5. @Konato_K Hmm... So what you gave me is working, but it's not adding it to the PermissionsEx plugin file I am using. Would vault handle adding the player to a permissions file like that? Meaning.. I should use vault over the Bukkit super perms.
     
  6. Offline

    Konato_K

    @NewDevOnTheBlock Yes, it won't since Pex is not aware of this permission, you'll either link with Pex or link with Vault, both should work to store the permission permanently in the current permission plugin (Pex in this case)
     
  7. Ended up solving the problem.

    Placed the Vault method
    Code:
        private boolean setupPermissions() {
            RegisteredServiceProvider<Permission> permissionProvider = getServer().getServicesManager().getRegistration(Permission.class);
            if (permissionProvider != null) {
                this.permission = ((Permission)permissionProvider.getProvider());
            }
            return this.permission != null;
        }
    into the class, and...
    Code:
    setupPermissions();
    Into the onEnable() method
    Code:
    Permission permission = null;
    As a global class level... And finally...
    Code:
    this.permission.playerAdd(player, permission);
    To add the player to the permissions plugin.
     
    MnMaxon likes this.
Thread Status:
Not open for further replies.

Share This Page