Adds blacksmith title #9
This commit is contained in:
@ -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
|
||||
*
|
||||
* <p>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.</p>
|
||||
*/
|
||||
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<price> &eto reforge that &a<item>&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
|
||||
|
@ -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 <p>The title of the blacksmith</p>
|
||||
*/
|
||||
public String getBlacksmithTitle() {
|
||||
return asString(NPCSetting.BLACKSMITH_TITLE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets whether to disable the reforge-cool-down
|
||||
*
|
||||
|
@ -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<Material> 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("<price>", cost).replace("<item>", itemName));
|
||||
sendNPCMessage(this.npc, player, config.getCostMessage().replace("{cost}", cost).replace("{item}", itemName));
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user