Skip to content

Commit bdb9dd1

Browse files
committed
Cleaner metadata hover
1 parent 5fd4560 commit bdb9dd1

File tree

1 file changed

+27
-14
lines changed

1 file changed

+27
-14
lines changed

common/src/main/kotlin/com/lambda/util/Communication.kt

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,23 @@ object Communication {
128128

129129
private fun TextBuilder.commandSource(command: LambdaCommand, color: Color) {
130130
hoverEvent(HoverEvents.showText(buildText {
131-
literal(command.description)
132-
literal("\n")
133-
literal(command.usage)
134-
literal("\n")
135-
literal("Aliases: ")
136-
joinToText(command.aliases) {
131+
if (command.description.isNotBlank()) {
132+
literal(command.description)
133+
}
134+
if (command.usage.isNotBlank()) {
135+
literal("\n")
136+
literal("Usage: ")
137137
color(GuiSettings.primaryColor) {
138-
literal(it)
138+
literal(command.usage)
139+
}
140+
}
141+
if (command.aliases.isNotEmpty()) {
142+
literal("\n")
143+
literal("Aliases: ")
144+
joinToText(command.aliases) {
145+
color(GuiSettings.primaryColor) {
146+
literal(it)
147+
}
139148
}
140149
}
141150
})) {
@@ -147,8 +156,10 @@ object Communication {
147156

148157
private fun TextBuilder.moduleSource(module: Module, color: Color) {
149158
hoverEvent(HoverEvents.showText(buildText {
150-
literal(module.description)
151-
literal("\n")
159+
if (module.description.isNotBlank()) {
160+
literal(module.description)
161+
literal("\n")
162+
}
152163
literal("Keybind: ")
153164
color(GuiSettings.primaryColor) {
154165
if (module.keybind.keyCode != -1) {
@@ -158,11 +169,13 @@ object Communication {
158169
}
159170

160171
}
161-
literal("\n")
162-
literal("Default tags: ")
163-
joinToText(module.defaultTags) {
164-
color(GuiSettings.primaryColor) {
165-
literal(it.name)
172+
if (module.defaultTags.isNotEmpty()) {
173+
literal("\n")
174+
literal("Default tags: ")
175+
joinToText(module.defaultTags) {
176+
color(GuiSettings.primaryColor) {
177+
literal(it.name)
178+
}
166179
}
167180
}
168181
if (module.customTags.value.isNotEmpty()) {

0 commit comments

Comments
 (0)