mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-23 02:55:45 +01:00
Replace NPC names in Placeholders rather than Chat trait
This commit is contained in:
parent
8ad3a14b7c
commit
367cbd330f
@ -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>", npc.getName()).replace("<text>",
|
||||
context.getMessage());
|
||||
String text = Setting.CHAT_FORMAT.asString().replace("<text>", 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>", npc.getName()).replace("<text>",
|
||||
context.getMessage());
|
||||
String text = Setting.CHAT_FORMAT_TO_TARGET.asString().replace("<text>", 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>", npc.getName())
|
||||
.replace("<target>", targetName).replace("<text>", context.getMessage());
|
||||
String bystanderText = Setting.CHAT_FORMAT_TO_BYSTANDERS.asString().replace("<target>", targetName)
|
||||
.replace("<text>", context.getMessage());
|
||||
talkToBystanders(npc, bystanderText, context);
|
||||
return;
|
||||
}
|
||||
|
||||
else { // Multiple recipients
|
||||
String text = Setting.CHAT_FORMAT_TO_TARGET.asString().replace("<npc>", npc.getName()).replace("<text>",
|
||||
context.getMessage());
|
||||
String text = Setting.CHAT_FORMAT_TO_TARGET.asString().replace("<text>", context.getMessage());
|
||||
List<String> targetNames = new ArrayList<String>();
|
||||
// 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>", npc.getName()).replace("<targets>", targets)
|
||||
.replace("<text>", context.getMessage());
|
||||
.replace("<targets>", targets).replace("<text>", context.getMessage());
|
||||
talkToBystanders(npc, bystanderText, context);
|
||||
}
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user