PermissionsEx Api Example

Discussion in 'Plugin Development' started by javoris767, Nov 22, 2011.

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

    javoris767

    Can anyone show me how PermissionsEx's Permissions API is added into a plugin? :S
     
  2. Offline

    Daniel Heppner

    Player.hasPermission();
     
  3. Offline

    ArcheCane

    Code:java
    1. player.hasPermission("node.here")


    EDIT: Ninja'd.
     
  4. Offline

    javoris767

    o thought it was all this


    Code:
    if(Bukkit.getServer().getPluginManager().isPluginEnabled("PermissionsEx")){
        PermissionManager permissions = PermissionsEx.getPermissionManager();
    
        // Permission check
        if(permissions.has(player, "yourplugin.permission")){
        // yay!
        } else {
        // houston, we have a problem :)
        }
    } else {
       Logger.getLogger("Minecraft").warning("PermissionsEx plugin are not found.");
    } //Written by: t3hk0d3
    
    Want to edit Permissions of Users/Groups? Here is a Method that can do both add/remove for both users/groups:
    
    public void SetPermission(String Permission, String Name, String world, boolean Allow, boolean isUser){
            PermissionManager pex = PermissionsEx.getPermissionManager();
            PermissionsEntity entity = isUser ? pex.getUser(Name) : pex.getGroup(Name);
    
            if(Allow && !pex.getUser(Name).has(Permission, world)){
                entity.addPermission(Permission, world);
            } else if (!Allow) {
                entity.removePermission(Permission, world);
            }
    
    } //Written by: Killie01, refactoring by t3hk0d3
    
     
  5. Offline

    Daniel Heppner

    Why did you use a spoiler for that? Put it in code blocks, please.
    Also, that would be for the Pex API. Pex also supports SuperPerms, so you can use Player.hasPermission();
     
  6. Offline

    javoris767

    PermissionsEX doesnt work with my node :(
     
  7. Offline

    Daniel Heppner

    Explain.
     
  8. Offline

    javoris767

    Code:java
    1. if(player.hasPermission("pr3d.admin") || (player.hasPermission("pr3d.creative") && (player.hasPermission("pr3d.survival") && player.isOp())))
    2. {


    Code:
        Host:
            default: false
            info:
                prefix: ''
                suffix: '&f'
                build: true
                rank: '11'
            inheritance:
            - Admin
            permissions:
            - pr3d.admin
            - '*''
    and i tested it in game i dont have permission
    It works for PermissionsBukkit
     
  9. Offline

    halley

    Are you in group Host ?

    Learn to use the /pex user <name> toggle debug command: it will help you debug your plugin (you will see requests for specific permissions) and also debug your permission setup (you will see if the permission checks succeed or fail).

    Also, using the /pex user <name> command will dump out what permissions a player has, and which group(s) gave them.

    This is an ugly expression, easily confused with all the mixed ANDs and ORs.

    This is equivalent code to your expression. I'm not saying it's prettier, but I wanted to see if the logic is what you intended.

    Code:
    boolean allowed = false;
    if (player.hasPermission("pr3d.admin"))
        allowed = true;
    else if (player.hasPermission("pr3d.creative") &&
             player.hasPermission("pr3d.survival") &&
             player.isOp())
        allowed = true;
    if (allowed)
        :
    
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 21, 2016
Thread Status:
Not open for further replies.

Share This Page