Question Question about permissions

  • After careful consideration and due to limited usage, we’ve made the decision to discontinue the PaperMC forums. Moving forward, we recommend using Hangar for plugin uploads, and for all other community discussions and support, please join us on Discord.

MCmitNoah

New member
Feb 14, 2022
7
1
3
Hello,

so I am currently working on a plugin with my firends and I use the player.hasPermission() method to check if a player has the required permission.

Now I am asking if there is a way to check if a player has a child permission but not the parent permission.

I know its sounds weird but i have an example here:

Java:
if (!player.hasPermission("parent")) {
    player.sendMessage(Component.text("You dont have enough permissions!"));
    return false;
}

//check if args are actually 1 and send message if not. "usage: ....."

if ("children1".equalsIgnoreCase(args[0])) {
    if (!player.hasPermission("parent.children1")) {
        player.sendMessage(Prefix.TRACKER
            .append(Component.text("You dont have enough permissions!")));
        return false;
    }
    
    //do something
}

if ("children2".equalsIgnoreCase(args[0])) {
    if (!player.hasPermission("parent.children2")) {
        player.sendMessage(Component.text("You dont have enough permissions!"));
        return false;
    }

    //do something
}

so what I expect here to happen is that a player shouldn't be able to see the "usage: ....." message if they dont have any of the 2 child perms. Which should work, yeah
but when a player has child1 they should be able to go past the first if but they dont.

Any suggestions?
 
Version Output
This server is running Paper version git-Paper-152 (MC: 1.18.1) (Implementing API version 1.18.1-R0.1-SNAPSHOT) (Git: 78999b5)
You are 45 version(s) behind
Download the new version at: https://papermc.io/downloads
Previous version: git-Paper-400 (MC: 1.17.1)