Change use of String permissions to the permission enums

This commit is contained in:
ljacqu
2015-11-28 21:59:29 +01:00
parent e519906dc5
commit 364583e7db
18 changed files with 108 additions and 257 deletions
@@ -3,7 +3,7 @@ package fr.xephi.authme.permission;
/**
* AuthMe admin permissions.
*/
public enum AdminPermission implements PermissionsNode {
public enum AdminPermission implements PermissionNode {
REGISTER("authme.admin.register"),
@@ -3,7 +3,7 @@ package fr.xephi.authme.permission;
/**
* Common interface for AuthMe permission nodes.
*/
public interface PermissionsNode {
public interface PermissionNode {
/** Return the node of the permission, e.g. "authme.unregister". */
String getNode();
@@ -98,10 +98,10 @@ public class PermissionsManager {
/**
* Return the permissions system where the permissions manager is currently hooked into.
*
* @return Permissions system type.
* @return The name of the permissions system used.
*/
public PermissionsSystemType getUsedPermissionsSystemType() {
return this.permsType;
public String getUsedPermissionsSystemType() {
return this.permsType.getName();
}
/**
@@ -330,12 +330,16 @@ public class PermissionsManager {
* the player has to be OP in order to have the permission.
*
* @param player The player.
* @param permissionsNode The permissions node to verify.
* @param permissionNode The permissions node to verify.
*
* @return True if the player has the permission, false otherwise.
*/
public boolean hasPermission(Player player, PermissionsNode permissionsNode) {
return hasPermission(player, permissionsNode.getNode(), player.isOp());
public boolean hasPermission(Player player, PermissionNode permissionNode) {
return hasPermission(player, permissionNode, player.isOp());
}
public boolean hasPermission(Player player, PermissionNode permissionNode, boolean def) {
return hasPermission(player, permissionNode.getNode(), def);
}
/**
@@ -910,7 +914,7 @@ public class PermissionsManager {
return removeGroups(player, groupNames);
}
public enum PermissionsSystemType {
private enum PermissionsSystemType {
NONE("None"),
PERMISSIONS_EX("PermissionsEx"),
PERMISSIONS_BUKKIT("Permissions Bukkit"),
@@ -3,7 +3,7 @@ package fr.xephi.authme.permission;
/**
* AuthMe user permission nodes.
*/
public enum UserPermission implements PermissionsNode {
public enum UserPermission implements PermissionNode {
BYPASS_ANTIBOT("authme.bypassantibot"),