Skip to content

Commit 09088e6

Browse files
authored
Merge pull request #742 from ybw0014/fix/item-name-white-translation
feat(RebarTranslator): apply white color to item names if not set
2 parents 3be6d2a + 3e06735 commit 09088e6

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

rebar/src/main/kotlin/io/github/pylonmc/rebar/i18n/RebarTranslator.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import io.papermc.paper.datacomponent.item.ItemLore
2121
import io.papermc.paper.datacomponent.item.ResolvableProfile
2222
import net.kyori.adventure.key.Key
2323
import net.kyori.adventure.text.*
24+
import net.kyori.adventure.text.format.NamedTextColor
2425
import net.kyori.adventure.text.format.Style
2526
import net.kyori.adventure.translation.GlobalTranslator
2627
import net.kyori.adventure.translation.Translator
@@ -208,12 +209,14 @@ class RebarTranslator private constructor(private val addon: RebarAddon) : Trans
208209
}
209210

210211
val translated = GlobalTranslator.render(it.withArguments(concatenatedArguments), locale)
211-
if (translated is TranslatableComponent && translated.fallback() != null) {
212+
val result = if (translated is TranslatableComponent && translated.fallback() != null) {
212213
Component.text(translated.fallback()!!)
213214
} else {
214215
translated
215216
}
216217

218+
// apply white color if not set
219+
if (result.style().color() == null) result.color(NamedTextColor.WHITE) else result
217220
}
218221
editData(DataComponentTypes.LORE) { lore ->
219222
editPersistentDataContainer { pdc -> pdc.set(originalLoreKey, loreType, lore.lines())}
@@ -303,4 +306,4 @@ class RebarTranslator private constructor(private val addon: RebarAddon) : Trans
303306

304307
private val Material.isPotion: Boolean
305308
get() = this == Material.POTION || this == Material.SPLASH_POTION ||
306-
this == Material.LINGERING_POTION || this == Material.TIPPED_ARROW
309+
this == Material.LINGERING_POTION || this == Material.TIPPED_ARROW

0 commit comments

Comments
 (0)