From 367cbd330fa02f9d3a5e78bbee01d5054fcfd831 Mon Sep 17 00:00:00 2001 From: fullwall Date: Mon, 16 Jan 2023 23:39:59 +0800 Subject: [PATCH] Replace NPC names in Placeholders rather than Chat trait --- .../net/citizensnpcs/npc/ai/speech/Chat.java | 16 ++++++---------- .../npc/ai/speech/TalkableEntity.java | 2 +- .../npc/profile/ProfileFetchThread.java | 7 +------ 3 files changed, 8 insertions(+), 17 deletions(-) diff --git a/main/src/main/java/net/citizensnpcs/npc/ai/speech/Chat.java b/main/src/main/java/net/citizensnpcs/npc/ai/speech/Chat.java index ff6d0c884..53ffce688 100644 --- a/main/src/main/java/net/citizensnpcs/npc/ai/speech/Chat.java +++ b/main/src/main/java/net/citizensnpcs/npc/ai/speech/Chat.java @@ -29,16 +29,14 @@ public class Chat implements VocalChord { // chat to the world with CHAT_FORMAT and CHAT_RANGE settings if (!context.hasRecipients()) { - String text = Setting.CHAT_FORMAT.asString().replace("", npc.getName()).replace("", - context.getMessage()); + String text = Setting.CHAT_FORMAT.asString().replace("", context.getMessage()); talkToBystanders(npc, text, context); return; } // Assumed recipients at this point else if (context.size() <= 1) { - String text = Setting.CHAT_FORMAT_TO_TARGET.asString().replace("", npc.getName()).replace("", - context.getMessage()); + String text = Setting.CHAT_FORMAT_TO_TARGET.asString().replace("", context.getMessage()); String targetName = ""; // For each recipient for (Talkable entity : context) { @@ -49,15 +47,14 @@ public class Chat implements VocalChord { if (!Setting.CHAT_BYSTANDERS_HEAR_TARGETED_CHAT.asBoolean()) return; // Format message with config setting and send to bystanders - String bystanderText = Setting.CHAT_FORMAT_TO_BYSTANDERS.asString().replace("", npc.getName()) - .replace("", targetName).replace("", context.getMessage()); + String bystanderText = Setting.CHAT_FORMAT_TO_BYSTANDERS.asString().replace("", targetName) + .replace("", context.getMessage()); talkToBystanders(npc, bystanderText, context); return; } else { // Multiple recipients - String text = Setting.CHAT_FORMAT_TO_TARGET.asString().replace("", npc.getName()).replace("", - context.getMessage()); + String text = Setting.CHAT_FORMAT_TO_TARGET.asString().replace("", context.getMessage()); List targetNames = new ArrayList(); // Talk to each recipient for (Talkable entity : context) { @@ -97,8 +94,7 @@ public class Chat implements VocalChord { } String bystanderText = Setting.CHAT_FORMAT_WITH_TARGETS_TO_BYSTANDERS.asString() - .replace("", npc.getName()).replace("", targets) - .replace("", context.getMessage()); + .replace("", targets).replace("", context.getMessage()); talkToBystanders(npc, bystanderText, context); } } diff --git a/main/src/main/java/net/citizensnpcs/npc/ai/speech/TalkableEntity.java b/main/src/main/java/net/citizensnpcs/npc/ai/speech/TalkableEntity.java index 1a10ecf40..3ceb0809c 100644 --- a/main/src/main/java/net/citizensnpcs/npc/ai/speech/TalkableEntity.java +++ b/main/src/main/java/net/citizensnpcs/npc/ai/speech/TalkableEntity.java @@ -53,7 +53,7 @@ public class TalkableEntity implements Talkable { @Override public String getName() { if (CitizensAPI.getNPCRegistry().isNPC(entity)) { - return CitizensAPI.getNPCRegistry().getNPC(entity).getName(); + return CitizensAPI.getNPCRegistry().getNPC(entity).getFullName(); } else if (entity instanceof Player) { return ((Player) entity).getName(); } else { diff --git a/main/src/main/java/net/citizensnpcs/npc/profile/ProfileFetchThread.java b/main/src/main/java/net/citizensnpcs/npc/profile/ProfileFetchThread.java index b3f7bb9aa..029bb86c1 100644 --- a/main/src/main/java/net/citizensnpcs/npc/profile/ProfileFetchThread.java +++ b/main/src/main/java/net/citizensnpcs/npc/profile/ProfileFetchThread.java @@ -237,11 +237,6 @@ class ProfileFetchThread implements Runnable { } private static void sendResult(final ProfileFetchHandler handler, final ProfileRequest request) { - Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), new Runnable() { - @Override - public void run() { - handler.onResult(request); - } - }, 1); + Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), () -> handler.onResult(request), 1); } }