summaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/test/command
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/test/command')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/test/command/TestChatCommand.kt33
1 files changed, 22 insertions, 11 deletions
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)