From 1cdeda5d5d8952f485289d03525b5231b18db2f9 Mon Sep 17 00:00:00 2001 From: fullwall Date: Sat, 25 Jun 2022 16:47:13 +0800 Subject: [PATCH] Add 'say' option to /npc command and add the NPC id for /npc commands --- .../java/net/citizensnpcs/commands/NPCCommands.java | 4 ++-- .../main/java/net/citizensnpcs/trait/CommandTrait.java | 10 +++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/main/src/main/java/net/citizensnpcs/commands/NPCCommands.java b/main/src/main/java/net/citizensnpcs/commands/NPCCommands.java index 428d1b1bf..1fc98a2ce 100644 --- a/main/src/main/java/net/citizensnpcs/commands/NPCCommands.java +++ b/main/src/main/java/net/citizensnpcs/commands/NPCCommands.java @@ -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") diff --git a/main/src/main/java/net/citizensnpcs/trait/CommandTrait.java b/main/src/main/java/net/citizensnpcs/trait/CommandTrait.java index f49a841d2..74dd75f6f 100644 --- a/main/src/main/java/net/citizensnpcs/trait/CommandTrait.java +++ b/main/src/main/java/net/citizensnpcs/trait/CommandTrait.java @@ -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

"; + } + if ((command.startsWith("npc") || command.startsWith("waypoints") || command.startsWith("wp")) + && !command.contains("--id ")) { + cmd += " --id "; + } + String interpolatedCommand = Placeholders.replace(cmd, clicker, npc); if (Messaging.isDebugging()) { Messaging.debug( "Running command " + interpolatedCommand + " on NPC " + npc.getId() + " clicker " + clicker);