mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-28 05:05:14 +01:00
- Add wildcard attribute to permission nodes that are checked additionally in the permissions manager
This commit is contained in:
parent
f99bba4b5f
commit
63a7cd00df
@ -103,23 +103,13 @@ public enum AdminPermission implements PermissionNode {
|
||||
/**
|
||||
* Give access to all admin commands.
|
||||
*/
|
||||
ALL("authme.admin.*");
|
||||
ADMIN_ALL("authme.admin.*");
|
||||
|
||||
/**
|
||||
* Permission node.
|
||||
* The permission node.
|
||||
*/
|
||||
private String node;
|
||||
|
||||
/**
|
||||
* Get the permission node.
|
||||
*
|
||||
* @return Permission node.
|
||||
*/
|
||||
@Override
|
||||
public String getNode() {
|
||||
return node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
@ -128,4 +118,14 @@ public enum AdminPermission implements PermissionNode {
|
||||
AdminPermission(String node) {
|
||||
this.node = node;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNode() {
|
||||
return node;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PermissionNode getWildcardNode() {
|
||||
return ADMIN_ALL;
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,18 @@ package fr.xephi.authme.permission;
|
||||
*/
|
||||
public interface PermissionNode {
|
||||
|
||||
/** Return the node of the permission, e.g. "authme.unregister". */
|
||||
/**
|
||||
* Return the node of the permission, e.g. "authme.player.unregister".
|
||||
*
|
||||
* @return The name of the permission node
|
||||
*/
|
||||
String getNode();
|
||||
|
||||
/**
|
||||
* Return the wildcard node that also grants the permission.
|
||||
*
|
||||
* @return The wildcard permission node (e.g. "authme.player.*")
|
||||
*/
|
||||
PermissionNode getWildcardNode();
|
||||
|
||||
}
|
||||
|
@ -314,7 +314,8 @@ public class PermissionsManager implements PermissionsService {
|
||||
}
|
||||
|
||||
public boolean hasPermission(Player player, PermissionNode permissionNode, boolean def) {
|
||||
return hasPermission(player, permissionNode.getNode(), def);
|
||||
return hasPermission(player, permissionNode.getNode(), def)
|
||||
|| hasPermission(player, permissionNode.getWildcardNode(), def);
|
||||
}
|
||||
|
||||
public boolean hasPermission(Player player, Iterable<PermissionNode> nodes, boolean def) {
|
||||
|
@ -83,23 +83,13 @@ public enum PlayerPermission implements PermissionNode {
|
||||
/**
|
||||
* Permission to use all player (non-admin) commands.
|
||||
*/
|
||||
ALL_COMMANDS("authme.player.*");
|
||||
PLAYER_ALL("authme.player.*");
|
||||
|
||||
/**
|
||||
* Permission node.
|
||||
* The permission node.
|
||||
*/
|
||||
private String node;
|
||||
|
||||
/**
|
||||
* Get the permission node.
|
||||
*
|
||||
* @return Permission node.
|
||||
*/
|
||||
@Override
|
||||
public String getNode() {
|
||||
return node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
@ -108,4 +98,14 @@ public enum PlayerPermission implements PermissionNode {
|
||||
PlayerPermission(String node) {
|
||||
this.node = node;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNode() {
|
||||
return node;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PermissionNode getWildcardNode() {
|
||||
return PLAYER_ALL;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user