diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/display/EnchantDisplay.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/display/EnchantDisplay.kt index 590ee8c5..fd2bef56 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/display/EnchantDisplay.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/display/EnchantDisplay.kt @@ -73,11 +73,17 @@ class EnchantDisplay(private val plugin: EcoEnchantsPlugin) : DisplayModule(plug val notMetLines = mutableListOf() for ((enchant, level) in enchants) { + var showNotMet = false if (player != null && enchant is EcoEnchant) { - notMetLines.addAll(enchant.getLevel(level).getNotMetLines(player).map { Display.PREFIX + it }) + val enchantNotMetLines = enchant.getLevel(level).getNotMetLines(player).map { Display.PREFIX + it } + notMetLines.addAll(enchantNotMetLines) + if (enchantNotMetLines.isNotEmpty()) { + showNotMet = true + } } - formattedNames[DisplayableEnchant(enchant.wrap(), level)] = enchant.wrap().getFormattedName(level) + formattedNames[DisplayableEnchant(enchant.wrap(), level)] = + enchant.wrap().getFormattedName(level, showNotMet = showNotMet) } if (shouldCollapse) { diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/display/EnchantmentFormatting.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/display/EnchantmentFormatting.kt index 5846a28c..7794cdc1 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/display/EnchantmentFormatting.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/display/EnchantmentFormatting.kt @@ -32,7 +32,11 @@ data class DisplayableEnchant( val level: Int ) -fun EcoEnchantLike.getFormattedName(level: Int): String { +@JvmOverloads +fun EcoEnchantLike.getFormattedName( + level: Int, + showNotMet: Boolean = false +): String { val plugin = EcoEnchantsPlugin.instance return DisplayCache.nameCache.get(DisplayableEnchant(this, level)) { @@ -44,20 +48,22 @@ fun EcoEnchantLike.getFormattedName(level: Int): String { val number = if (numerals) NumberUtils.toNumeral(level) else level.toString() val dontShowNumber = (level == 1 && this.enchant.maxLevel == 1) || level < 1 + val notMetFormat = if (showNotMet) plugin.configYml.getString("display.not-met.format") else "" + if (plugin.configYml.getBool("display.above-max-level.enabled") && level > this.enchant.maxLevel) { val format = plugin.configYml.getString("display.above-max-level.format") val levelOnly = plugin.configYml.getBool("display.above-max-level.level-only") if (levelOnly) { - StringUtils.format("$typeFormat$name $format$number") + StringUtils.format("$notMetFormat$typeFormat$name $format$number") } else { - StringUtils.format("$format$name $number") + StringUtils.format("$notMetFormat$format$name $number") } } else { if (dontShowNumber) { - StringUtils.format("$typeFormat$name") + StringUtils.format("$notMetFormat$typeFormat$name") } else { - StringUtils.format("$typeFormat$name $number") + StringUtils.format("$notMetFormat$typeFormat$name $number") } } } diff --git a/eco-core/core-plugin/src/main/resources/config.yml b/eco-core/core-plugin/src/main/resources/config.yml index b3b8f4b1..a47848b0 100644 --- a/eco-core/core-plugin/src/main/resources/config.yml +++ b/eco-core/core-plugin/src/main/resources/config.yml @@ -39,6 +39,10 @@ display: enabled: true # If numerals should be used for the enchantment levels threshold: 10 # Above this, numbers will be used instead of numerals + # Options for not met lines: https://plugins.auxilor.io/effects/configuring-a-condition#example-condition-config + not-met: + format: "" # Enchantments with any not-met-lines active will have this format added to them + above-max-level: enabled: true # If enchantments above their max level should have a custom format format: "" # The format to apply