mirror of
https://github.com/FancyInnovations/FancyPlugins.git
synced 2025-12-06 07:43:36 +00:00
fancynpcs: Implemented inversed permission checks -> "!" prefix for perms (#139)
* Implemented feature from here: https://github.com/FancyInnovations/FancyPlugins/issues/86 * Implemented feature from here: https://github.com/FancyInnovations/FancyPlugins/issues/50
This commit is contained in:
@@ -20,7 +20,13 @@ public class NeedPermissionAction extends NpcAction {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!context.getPlayer().hasPermission(value)) {
|
||||
boolean invertCheck = value.startsWith("!");
|
||||
String permission = invertCheck ? value.substring(1) : value;
|
||||
|
||||
boolean hasPermission = context.getPlayer().hasPermission(permission);
|
||||
boolean passesCheck = invertCheck ? !hasPermission : hasPermission;
|
||||
|
||||
if (!passesCheck) {
|
||||
FancyNpcsPlugin.get().getTranslator().translate("action_missing_permissions").send(context.getPlayer());
|
||||
context.terminate();
|
||||
}
|
||||
|
||||
@@ -90,6 +90,7 @@ public class NpcModifyEvent extends Event implements Cancellable {
|
||||
LOCATION,
|
||||
MIRROR_SKIN,
|
||||
PLAYER_COMMAND,
|
||||
ROTATION,
|
||||
SERVER_COMMAND,
|
||||
SHOW_IN_TAB,
|
||||
SKIN,
|
||||
|
||||
Reference in New Issue
Block a user