fancynpcs: Send warning when adding player_command_as_op action

This commit is contained in:
Oliver
2025-07-30 21:25:11 +02:00
parent aa20217c61
commit c99d32c452
3 changed files with 24 additions and 4 deletions

View File

@@ -1 +1 @@
2.7.0.285 2.7.0.286

View File

@@ -13,14 +13,13 @@ import org.incendo.cloud.annotations.Permission;
import org.incendo.cloud.annotations.suggestion.Suggestions; import org.incendo.cloud.annotations.suggestion.Suggestions;
import org.incendo.cloud.context.CommandContext; import org.incendo.cloud.context.CommandContext;
import org.incendo.cloud.context.CommandInput; import org.incendo.cloud.context.CommandInput;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public enum ActionCMD { public enum ActionCMD {
INSTANCE; // SINGLETON INSTANCE; // SINGLETON
@@ -49,6 +48,11 @@ public enum ActionCMD {
.translate("npc_action_add_success") .translate("npc_action_add_success")
.replaceStripped("total", String.valueOf(npc.getData().getActions(trigger).size())) .replaceStripped("total", String.valueOf(npc.getData().getActions(trigger).size()))
.send(sender); .send(sender);
if (actionType.getName().equalsIgnoreCase("player_command_as_op")) {
translator.translate("npc_action_add_op_warning")
.send(sender);
}
} }
@Command("npc action <npc> <trigger> add_before <index> <actionType> [value]") @Command("npc action <npc> <trigger> add_before <index> <actionType> [value]")
@@ -77,6 +81,11 @@ public enum ActionCMD {
.replaceStripped("number", String.valueOf(index)) .replaceStripped("number", String.valueOf(index))
.replaceStripped("total", String.valueOf(npc.getData().getActions(trigger).size())) .replaceStripped("total", String.valueOf(npc.getData().getActions(trigger).size()))
.send(sender); .send(sender);
if (actionType.getName().equalsIgnoreCase("player_command_as_op")) {
translator.translate("npc_action_add_op_warning")
.send(sender);
}
} }
@Command("npc action <npc> <trigger> add_after <index> <actionType> [value]") @Command("npc action <npc> <trigger> add_after <index> <actionType> [value]")
@@ -105,6 +114,11 @@ public enum ActionCMD {
.replaceStripped("number", String.valueOf(index)) .replaceStripped("number", String.valueOf(index))
.replaceStripped("total", String.valueOf(npc.getData().getActions(trigger).size())) .replaceStripped("total", String.valueOf(npc.getData().getActions(trigger).size()))
.send(sender); .send(sender);
if (actionType.getName().equalsIgnoreCase("player_command_as_op")) {
translator.translate("npc_action_add_op_warning")
.send(sender);
}
} }
@Command("npc action <npc> <trigger> set <number> <actionType> [value]") @Command("npc action <npc> <trigger> set <number> <actionType> [value]")
@@ -140,6 +154,11 @@ public enum ActionCMD {
.replaceStripped("number", String.valueOf(number)) .replaceStripped("number", String.valueOf(number))
.replaceStripped("total", String.valueOf(npc.getData().getActions(trigger).size())) .replaceStripped("total", String.valueOf(npc.getData().getActions(trigger).size()))
.send(sender); .send(sender);
if (actionType.getName().equalsIgnoreCase("player_command_as_op")) {
translator.translate("npc_action_add_op_warning")
.send(sender);
}
} }
@Command("npc action <npc> <trigger> remove <number>") @Command("npc action <npc> <trigger> remove <number>")

View File

@@ -189,6 +189,7 @@ messages:
npc_action_add_success: "<dark_gray> <gray>Action has been added. There are {warningColor}{total}<gray> actions in total." npc_action_add_success: "<dark_gray> <gray>Action has been added. There are {warningColor}{total}<gray> actions in total."
npc_action_add_before_success: "<dark_gray> <gray>Action has been added before action {warningColor}{number}<gray>. There are {warningColor}{total}<gray> actions in total." npc_action_add_before_success: "<dark_gray> <gray>Action has been added before action {warningColor}{number}<gray>. There are {warningColor}{total}<gray> actions in total."
npc_action_add_after_success: "<dark_gray> <gray>Action has been added after action {warningColor}{number}<gray>. There are {warningColor}{total}<gray> actions in total." npc_action_add_after_success: "<dark_gray> <gray>Action has been added after action {warningColor}{number}<gray>. There are {warningColor}{total}<gray> actions in total."
npc_action_add_op_warning: "<dark_gray> {warningColor}FancyNpcs will give the player operator permissions for the duration of the command execution. This means that the player will have access to all commands and permissions during that time. This can be a security risk if not used carefully, so make sure to use this action only when necessary and with trusted players."
npc_action_set_success: "<dark_gray> <gray>Action trigger {warningColor}{number}<gray> has been updated. There are {warningColor}{total}<gray> actions in total." npc_action_set_success: "<dark_gray> <gray>Action trigger {warningColor}{number}<gray> has been updated. There are {warningColor}{total}<gray> actions in total."
npc_action_set_failure: "<dark_gray> {errorColor}Action trigger {warningColor}{number}{errorColor} does not exist." npc_action_set_failure: "<dark_gray> {errorColor}Action trigger {warningColor}{number}{errorColor} does not exist."
npc_action_move_up_success: "<dark_gray> <gray>Action trigger {warningColor}{number}<gray> has been moved up." npc_action_move_up_success: "<dark_gray> <gray>Action trigger {warningColor}{number}<gray> has been moved up."