#784 Perform bypass purge permission check with OfflinePlayer objects

- Move permission check inside PurgeTask to perform it with OfflinePlayer objects instead of lowercase names
- Move purge members into child "purge" package
- Unify online and offline default permission behavior in DefaultPermission
This commit is contained in:
ljacqu
2016-07-17 11:54:22 +02:00
parent b439a0391c
commit 2a4cda0709
18 changed files with 102 additions and 149 deletions
@@ -12,6 +12,7 @@ import fr.xephi.authme.permission.handlers.VaultHandler;
import fr.xephi.authme.permission.handlers.ZPermissionsHandler;
import fr.xephi.authme.util.StringUtils;
import org.anjocaido.groupmanager.GroupManager;
import org.bukkit.OfflinePlayer;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -210,22 +211,33 @@ public class PermissionsManager implements Reloadable {
* Check if a player has permission for the given permission node. This is for offline player checks. If no permissions
* system is used, then the player will not have permission.
*
* @param name The name of the player.
* @param permissionNode The permission node to verify.
* @param player The offline player
* @param permissionNode The permission node to verify
*
* @return
* @return true if the player has permission, false otherwise
*/
public boolean hasPermissionOffline(String name, PermissionNode permissionNode) {
public boolean hasPermissionOffline(OfflinePlayer player, PermissionNode permissionNode) {
// Check if the permission node is null
if (permissionNode == null) {
return true;
}
if (!isEnabled()) {
return permissionNode.getDefaultPermission().evaluateOffline(name);
return permissionNode.getDefaultPermission().evaluate(player);
}
return handler.hasPermission(name, permissionNode);
return handler.hasPermissionOffline(player.getName(), permissionNode);
}
public boolean hasPermissionOffline(String name, PermissionNode permissionNode) {
if (permissionNode == null) {
return true;
}
if (!isEnabled()) {
return permissionNode.getDefaultPermission().evaluate(null);
}
return handler.hasPermissionOffline(name, permissionNode);
}
/**