Get a permission node! not that simple

Discussion in 'Plugin Development' started by EnchantedMiners, Nov 6, 2014.

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

    EnchantedMiners

    So what i want to do is a shop plugin where if the player have permission shop.multiple.2 when the player sells it will multiple the money for that number so besically money * multiplier
    Hope someone can help!
    Thanks!
     
  2. Offline

    Skionz

    EnchantedMiners
    Code:
    if(player.hasPermission("shop.multiple.2) {
      //multiply by 2
    }
    ?
     
  3. Offline

    Watto

  4. Offline

    EnchantedMiners

    Watto yes you are correct so i don't have to be going back to code the plugin ever again ;)
     
  5. Offline

    Skionz

    Watto else ifs? I'm sure he won't want people to be able to get * 1000 so he could just to a bunch of if statements
     
  6. Offline

    EnchantedMiners

    Skionz that would be ........ not clean at all and i also want to do double not just int so i would have to do 1000 statements and that would be just not cool xD i forgot the right word for this
     
  7. Offline

    Watto

    Skionz EnchantedMiners

    If you want to limit them you could do a for-loop too. For loop would be cleaner than a cluster of else ifs.
     
  8. Offline

    EnchantedMiners

    Watto but how would i check for the permission doe xD?
     
  9. Offline

    Watto

    EnchantedMiners

    I don't specifically want to spoon feed you so:

    For loop

    check if player.hasPermission("example.perm." + forLoopIndex)
    if it does number * forLoopIndex

    This won't work with doubles however..
    If you want to use doubles, surely there is a way to get all player permissions (haven't checked) if there is you'll have to iterate through them all and check if the player as the specific permission with the number on the end
     
  10. Offline

    Skionz

    EnchantedMiners Just checked the javadocs and I found this (never used it before)
    Code:
    Permissible#getEffectivePermissions();
    Again I have never used it so I am not positive this would work but you could do something like this
    Code:
    for(PermissionAttachmentInfo perm : player.getEffectivePermissions()) {
      if(perm.getPermission().startsWith("shop.multiple")) {
        double multiply = Double.parseDouble(perm.getPermission().replace("shop.multiple.", ""));
      }
    }
     
  11. Offline

    EnchantedMiners

    Watto Skionz i think it will work thanks for help!
    and i think i have Skionz on eclipse saros lol
    EDIT: Woah Skionz that make sense let me try it
     
  12. Offline

    Watto

    EnchantedMiners My edit was basically telling you to do what Skionz said except without the spoonfeed
     
  13. Offline

    Skionz

    Watto It was 3 lines of code. Its not like I added the try and catch in there for him.
     
  14. Offline

    EnchantedMiners

    Watto just notice :) Thanks for the help saved lot of time and now ik something new :)
     
Thread Status:
Not open for further replies.

Share This Page