diff --git a/eco-core/core-nms/modern/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/modern/NewEcoFastItemStack.kt b/eco-core/core-nms/modern/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/modern/NewEcoFastItemStack.kt index aaa5ec804..a5a6fe8a6 100644 --- a/eco-core/core-nms/modern/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/modern/NewEcoFastItemStack.kt +++ b/eco-core/core-nms/modern/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/modern/NewEcoFastItemStack.kt @@ -14,6 +14,8 @@ import com.willfp.eco.util.StringUtils import com.willfp.eco.util.toComponent import com.willfp.eco.util.toLegacy import net.kyori.adventure.text.Component +import net.kyori.adventure.text.format.Style +import net.kyori.adventure.text.format.TextColor import net.kyori.adventure.text.format.TextDecoration import net.minecraft.core.component.DataComponentType import net.minecraft.core.component.DataComponents @@ -37,6 +39,10 @@ private val unstyledComponent = Component.empty().style { it.color(null).decoration(TextDecoration.ITALIC, false) } +private fun Component.unstyled(): Component { + return unstyledComponent.append(this) +} + class NewEcoFastItemStack( private val bukkit: ItemStack ) : ImplementedFIS { @@ -102,7 +108,7 @@ class NewEcoFastItemStack( handle.set(DataComponents.LORE, null) } else { val components = lore - .map { unstyledComponent.append(it) } + .map { it.unstyled() } .map { it.toNMS() } handle.set( @@ -126,8 +132,12 @@ class NewEcoFastItemStack( override fun setDisplayName(name: Component?) { if (name == null) { handle.set(DataComponents.ITEM_NAME, null) + handle.set(DataComponents.CUSTOM_NAME, null) } else { - handle.set(DataComponents.ITEM_NAME, unstyledComponent.append(name).toNMS()) + handle.set( + DataComponents.CUSTOM_NAME, + name.unstyled().toNMS() + ) } apply()