mirror of
https://github.com/FancyInnovations/FancyPlugins.git
synced 2025-12-06 07:43:36 +00:00
fancynpcs: Add permissions for adding action types
This commit is contained in:
@@ -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