@@ -8,6 +8,15 @@ import net.kyori.adventure.text.format.NamedTextColor
88import net.kyori.adventure.text.format.TextColor
99import net.kyori.adventure.text.format.TextDecoration
1010
11+ /* * What the tab list shows about a player's voice; Java viewers only. */
12+ enum class TabVoice {
13+ ON ,
14+ /* * Switched off in the mod. */
15+ OFF ,
16+ /* * No voice at all, shown only to the player's own party: voice cannot reach them. */
17+ MISSING ,
18+ }
19+
1120object TabName {
1221 private const val GAP = 2
1322
@@ -17,8 +26,8 @@ object TabName {
1726 bedrock : Boolean = false,
1827 bedrockViewer : Boolean = false,
1928 partyMember : Boolean = false,
20- /* * True for voice on, false for voice off, null for no voice; Java viewers only . */
21- voice : Boolean ? = null,
29+ /* * Null draws no voice icon . */
30+ voice : TabVoice ? = null,
2231 ): Component {
2332 val displayName = PlayerDisplayNames .displayName(name, bedrock)
2433 val colour = role?.colour?.let (TextColor ::fromHexString) ? : Palette .TEXT
@@ -42,14 +51,14 @@ object TabName {
4251 )
4352 row.append(Component .text(TabSpaces .of(GAP )).font(TabGlyphs .FONT ))
4453 }
45- voice?.let { on ->
46- row.append(
47- Component .text(
48- if (on) TabGlyphs .VOICE_ON else TabGlyphs . VOICE_OFF ,
49- if (on) Palette . SUCCESS else Palette .TEXT_FAINT ,
50- )
51- .font( TabGlyphs . FONT )
52- )
54+ voice?.let {
55+ val icon =
56+ when (it) {
57+ TabVoice . ON -> Component .text( TabGlyphs .VOICE_ON , Palette . SUCCESS )
58+ TabVoice . OFF -> Component .text( TabGlyphs . VOICE_OFF , Palette .TEXT_FAINT )
59+ TabVoice . MISSING -> Component .text( TabGlyphs . VOICE_OFF , Palette . DANGER )
60+ }
61+ row.append(icon.font( TabGlyphs . FONT ) )
5362 row.append(Component .text(TabSpaces .of(GAP )).font(TabGlyphs .FONT ))
5463 }
5564 row.append(nameText)
0 commit comments