From 412097d596e66c921219e048a2224e35bc027d0e Mon Sep 17 00:00:00 2001 From: Auxilor Date: Sat, 2 Oct 2021 12:53:23 +0100 Subject: [PATCH] Fixed display in name --- .../willfp/reforges/display/ReforgesDisplay.kt | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/reforges/display/ReforgesDisplay.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/reforges/display/ReforgesDisplay.kt index 4affe63..7932632 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/reforges/display/ReforgesDisplay.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/reforges/display/ReforgesDisplay.kt @@ -19,6 +19,11 @@ import org.bukkit.inventory.meta.SkullMeta @Suppress("DEPRECATION") class ReforgesDisplay(private val plugin: ReforgesPlugin) : DisplayModule(plugin, DisplayPriority.HIGHEST) { + private val replacement = TextReplacementConfig.builder() + .match("§w(.+)§w") + .replacement("") + .build() + override fun display( itemStack: ItemStack, vararg args: Any @@ -74,10 +79,7 @@ class ReforgesDisplay(private val plugin: ReforgesPlugin) : DisplayModule(plugin val displayName = (if (meta.hasDisplayName()) meta.displayName()!! else Component.translatable(itemStack)) .replaceText( - TextReplacementConfig.builder() - .match("§w(.)§w") - .replacement("") - .build() + replacement ) val newName = StringUtils.toComponent("§w${reforge.name} §w") .decoration(TextDecoration.ITALIC, false).append(displayName) @@ -101,10 +103,7 @@ class ReforgesDisplay(private val plugin: ReforgesPlugin) : DisplayModule(plugin val displayName = meta.displayName() ?: return meta.displayName( displayName.replaceText( - TextReplacementConfig.builder() - .match("§w(.)§w") - .replacement("") - .build() + replacement ) ) }