From 922359d6e6ba7e87ce7e62a24cb07a678c234712 Mon Sep 17 00:00:00 2001 From: muhammadeko Date: Sat, 14 May 2022 07:50:36 +0700 Subject: [PATCH] add negative permission check --- src/main/java/emu/grasscutter/game/Account.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/emu/grasscutter/game/Account.java b/src/main/java/emu/grasscutter/game/Account.java index 6c3daf61a..39fb8969e 100644 --- a/src/main/java/emu/grasscutter/game/Account.java +++ b/src/main/java/emu/grasscutter/game/Account.java @@ -144,12 +144,20 @@ public class Account { } public boolean hasPermission(String permission) { - if (this.permissions.contains(permission) || this.permissions.contains("*")) { + if (this.permissions.contains(permission)) { return true; } + if(this.permissions.contains("*") && this.permissions.contains("-"+permission)) { + return false; + } + String[] permissionParts = permission.split("\\."); for (String p : this.permissions) { + if (p.startsWith("-") && permissionMatchesWildcard(p.substring(1), permissionParts)) { + return false; + } if (permissionMatchesWildcard(p, permissionParts)) { + Grasscutter.getLogger().info("Permission " + p + " matches " + permission); return true; } }