diff --git a/common/src/main/java/org/samo_lego/blacksmiths/config/SmithyConfig.java b/common/src/main/java/org/samo_lego/blacksmiths/config/SmithyConfig.java index 1ec632d..05ca29d 100644 --- a/common/src/main/java/org/samo_lego/blacksmiths/config/SmithyConfig.java +++ b/common/src/main/java/org/samo_lego/blacksmiths/config/SmithyConfig.java @@ -77,6 +77,11 @@ public static class Costs { @BrigadierExcluded @SerializedName("ignore_economy_mod") public boolean ignoreEconomyMod = false; + + @SerializedName("// Whether to add lore with cost info to the item.") + public final String _comment_addLore = ""; + @SerializedName("add_lore") + public boolean addLore = true; } diff --git a/common/src/main/java/org/samo_lego/blacksmiths/gui/RepairGUI.java b/common/src/main/java/org/samo_lego/blacksmiths/gui/RepairGUI.java index 83b28b2..b4b4de4 100644 --- a/common/src/main/java/org/samo_lego/blacksmiths/gui/RepairGUI.java +++ b/common/src/main/java/org/samo_lego/blacksmiths/gui/RepairGUI.java @@ -95,33 +95,37 @@ public ItemStack getItem(int index) { } } - ItemStack copy = itemStack.copy(); - CompoundTag nbt = copy.getTag(); - - if (nbt != null) { - // Calculate cost - double amount = (startDmg - itemStack.getDamageValue()) * this.profession.getCostPerDamage(); - VanillaEconomy economy = Blacksmiths.getInstance().getEconomy(); - - double cost = economy.getItemConversionCost(amount); - MutableComponent costLore = economy.getCurrencyFormat(cost); - boolean canAfford = Blacksmiths.getInstance().getEconomy().canAfford(cost, this.player) >= 0; - - CompoundTag nbtDisplay = nbt.getCompound(ItemStack.TAG_DISPLAY); - ListTag nbtLore = new ListTag(); - - nbtLore.add(StringTag.valueOf( - Component.Serializer.toJson( - costLore.withStyle(canAfford ? ChatFormatting.GREEN : ChatFormatting.RED) - ) - )); - - nbtDisplay.put(ItemStack.TAG_LORE, nbtLore); - nbt.put(ItemStack.TAG_DISPLAY, nbtDisplay); - copy.setTag(nbt); + // Adds lore with current cost to the item. + if (CONFIG.costs.addLore) { + ItemStack copy = itemStack.copy(); + CompoundTag nbt = copy.getTag(); + + if (nbt != null) { + // Calculate cost + double amount = (startDmg - itemStack.getDamageValue()) * this.profession.getCostPerDamage(); + VanillaEconomy economy = Blacksmiths.getInstance().getEconomy(); + + double cost = economy.getItemConversionCost(amount); + MutableComponent costLore = economy.getCurrencyFormat(cost); + boolean canAfford = Blacksmiths.getInstance().getEconomy().canAfford(cost, this.player) >= 0; + + CompoundTag nbtDisplay = nbt.getCompound(ItemStack.TAG_DISPLAY); + ListTag nbtLore = new ListTag(); + + nbtLore.add(StringTag.valueOf( + Component.Serializer.toJson( + costLore.withStyle(canAfford ? ChatFormatting.GREEN : ChatFormatting.RED) + ) + )); + + nbtDisplay.put(ItemStack.TAG_LORE, nbtLore); + nbt.put(ItemStack.TAG_DISPLAY, nbtDisplay); + copy.setTag(nbt); + } + + itemStack = copy; } - itemStack = copy; } else { itemStack = ItemStack.EMPTY; }