Setting and saving permissions

Discussion in 'Plugin Development' started by Laekh, Oct 16, 2012.

Thread Status:
Not open for further replies.
  1. Hello,

    I recently got into developing plugins,
    but as you may notice I'm pretty much a noob at it now.
    I do not lack the Java knowledge so it shouldn't get too hard.

    My question for you is how would I set a permission for a player?
    Currently I'm (as a practice) creating a plugin where a new player cannot build unless it has been given permission to do so by an OP that executed the /build player on/off command . (Like /build cupcakes69 on)

    Everything's fine but I just need to know how to set the permission for that player when that command is executed. I've only found methods to check if the player has the permission, not to set it.

    Thank you.

    Kind regards,
    Cupcakes.
     
  2. Offline

    RainoBoy97

    On the command, save/remove the player from a HashMap. And if they are in the HashMap, allow them to build.
     
  3. Thanks, got it to work a little more.
    Now how would I be able to save it?
    Because when I close and open the server, the hashmap resets.
     
  4. Offline

    daviga404

    If you want support for multiple permissions plugins like PermissionsEx and bPermissions, use Vault. With Vault you can add permissions to players by getting the permission provider
    Code:
    Permission permission;
    public boolean loadPermissions(){
    RegisteredServiceProvider<Permission> permissionProvider = pl.getServer().getServicesManager().getRegistration(net.milkbowl.vault.permission.Permission.class);
            if (permissionProvider != null) {
                permission = permissionProvider.getProvider();
            }
            return (permission != null);
    }
    and then give the player the permission
    Code:
    permission.playerAdd(player,"permission.string.here");
    or to remove it
    Code:
    permission.playerRemove(player,"permission.string.here");
    The method above works fine too, but if you want full compatibility with many permissions plugins, use Vault. Note that for the Vault API to work, the server owner needs to have the Vault plugin.
     
    Cupcakes69 likes this.
  5. Thank you, but I think I found an easier way.
    I'm using SLAPI. I think that's as good? Or isn't it?
     
Thread Status:
Not open for further replies.

Share This Page