mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-12-19 07:07:55 +01:00
#872 Use Player#hasPermission instead of custom PermissionHandler method
- Use Player#hasPermission to check if a player has a permission - Remove hasPermission method from PermissionHandler implementations
This commit is contained in:
parent
b07e60a807
commit
dd27ff7daa
@ -198,13 +198,13 @@ public class PermissionsManager implements Reloadable {
|
|||||||
return true;
|
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()) {
|
if (!(sender instanceof Player) || !isEnabled()) {
|
||||||
return permissionNode.getDefaultPermission().evaluate(sender);
|
return permissionNode.getDefaultPermission().evaluate(sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
Player player = (Player) 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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasPermission(Player player, PermissionNode node) {
|
|
||||||
return ApiLayer.hasPermission(player.getWorld().getName(), CalculableType.USER, player.getName(), node.getNode());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasPermissionOffline(String name, PermissionNode node) {
|
public boolean hasPermissionOffline(String name, PermissionNode node) {
|
||||||
return ApiLayer.hasPermission(null, CalculableType.USER, name, node.getNode());
|
return ApiLayer.hasPermission(null, CalculableType.USER, name, node.getNode());
|
||||||
|
@ -29,12 +29,6 @@ public class GroupManagerHandler implements PermissionHandler {
|
|||||||
return true;
|
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
|
@Override
|
||||||
public boolean hasPermissionOffline(String name, PermissionNode node) {
|
public boolean hasPermissionOffline(String name, PermissionNode node) {
|
||||||
final AnjoPermissionsHandler handler = groupManager.getWorldsHolder().getWorldPermissionsByPlayerName(name);
|
final AnjoPermissionsHandler handler = groupManager.getWorldsHolder().getWorldPermissionsByPlayerName(name);
|
||||||
|
@ -28,16 +28,6 @@ public interface PermissionHandler {
|
|||||||
*/
|
*/
|
||||||
boolean hasGroupSupport();
|
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.
|
* Check if a player has permission by their name.
|
||||||
* Used to check an offline player's permission.
|
* Used to check an offline player's permission.
|
||||||
|
@ -20,11 +20,6 @@ public class PermissionsBukkitHandler implements PermissionHandler {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasPermission(Player player, PermissionNode node) {
|
|
||||||
return player.hasPermission(node.getNode());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasPermissionOffline(String name, PermissionNode node) {
|
public boolean hasPermissionOffline(String name, PermissionNode node) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -37,12 +37,6 @@ public class PermissionsExHandler implements PermissionHandler {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasPermission(Player player, PermissionNode node) {
|
|
||||||
PermissionUser user = permissionManager.getUser(player);
|
|
||||||
return user.has(node.getNode());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasPermissionOffline(String name, PermissionNode node) {
|
public boolean hasPermissionOffline(String name, PermissionNode node) {
|
||||||
PermissionUser user = permissionManager.getUser(name);
|
PermissionUser user = permissionManager.getUser(name);
|
||||||
|
@ -44,11 +44,6 @@ public class VaultHandler implements PermissionHandler {
|
|||||||
return vaultProvider.hasGroupSupport();
|
return vaultProvider.hasGroupSupport();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasPermission(Player player, PermissionNode node) {
|
|
||||||
return vaultProvider.has(player, node.getNode());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasPermissionOffline(String name, PermissionNode node) {
|
public boolean hasPermissionOffline(String name, PermissionNode node) {
|
||||||
return vaultProvider.has("", name, node.getNode());
|
return vaultProvider.has("", name, node.getNode());
|
||||||
|
@ -33,15 +33,6 @@ public class ZPermissionsHandler implements PermissionHandler {
|
|||||||
return true;
|
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
|
@Override
|
||||||
public boolean hasPermissionOffline(String name, PermissionNode node) {
|
public boolean hasPermissionOffline(String name, PermissionNode node) {
|
||||||
Map<String, Boolean> perms = zPermissionsService.getPlayerPermissions(null, null, name);
|
Map<String, Boolean> perms = zPermissionsService.getPlayerPermissions(null, null, name);
|
||||||
|
Loading…
Reference in New Issue
Block a user