diff --git a/src/main/java/fr/xephi/authme/permission/AdminPermission.java b/src/main/java/fr/xephi/authme/permission/AdminPermission.java index 470d3a4bb..c04743ba1 100644 --- a/src/main/java/fr/xephi/authme/permission/AdminPermission.java +++ b/src/main/java/fr/xephi/authme/permission/AdminPermission.java @@ -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; + } } diff --git a/src/main/java/fr/xephi/authme/permission/PermissionNode.java b/src/main/java/fr/xephi/authme/permission/PermissionNode.java index ba216914f..8b38f1a0d 100644 --- a/src/main/java/fr/xephi/authme/permission/PermissionNode.java +++ b/src/main/java/fr/xephi/authme/permission/PermissionNode.java @@ -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(); + } diff --git a/src/main/java/fr/xephi/authme/permission/PermissionsManager.java b/src/main/java/fr/xephi/authme/permission/PermissionsManager.java index 26ef9af50..02b4194b2 100644 --- a/src/main/java/fr/xephi/authme/permission/PermissionsManager.java +++ b/src/main/java/fr/xephi/authme/permission/PermissionsManager.java @@ -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 nodes, boolean def) { diff --git a/src/main/java/fr/xephi/authme/permission/PlayerPermission.java b/src/main/java/fr/xephi/authme/permission/PlayerPermission.java index 8ae97407f..8eddb8028 100644 --- a/src/main/java/fr/xephi/authme/permission/PlayerPermission.java +++ b/src/main/java/fr/xephi/authme/permission/PlayerPermission.java @@ -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; + } }