This commit is contained in:
parent
215fe42448
commit
36d04bc041
1 changed files with 24 additions and 1 deletions
|
@ -108,11 +108,34 @@ public class Permissions {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean has_perm(String playerId,String perm){
|
public static boolean has_perm(String playerId,String perm){
|
||||||
|
if (perm.isEmpty())
|
||||||
|
return has_user_special_perm(playerId);
|
||||||
GroupPerms group = default_group;
|
GroupPerms group = default_group;
|
||||||
if (player_group.containsKey(playerId))
|
if (player_group.containsKey(playerId))
|
||||||
if (groupPermsMap.containsKey(player_group.get(playerId)))
|
if (groupPermsMap.containsKey(player_group.get(playerId)))
|
||||||
group=groupPermsMap.get(player_group.get(playerId));
|
group=groupPermsMap.get(player_group.get(playerId));
|
||||||
return has_user_special_perm(playerId) || group.has_perm(perm) || group.has_perm("*");
|
String[] perm_parts = perm.split("\\.");
|
||||||
|
boolean has_valid_perm = group.has_perm("*");
|
||||||
|
if (!has_valid_perm){
|
||||||
|
for (int i = 0; i < perm_parts.length; i++) {
|
||||||
|
StringBuilder perm_test = new StringBuilder();
|
||||||
|
for (int j = 0; j < i + 1; j++) {
|
||||||
|
if (j < i)
|
||||||
|
perm_test.append(perm_parts[j]).append(".");
|
||||||
|
else {
|
||||||
|
if (perm_parts.length == i + 1)
|
||||||
|
perm_test.append(perm_parts[j]);
|
||||||
|
else
|
||||||
|
perm_test.append("*");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (group.has_perm(perm_test.toString())) {
|
||||||
|
has_valid_perm = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return has_user_special_perm(playerId) || has_valid_perm;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GroupPerms get_group(String playerId){
|
public static GroupPerms get_group(String playerId){
|
||||||
|
|
Loading…
Reference in a new issue