Adding permissions to a player with vault

Discussion in 'Plugin Development' started by JOPHESTUS, Sep 1, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    JOPHESTUS

    Hey,

    I am trying to add permissions to a player using vault
    Code:
    if (econ.has(player.getName(), price)) {
     
     
    econ.withdrawPlayer(player.getName(), price);
     
    perms.playerAdd(player, node);
    player.sendMessage(ChatColor.GOLD + "[BuyNodes] " + ChatColor.GREEN + "You have sucessfully bought " + node);
     
    
    This is the code I am using to do it, but it's not giving the user the permission node :(
    Please tell me what I am doing wrong, and how to fix it.

    Thanks,
    JOPH

    It worked with Pex, but not Groupmanager :eek:

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 28, 2016
  2. Offline

    jamietech

    JOPHESTUS
    Why do you need to do it with Vault? Why not with the Bukkit API?
     
  3. Offline

    JOPHESTUS

    Because this involves giving a permission to a player, and using economies. Vault supports most permission plugins and economies so it's the ideal way to go. I don't think you can actually give a user a permission wit the bukkit api alone.
     
  4. Offline

    jamietech

    How do you think permissions plugins work? :p

    But it seems vault may be the best choice here unless you want to offer both.
     
  5. Offline

    JOPHESTUS

    Well, I'd have to hook into the permission plugins for that, Vault already does that so its so much easier
     
  6. Offline

    ase34

    Code:java
    1. RegisteredServiceProvider<Permission>permissionProvider = getServer().getServicesManager().getRegistration(net.milkbowl.vault.permission.Permission.class);
    2. Permission permission = permissionProvider.getProvider();
    3.  
    4. foreach (World world: getServer().getWorlds()) {
    5. permission.addPlayer(world, player, permission_title);
    6. }


    See more in the Vault javadocs
     
  7. Offline

    Sleaker

    As explained elsewhere, and the javadocs, If you want to add a global permission, you pass null for the world. If you want to add a permission to all available worlds, and the permission system doesn't support global permissions, you'll need to use the above mentioned method. Although, permission_title doesn't seem like a valid permission.
     
  8. Offline

    md_5

    There is no definition of '.' as a separator in permissions. Unlike in configs etc etc, in permissions it bares to special meaning.
     
  9. Offline

    Sleaker

    Right, but using TITLES as permissions doesn't seem valid. I'm unaware of a permission system that uses the bukkit backend to apply/check titles. My comment had nothing to do with the use of an '_'
     
  10. Offline

    jamietech

    I would assume he meant that permission_title is a String variable holding the permission node.
     
  11. Offline

    Sleaker

    Oooh that makes a lot more sense, haha.
     
Thread Status:
Not open for further replies.

Share This Page