deh-cheesekake
deh-cheesekake

Reputation: 31

Bukkit plugin multiple permissions not working

I am trying to make it so that if a player is opped or has atleast one of two permission nodes, they are allowed to execute a command

Player player = (Player) sender;

if (! (player.hasPermission("perm.node1")) || (player.hasPermission("perm.node2")) ) { sender.sendMessage(ChatColor.RED + "Access denied!"); return true; }

I am testing this plugin on a server with the same bukkit build as the one the plugin was compiled with and I am opped ingame, I have not given myself any of the permissions

With only one permission node if (! (player.hasPermission("perm.node1"))) being required, the code works fine but with both permissions listed, it replied with "Access denied!".

The words "Access denied!" appear nowhere else in the code so it must be coming from this statement

I have tried adding another or to the if statement player.isOp(), but it has no effect

If I am in a user group with perm.node1 I can execute the command in question without getting "Access denied!" but if I have perm.node2, I do get "Access denied!", regardless of if I have perm.node1

Upvotes: 0

Views: 560

Answers (1)

August
August

Reputation: 12558

Your conditional will evaluate to true (and deny access) if the player has permission for "perm.node2".

Try this:

if (!player.hasPermission("perm.node1") && !player.hasPermisson("perm.node2")) {
    // deny access...
}

Upvotes: 1

Related Questions