mirror of
https://github.com/FancyInnovations/FancyPlugins.git
synced 2025-12-05 23:33:36 +00:00
fancynpcs: Add permissions for adding action types
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
2.7.1.293
|
||||
2.7.1.294
|
||||
@@ -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 */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user