Makes the npc talking format configurable #19

This commit is contained in:
Kristian Knarvik 2023-01-16 03:02:13 +01:00
parent bbb93bb0eb
commit 7d468115e0
3 changed files with 12 additions and 4 deletions

View File

@ -1,9 +1,9 @@
package net.knarcraft.blacksmith.formatting; package net.knarcraft.blacksmith.formatting;
import net.citizensnpcs.api.npc.NPC; import net.citizensnpcs.api.npc.NPC;
import net.knarcraft.blacksmith.BlacksmithPlugin;
import net.knarcraft.knarlib.property.ColorConversion; import net.knarcraft.knarlib.property.ColorConversion;
import net.knarcraft.knarlib.util.ColorHelper; import net.knarcraft.knarlib.util.ColorHelper;
import net.md_5.bungee.api.ChatColor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
/** /**
@ -23,8 +23,10 @@ public final class BlacksmithStringFormatter {
* @param message <p>The message to send</p> * @param message <p>The message to send</p>
*/ */
public static void sendNPCMessage(NPC npc, Player player, String message) { public static void sendNPCMessage(NPC npc, Player player, String message) {
player.sendMessage(ChatColor.GREEN + "[" + npc.getName() + "] -> You:" + ChatColor.RESET + " " + player.sendMessage(BlacksmithPlugin.getStringFormatter().replacePlaceholders(
ColorHelper.translateColorCodes(message, ColorConversion.NORMAL)); BlacksmithTranslatableMessage.NPC_TALK_FORMAT,
new String[]{"{npc}", "{message}"},
new String[]{npc.getName(), ColorHelper.translateColorCodes(message, ColorConversion.RGB)}));
} }
} }

View File

@ -130,7 +130,12 @@ public enum BlacksmithTranslatableMessage implements TranslatableMessage {
/** /**
* The marker used for displaying that a given setting has been overridden for the selected NPC * The marker used for displaying that a given setting has been overridden for the selected NPC
*/ */
SETTING_OVERRIDDEN_MARKER; SETTING_OVERRIDDEN_MARKER,
/**
* The format to use for formatting any message spoken by a blacksmith NPC
*/
NPC_TALK_FORMAT;
/** /**
* Gets the message to display when displaying the raw value of messages * Gets the message to display when displaying the raw value of messages

View File

@ -18,6 +18,7 @@ en:
INVALID_PRESET_OR_FILTER: "You specified an invalid preset or an invalid filter" INVALID_PRESET_OR_FILTER: "You specified an invalid preset or an invalid filter"
PRESET_MATERIALS: "Materials in preset: {materials}" PRESET_MATERIALS: "Materials in preset: {materials}"
DURATION_FORMAT: "in {time} {unit}" DURATION_FORMAT: "in {time} {unit}"
NPC_TALK_FORMAT: "&a[{npc}] -> You:&r {message}"
UNIT_NOW: "imminently" UNIT_NOW: "imminently"
UNIT_SECOND: "second" UNIT_SECOND: "second"
UNIT_SECONDS: "seconds" UNIT_SECONDS: "seconds"