From 0850dc6a0195d7e52cea13cc5838e75d216f81b7 Mon Sep 17 00:00:00 2001 From: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> Date: Sun, 7 Apr 2024 18:39:07 +1000 Subject: Backend: Change stuff around with chat messages (#1227) --- .../hannibal2/skyhanni/config/commands/Commands.kt | 26 +++++++++++----------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni/config/commands') diff --git a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt index 1b8c2bdeb..1e1cc0da3 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt @@ -80,10 +80,7 @@ import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.SoundUtils import at.hannibal2.skyhanni.utils.TabListData import at.hannibal2.skyhanni.utils.repopatterns.RepoPatternGui -import net.minecraft.client.Minecraft import net.minecraft.command.ICommandSender -import net.minecraft.event.ClickEvent -import net.minecraft.event.HoverEvent import net.minecraft.util.BlockPos import net.minecraft.util.ChatComponentText import net.minecraftforge.client.ClientCommandHandler @@ -522,30 +519,33 @@ object Commands { } else { title = "All SkyHanni commands" } - val base = ChatComponentText(" \n§7$title:\n") + + val components = mutableListOf() + components.add(ChatComponentText(" \n§7$title:\n")) + for (command in commands) { if (!filter(command.name) && !filter(command.description)) continue val category = command.category val name = command.name val color = category.color - val text = ChatComponentText("$color/$name") - text.chatStyle.chatClickEvent = ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/$name") val hoverText = buildList { add("§e/$name") - add(" §7${command.description}") + if (command.description.isNotEmpty()) { + add(" §7${command.description}") + } add("") add("$color${category.categoryName}") add(" §7${category.description}") } - text.chatStyle.chatHoverEvent = - HoverEvent(HoverEvent.Action.SHOW_TEXT, ChatComponentText(hoverText.joinToString("\n"))) - base.appendSibling(text) - base.appendSibling(ChatComponentText("§7, ")) + val commandInfo = ChatUtils.createHoverableChat("$color/$name", hoverText, "/$name", false) + + components.add(commandInfo) + components.add(ChatComponentText("§7, ")) } - base.appendSibling(ChatComponentText("\n ")) - Minecraft.getMinecraft().thePlayer.addChatMessage(base) + components.add(ChatComponentText("\n ")) + ChatUtils.multiComponentMessage(components) } @JvmStatic -- cgit