diff --git a/src/main/java/net/knarcraft/blacksmith/config/NPCSetting.java b/src/main/java/net/knarcraft/blacksmith/config/NPCSetting.java
index d28f827..b92538a 100644
--- a/src/main/java/net/knarcraft/blacksmith/config/NPCSetting.java
+++ b/src/main/java/net/knarcraft/blacksmith/config/NPCSetting.java
@@ -48,6 +48,14 @@ public enum NPCSetting {
*/
REFORGE_ABLE_ITEMS("reforgeAbleItems", SettingValueType.STRING_LIST, new String[]{}, "reforgeAbleItems"),
+ /**
+ * The setting for the title used to display which kind of blacksmith the NPC is
+ *
+ *
While this should be entirely configurable, values such as armor-smith, sword-smith and similar, which
+ * describe the blacksmith's specialization, and thus the range of reforge-able items, is expected.
+ */
+ BLACKSMITH_TITLE("blacksmithTitle", SettingValueType.STRING, "blacksmith", "blacksmithTitle"),
+
/*-----------
| Messages |
-----------*/
@@ -74,7 +82,7 @@ public enum NPCSetting {
* The message displayed when displaying the cost of reforging the held item to the player
*/
COST_MESSAGE("messages.costMessage", SettingValueType.STRING,
- "&eIt will cost &a &eto reforge that &a- &e! Click again to reforge!", "costMessage"),
+ "&eIt will cost &a{cost}&e to reforge that &a{item}&e! Click again to reforge!", "costMessage"),
/**
* The message displayed if the blacksmith fails reforging an item
@@ -92,7 +100,7 @@ public enum NPCSetting {
* The message displayed if the blacksmith encounters an item they cannot reforge
*/
INVALID_ITEM_MESSAGE("messages.invalidItemMessage", SettingValueType.STRING,
- "&cI'm sorry, but I don't know how to reforge that!", "invalidItemMessage"),
+ "&cI'm sorry, but I'm a/an {title}, I don't know how to reforge that!", "invalidItemMessage"),
/**
* The message displayed if a player presents a different item after seeing the price to reforge an item
diff --git a/src/main/java/net/knarcraft/blacksmith/config/NPCSettings.java b/src/main/java/net/knarcraft/blacksmith/config/NPCSettings.java
index 7a38da3..ef373a4 100644
--- a/src/main/java/net/knarcraft/blacksmith/config/NPCSettings.java
+++ b/src/main/java/net/knarcraft/blacksmith/config/NPCSettings.java
@@ -251,6 +251,15 @@ public class NPCSettings {
return ConfigHelper.asBoolean(getValue(NPCSetting.DROP_ITEM));
}
+ /**
+ * Gets the title of the blacksmith, describing which items it can reforge
+ *
+ * @return
The title of the blacksmith
+ */
+ public String getBlacksmithTitle() {
+ return asString(NPCSetting.BLACKSMITH_TITLE);
+ }
+
/**
* Gets whether to disable the reforge-cool-down
*
diff --git a/src/main/java/net/knarcraft/blacksmith/trait/BlacksmithTrait.java b/src/main/java/net/knarcraft/blacksmith/trait/BlacksmithTrait.java
index 85ee7c8..bd71815 100644
--- a/src/main/java/net/knarcraft/blacksmith/trait/BlacksmithTrait.java
+++ b/src/main/java/net/knarcraft/blacksmith/trait/BlacksmithTrait.java
@@ -5,6 +5,7 @@ import net.citizensnpcs.api.trait.Trait;
import net.citizensnpcs.api.util.DataKey;
import net.knarcraft.blacksmith.BlacksmithPlugin;
import net.knarcraft.blacksmith.config.NPCSettings;
+import net.knarcraft.blacksmith.formatting.StringFormatter;
import net.knarcraft.blacksmith.manager.EconomyManager;
import net.knarcraft.blacksmith.util.ItemHelper;
import org.bukkit.Bukkit;
@@ -170,7 +171,9 @@ public class BlacksmithTrait extends Trait {
//Refuse if not repairable, or if reforge-able items is set, but doesn't include the held item
List reforgeAbleItems = config.getReforgeAbleItems();
if (!isRepairable(hand) || (!reforgeAbleItems.isEmpty() && !reforgeAbleItems.contains(hand.getType()))) {
- sendNPCMessage(this.npc, player, config.getInvalidItemMessage());
+ String invalidMessage = StringFormatter.replacePlaceholder(config.getInvalidItemMessage(),
+ "{title}", config.getBlacksmithTitle());
+ sendNPCMessage(this.npc, player, invalidMessage);
return;
}
@@ -186,7 +189,7 @@ public class BlacksmithTrait extends Trait {
//Tell the player the cost of repairing the item
String cost = EconomyManager.formatCost(player);
String itemName = hand.getType().name().toLowerCase().replace('_', ' ');
- sendNPCMessage(this.npc, player, config.getCostMessage().replace("", cost).replace("- ", itemName));
+ sendNPCMessage(this.npc, player, config.getCostMessage().replace("{cost}", cost).replace("{item}", itemName));
}
/**
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
index 97a2884..24e9f4e 100644
--- a/src/main/resources/config.yml
+++ b/src/main/resources/config.yml
@@ -52,6 +52,9 @@ defaults:
# The cool-down period between each reforge
reforgeCoolDown: 60
+ # The title describing the blacksmith's usage/speciality
+ blacksmithTitle: "blacksmith"
+
# All messages used by the NPC
messages:
# The message to display when another player is using the blacksmith
@@ -64,7 +67,7 @@ defaults:
coolDownUnexpiredMessage: "&cYou've already had your chance! Give me a break!"
# The message to display when informing a player about the reforging cost
- costMessage: "&eIt will cost &a &eto reforge that &a
- &e! Click again to reforge!"
+ costMessage: "&eIt will cost &a{cost}&e to reforge that &a{item}&e! Click again to reforge!"
# The message to display when the blacksmith fails to reforge an item
failReforgeMessage: "&cWhoops! Didn't mean to do that! Maybe next time?"
@@ -73,7 +76,7 @@ defaults:
insufficientFundsMessage: "&cYou don't have enough money to reforge that item!"
# The message to display when holding an item the blacksmith is unable to reforge
- invalidItemMessage: "&cI'm sorry, but I don't know how to reforge that!"
+ invalidItemMessage: "&cI'm sorry, but I'm a/an {title}, I don't know how to reforge that!"
# The message to display when presenting a different item than the one just evaluated
itemChangedMessage: "&cThat's not the item you wanted to reforge before!"