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
+1
View File
@@ -23,6 +23,7 @@ These changes will (most likely) be included in the next version.
- Boss rewards also support the `all()` and `random()` functions as well as the `nothing` keyword.
- New command `/ma addreward <player> <thing>` can be used to add a reward to an arena player's reward list. This can be useful for hooking into the rewards system from scripts or other plugins.
- The Root Target ability now uses potion effects (slowness, slow falling, and negative jump boost) instead of repeated teleports. This should make for a smoother root experience.
- Permissions for arenas and classes are now based on "slugs". It is now possible to configure permissions for arenas and classes with multi-word names (including "My Items"). Check the Permissions page on the wiki for details.
- Using `spectate-on-death: true` no longer forces players out to their join location/exit warp before moving them to the spectator area. This should prevent "jumpy" behavior in multi-world setups.
- Players should now properly respawn at the spectator area rather than at world spawn on servers with plugins that override respawn locations.
- Config-files with missing `pet-items` nodes no longer errors. A missing `pet-items` node in `global-settings` is treated as empty, i.e. no pet items will be registered.
@@ -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