mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2025-01-21 00:21:20 +01:00
Added not-met-format
This commit is contained in:
parent
8760be40d0
commit
a587c5dc3a
@ -73,11 +73,17 @@ class EnchantDisplay(private val plugin: EcoEnchantsPlugin) : DisplayModule(plug
|
||||
val notMetLines = mutableListOf<String>()
|
||||
|
||||
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) {
|
||||
|
@ -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")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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: "<strikethrough>" # 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: "<gradient:#1D976C:#93F9B9>" # The format to apply
|
||||
|
Loading…
Reference in New Issue
Block a user