Solved Permission question

Discussion in 'Plugin Development' started by L33m4n123, Sep 18, 2013.

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

    L33m4n123

    Hey!

    In the Plugin I am currently writing I want that I can go ahaed and make in the permission plugin of my choice for example

    'can.have.10'

    While the last number is variable. I know that I can do for example

    Code:java
    1. if player.hasPermissions("can.have.10") {
    2. player.sendMessage("You can have 10");
    3. }


    However. What I want to achieve is (and that is where you guys come in. I got no Idea IF it is possible with setting permissions only)

    Code:java
    1. if player.hasPermissions("can.have." + x) {
    2. player.sendMessage("You can have " + x);
    3. }


    Where the 'X' is variable to what ever the person that sets up the permissions in the end chan choose.
     
  2. Offline

    Assult

    That is possible if thats what youre asking.
     
  3. Offline

    L33m4n123

    Mind giving me a typ? Because I got not even the slightest Idea how to achieve this since I need to ask for the full permissionNode within the plugin [at least AFAIK] and checking from can.has.1 up to can.has.1000 is not really what I want to do^^
     
  4. Set<PermissionAttachmentInfo> perms = player.getEffectivePermissions();
    for (PermissionAttachmentInfo perm : perms)
    {
    if (perm.getPermission().startsWith("can.have.") && perm.getValue())
    {
    String x = perm.getPermission().substring("can.have.".length());
    player.sendMessage("You can have " + x);
    }
    }
     
    L33m4n123 likes this.
  5. Offline

    L33m4n123

    ferrybig

    D'oh Searched for player.getPermission in the API not EffectivePermission. ^^
    Thanks alot
     
Thread Status:
Not open for further replies.

Share This Page