Merge pull request #155 from AuthMe/872-use-player-haspermission

#872 Use Player#hasPermission instead of custom PermissionHandler method
This commit is contained in:
Gabriele C 2016-08-31 22:40:49 +02:00 committed by GitHub
commit c6b35688eb
8 changed files with 2 additions and 48 deletions

View File

@ -198,13 +198,13 @@ public class PermissionsManager implements Reloadable {
return true;
}
// Return if the player is an Op if sender is console or no permission system in use
// Return default if sender is not a player or no permission system is in use
if (!(sender instanceof Player) || !isEnabled()) {
return permissionNode.getDefaultPermission().evaluate(sender);
}
Player player = (Player) sender;
return handler.hasPermission(player, permissionNode);
return player.hasPermission(permissionNode.getNode());
}
/**

View File

@ -22,11 +22,6 @@ public class BPermissionsHandler implements PermissionHandler {
return true;
}
@Override
public boolean hasPermission(Player player, PermissionNode node) {
return ApiLayer.hasPermission(player.getWorld().getName(), CalculableType.USER, player.getName(), node.getNode());
}
@Override
public boolean hasPermissionOffline(String name, PermissionNode node) {
return ApiLayer.hasPermission(null, CalculableType.USER, name, node.getNode());

View File

@ -29,12 +29,6 @@ public class GroupManagerHandler implements PermissionHandler {
return true;
}
@Override
public boolean hasPermission(Player player, PermissionNode node) {
final AnjoPermissionsHandler handler = groupManager.getWorldsHolder().getWorldPermissions(player);
return handler != null && handler.has(player, node.getNode());
}
@Override
public boolean hasPermissionOffline(String name, PermissionNode node) {
final AnjoPermissionsHandler handler = groupManager.getWorldsHolder().getWorldPermissionsByPlayerName(name);

View File

@ -28,16 +28,6 @@ public interface PermissionHandler {
*/
boolean hasGroupSupport();
/**
* Check if a player has permission.
*
* @param player The player.
* @param node The permission node.
*
* @return True if the player has permission.
*/
boolean hasPermission(Player player, PermissionNode node);
/**
* Check if a player has permission by their name.
* Used to check an offline player's permission.

View File

@ -20,11 +20,6 @@ public class PermissionsBukkitHandler implements PermissionHandler {
return true;
}
@Override
public boolean hasPermission(Player player, PermissionNode node) {
return player.hasPermission(node.getNode());
}
@Override
public boolean hasPermissionOffline(String name, PermissionNode node) {
return false;

View File

@ -37,12 +37,6 @@ public class PermissionsExHandler implements PermissionHandler {
return true;
}
@Override
public boolean hasPermission(Player player, PermissionNode node) {
PermissionUser user = permissionManager.getUser(player);
return user.has(node.getNode());
}
@Override
public boolean hasPermissionOffline(String name, PermissionNode node) {
PermissionUser user = permissionManager.getUser(name);

View File

@ -44,11 +44,6 @@ public class VaultHandler implements PermissionHandler {
return vaultProvider.hasGroupSupport();
}
@Override
public boolean hasPermission(Player player, PermissionNode node) {
return vaultProvider.has(player, node.getNode());
}
@Override
public boolean hasPermissionOffline(String name, PermissionNode node) {
return vaultProvider.has("", name, node.getNode());

View File

@ -33,15 +33,6 @@ public class ZPermissionsHandler implements PermissionHandler {
return true;
}
@Override
public boolean hasPermission(Player player, PermissionNode node) {
Map<String, Boolean> perms = zPermissionsService.getPlayerPermissions(player.getWorld().getName(), null, player.getName());
if (perms.containsKey(node.getNode()))
return perms.get(node.getNode());
else
return node.getDefaultPermission().evaluate(player);
}
@Override
public boolean hasPermissionOffline(String name, PermissionNode node) {
Map<String, Boolean> perms = zPermissionsService.getPlayerPermissions(null, null, name);