Adds tons of changes to messages

This commit is contained in:
2022-09-29 01:49:12 +02:00
parent 3cfa7a2a0a
commit a6e9163dbd
18 changed files with 458 additions and 95 deletions

View File

@ -21,6 +21,8 @@ import java.util.Map;
import java.util.Objects;
import java.util.UUID;
import static net.knarcraft.blacksmith.util.MessageFormatter.sendNPCMessage;
/**
* The class representing the Blacksmith NPC trait
*/
@ -115,7 +117,7 @@ public class BlacksmithTrait extends Trait {
//Deny if on cool-down, or remove cool-down if expired
if (coolDowns.get(player.getUniqueId()) != null) {
if (!Calendar.getInstance().after(coolDowns.get(player.getUniqueId()))) {
player.sendMessage(config.getCoolDownUnexpiredMessage());
sendNPCMessage(this.npc, player, config.getCoolDownUnexpiredMessage());
return false;
}
coolDowns.remove(player.getUniqueId());
@ -139,13 +141,13 @@ public class BlacksmithTrait extends Trait {
public void continueSession(Player player) {
//Another player is using the blacksmith
if (!session.isInSession(player)) {
player.sendMessage(config.getBusyWithPlayerMessage());
sendNPCMessage(this.npc, player, config.getBusyWithPlayerMessage());
return;
}
//The blacksmith is already reforging for the player
if (session.isRunning()) {
player.sendMessage(config.getBusyReforgingMessage());
sendNPCMessage(this.npc, player, config.getBusyReforgingMessage());
return;
}
if (session.endSession()) {
@ -167,7 +169,7 @@ 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()))) {
player.sendMessage(config.getInvalidItemMessage());
sendNPCMessage(this.npc, player, config.getInvalidItemMessage());
return;
}
@ -178,7 +180,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('_', ' ');
player.sendMessage(config.getCostMessage().replace("<price>", cost).replace("<item>", itemName));
sendNPCMessage(this.npc, player, config.getCostMessage().replace("<price>", cost).replace("<item>", itemName));
}
/**
@ -188,7 +190,7 @@ public class BlacksmithTrait extends Trait {
* @param player <p>The player that initiated the reforge</p>
*/
private void reforge(NPC npc, Player player) {
player.sendMessage(config.getStartReforgeMessage());
sendNPCMessage(this.npc, player, config.getStartReforgeMessage());
EconomyManager.withdraw(player);
session.beginReforge();
ItemStack heldItem = player.getInventory().getItemInMainHand();