Use slugs in arena and class permission checks.

This commit changes the permission checks for arenas and classes to a
slug-based approach instead of the "config names", which are somewhat
arbitrary and may contain spaces, which are generally not supported by
permissions plugins.

This is a breaking change, which means it will be necessary for users
to change their permission setups. Backwards compatibility could have
been implemented, but it just leaves more room for ambiguity and will
make a necessary transition later down the road less obvious. Instead,
we burn the ships!

As a result of this change, access to the "My Items" class can now be
revoked as intended with the key `mobarena.classes.my-items`.

Fixes #647
This commit is contained in:
Andreas Troelsen
2020-11-03 19:50:29 +01:00
parent 1b46e17e38
commit 519886cf3e
3 changed files with 15 additions and 4 deletions
@@ -148,8 +148,13 @@ public class ArenaClass
}
public boolean hasPermission(Player p) {
String perm = "mobarena.classes." + configName;
return !p.isPermissionSet(perm) || p.hasPermission(perm);
String key = "mobarena.classes." + slug;
if (p.isPermissionSet(key)) {
return p.hasPermission(key);
}
// Permissive by default.
return true;
}
/**
@@ -680,8 +680,13 @@ public class ArenaImpl implements Arena
@Override
public boolean hasPermission(Player p) {
String perm = "mobarena.arenas." + name;
return !p.isPermissionSet(perm) || p.hasPermission(perm);
String key = "mobarena.arenas." + slug;
if (p.isPermissionSet(key)) {
return p.hasPermission(key);
}
// Permissive by default.
return true;
}
@Override