diff --git a/docs/src/fancynpcs/commands/npc.md b/docs/src/fancynpcs/commands/npc.md index a562d94b..1c961063 100644 --- a/docs/src/fancynpcs/commands/npc.md +++ b/docs/src/fancynpcs/commands/npc.md @@ -211,28 +211,36 @@ Learn more about actions and triggers in the [Action System](../tutorials/action Adds an action to the specified NPC's trigger. - **Syntax**: `/npc action (npc) (trigger) add (actionType) [value]` -- **Permissions**: `fancynpcs.command.npc.action.add` +- **Permissions**: + - `fancynpcs.command.npc.action.add` + - and `fancynpcs.command.npc.action.(actionType)` for the specific action type ### Add action before Adds an action before the specified index in the NPC's action list for the given trigger. - **Syntax**: `/npc action (npc) (trigger) add_before (index) (actionType) [value]` -- **Permissions**: `fancynpcs.command.npc.action.addBefore` +- **Permissions**: + - `fancynpcs.command.npc.action.addBefore` + - and `fancynpcs.command.npc.action.(actionType)` for the specific action type ### Add action after Adds an action after the specified index in the NPC's action list for the given trigger. - **Syntax**: `/npc action (npc) (trigger) add_after (index) (actionType) [value]` -- **Permissions**: `fancynpcs.command.npc.action.addAfter` +- **Permissions**: + - `fancynpcs.command.npc.action.addAfter` + - and `fancynpcs.command.npc.action.(actionType)` for the specific action type ### Set action Sets an action at the specified number in the NPC's action list for the given trigger. - **Syntax**: `/npc action (npc) (trigger) set (number) (actionType) [value]` -- **Permissions**: `fancynpcs.command.npc.action.set` +- **Permissions**: + - `fancynpcs.command.npc.action.set` + - and `fancynpcs.command.npc.action.(actionType)` for the specific action type ### Remove action diff --git a/plugins/fancynpcs/VERSION b/plugins/fancynpcs/VERSION index 707c7e9a..f7bd58ca 100644 --- a/plugins/fancynpcs/VERSION +++ b/plugins/fancynpcs/VERSION @@ -1 +1 @@ -2.7.1.293 \ No newline at end of file +2.7.1.294 \ No newline at end of file diff --git a/plugins/fancynpcs/src/main/java/de/oliver/fancynpcs/commands/npc/ActionCMD.java b/plugins/fancynpcs/src/main/java/de/oliver/fancynpcs/commands/npc/ActionCMD.java index 5d221a87..db7cef1d 100644 --- a/plugins/fancynpcs/src/main/java/de/oliver/fancynpcs/commands/npc/ActionCMD.java +++ b/plugins/fancynpcs/src/main/java/de/oliver/fancynpcs/commands/npc/ActionCMD.java @@ -34,6 +34,10 @@ public enum ActionCMD { final @NotNull NpcAction actionType, final @Nullable @Greedy String value ) { + if (!checkAddPermissions(sender, actionType)) { + return; + } + if (actionType.requiresValue() && (value == null || value.isEmpty())) { translator .translate("npc_action_requires_value") @@ -65,6 +69,10 @@ public enum ActionCMD { final @NotNull NpcAction actionType, final @Nullable @Greedy String value ) { + if (!checkAddPermissions(sender, actionType)) { + return; + } + if (actionType.requiresValue() && (value == null || value.isEmpty())) { translator .translate("npc_action_requires_value") @@ -98,6 +106,10 @@ public enum ActionCMD { final @NotNull NpcAction actionType, final @Nullable @Greedy String value ) { + if (!checkAddPermissions(sender, actionType)) { + return; + } + if (actionType.requiresValue() && (value == null || value.isEmpty())) { translator .translate("npc_action_requires_value") @@ -131,6 +143,10 @@ public enum ActionCMD { final @NotNull NpcAction actionType, final @Nullable @Greedy String value ) { + if (!checkAddPermissions(sender, actionType)) { + return; + } + if (actionType.requiresValue() && (value == null || value.isEmpty())) { translator .translate("npc_action_requires_value") @@ -303,6 +319,21 @@ public enum ActionCMD { return newActions; } + private boolean checkAddPermissions(final CommandSender sender, final NpcAction action) { + boolean hasGeneralPerms = sender.hasPermission("fancynpcs.command.npc.action.add.*"); + boolean hasSpecificPerms = sender.hasPermission("fancynpcs.command.npc.action.add." + action.getName()); + + if (hasGeneralPerms || hasSpecificPerms) { + return true; + } + + translator + .translate("action_missing_permissions") + .send(sender); + + return false; + } + /* PARSERS AND SUGGESTIONS */