mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-16 23:35:24 +01:00
Merge pull request #155 from AuthMe/872-use-player-haspermission
#872 Use Player#hasPermission instead of custom PermissionHandler method
This commit is contained in:
commit
c6b35688eb
@ -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());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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());
|
||||
|
@ -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);
|
||||
|
@ -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.
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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());
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user