Giving a playyer a permission

Discussion in 'Spigot Plugin Development' started by NaJated, May 16, 2015.

Thread Status:
Not open for further replies.
  1. Hey all, how would I give a player a permissions? I'm using PermissionsEx.
    I looked through the API and can't see anything.
    • Funny Funny x 1
  2. To give them a permission:

    /pex user <user> add <permission>

    to remove a permission:

    /pex user <user> remove <permission>
    • Funny Funny x 1
  3. foncused

    Moderator Patron

  4. Ye, but there's no way to 'add' a permission to that player. I want to use pex and as if I did pex user <player> add <perm>. Wait, couldn't I just dispatchCmd?

    @JoshJW 1v1 me Roblox.

    Doesn't say anything about adding a perm to a player.
  5. foncused

    Moderator Patron

    I add permissions to players doing what I do, not sure what you mean. If you are looking to use a command to add a permission, that is already doable with PermissionsEx.
  6. It certainly does, it talks about PermissionAttachments.

    However you're asking about plugin-specific support. Rather than worry about the type of perms plugin, use Vault and then assign permissions through there, so that your assignments persist.

    If you don't need someone's permissions to persist through a shutdown then you can just use attachments.

    Adding a permission via a command is liable to breaking under any future changes, I don't recommend it.
  7. Read the "Assigning Permissions" section.

    Infact, you can use the Vault API:

    Code (Java):
    public static Permission perms = null;
        private boolean setupPermissions() {
            RegisteredServiceProvider<Permission> rsp = getServer().getServicesManager().getRegistration(Permission.class);
            perms = rsp.getProvider();
            return perms != null;
    (Be sure to import Permission from Vault, not Bukkit. Run setUpPermissions() onEnable).

    And, manage permissions with:
    Code (Java):
    perms.playerAdd(player, permission);
    perms.playerRemove(player, permission);
    • Agree Agree x 1
  8. foncused

    Moderator Patron

    I use the Vault API and can confirm that it works. :)
  9. No need to make the perms variable public and static. In fact, very bad idea.
    • Agree Agree x 1
  10. I copied that code straight from the Vault page. If it is defined as public and static, maybe there's a reason.
  11. Yeah, the reason is that it's a terrible example.
    • Agree Agree x 1
  12. @IPv420 i got a linux pc
    l o l
    sooooo roblox no werrrrrk :(
  13. Or, y'know, use Vault and support both plus more plugins.
  14. But if I use the vault api to add a perm. Won't pex not pick it up and add it to that players' permissions?
  15. vault would do just fine.
  16. For add a permission: /pex user (or group) NAME add PERMISSION
  17. I think OP wants to give a permission to a player using API, and not via a command.
    • Agree Agree x 1
  18. Okay, I'll look into it :)
  19. If you are just trying to add permissions either to a player or group, mark the PermissionsEx as a depencency in your plugin.yml, import the PermissionsEx jar to your project and:

    Code (Text):
    public void givePermissionToPlayer(UUID id, String perm){
        public void givePermissionToGroup(String groupName, String perm){
Thread Status:
Not open for further replies.