From 2d9844426886cd488703d05ee58558e05d4c3987 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Wed, 8 May 2024 21:13:21 +0200 Subject: Feature: Profit per corpse loot (#1734) Co-authored-by: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../skyhanni/test/command/TestChatCommand.kt | 33 ++++++++++++++-------- 1 file changed, 22 insertions(+), 11 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni/test/command') diff --git a/src/main/java/at/hannibal2/skyhanni/test/command/TestChatCommand.kt b/src/main/java/at/hannibal2/skyhanni/test/command/TestChatCommand.kt index 2007e5b99..6d67a9ad0 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/command/TestChatCommand.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/command/TestChatCommand.kt @@ -21,24 +21,35 @@ object TestChatCommand { val isComplex = mutArgs.remove("-complex") val isClipboard = mutArgs.remove("-clipboard") val isHidden = mutArgs.remove("-s") + val multiLines = mutArgs.remove("-lines") val text = if (isClipboard) { OSUtils.readFromClipboard() ?: return@launchCoroutine ChatUtils.userError("Clipboard does not contain a string!") } else mutArgs.joinToString(" ") - val component = - if (isComplex) - try { - IChatComponent.Serializer.jsonToComponent(text) - } catch (ex: Exception) { - ChatUtils.userError("Please provide a valid JSON chat component (either in the command or via -clipboard)") - return@launchCoroutine - } - else ChatComponentText(text.replace("&", "§")) - if (!isHidden) ChatUtils.chat("Testing message: §7${component.formattedText}", prefixColor = "§a") - test(component) + if (multiLines) { + for (line in text.split("\n")) { + extracted(isComplex, line, isHidden) + } + } else { + extracted(isComplex, text, isHidden) + } } } + private fun extracted(isComplex: Boolean, text: String, isHidden: Boolean) { + val component = + if (isComplex) + try { + IChatComponent.Serializer.jsonToComponent(text) + } catch (ex: Exception) { + ChatUtils.userError("Please provide a valid JSON chat component (either in the command or via -clipboard)") + return + } + else ChatComponentText(text.replace("&", "§")) + if (!isHidden) ChatUtils.chat("Testing message: §7${component.formattedText}", prefixColor = "§a") + test(component) + } + private fun test(componentText: IChatComponent) { val message = componentText.formattedText.stripHypixelMessage() val event = LorenzChatEvent(message, componentText) -- cgit