Add 'say' option to /npc command and add the NPC id for /npc commands

This commit is contained in:
fullwall 2022-06-25 16:47:13 +08:00
parent 36cbef81a7
commit 1cdeda5d5d
2 changed files with 11 additions and 3 deletions

View File

@ -2399,8 +2399,8 @@ public class NPCCommands {
@Command(
aliases = { "npc" },
usage = "speak message to speak --target npcid|player_name --type vocal_type",
desc = "Uses the NPCs SpeechController to talk",
usage = "speak [message] --target [npcid|player name] (--type vocal_type)",
desc = "Says a message from the NPC",
modifiers = { "speak" },
min = 2,
permission = "citizens.npc.speak")

View File

@ -470,7 +470,15 @@ public class CommandTrait extends Trait {
}
public void run(NPC npc, Player clicker) {
String interpolatedCommand = Placeholders.replace(command, clicker, npc);
String cmd = command;
if (command.startsWith("say")) {
cmd = "npc speak " + command.replaceFirst("say", "").trim() + " --target <p>";
}
if ((command.startsWith("npc") || command.startsWith("waypoints") || command.startsWith("wp"))
&& !command.contains("--id <id>")) {
cmd += " --id <id>";
}
String interpolatedCommand = Placeholders.replace(cmd, clicker, npc);
if (Messaging.isDebugging()) {
Messaging.debug(
"Running command " + interpolatedCommand + " on NPC " + npc.getId() + " clicker " + clicker);