aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal002@users.noreply.github.com>2024-03-12 19:07:36 +0100
committerGitHub <noreply@github.com>2024-03-12 19:07:36 +0100
commitf95be461444fd7fb26c6d9f1586bad6a28fde6b5 (patch)
tree72a5ae2a574c1aa57c596a8f72e97d186f8b5dbe /src/main
parent21fadf13df106bfa76c8e9a2e735ea346aba8cba (diff)
downloadskyhanni-f95be461444fd7fb26c6d9f1586bad6a28fde6b5.tar.gz
skyhanni-f95be461444fd7fb26c6d9f1586bad6a28fde6b5.tar.bz2
skyhanni-f95be461444fd7fb26c6d9f1586bad6a28fde6b5.zip
Internal Change: /shtestmessage upgrade (#1145)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/test/command/TestChatCommand.kt38
1 files changed, 32 insertions, 6 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 0f14c94fd..6a1fb52f8 100644
--- a/src/main/java/at/hannibal2/skyhanni/test/command/TestChatCommand.kt
+++ b/src/main/java/at/hannibal2/skyhanni/test/command/TestChatCommand.kt
@@ -1,9 +1,11 @@
package at.hannibal2.skyhanni.test.command
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.utils.ChatUtils
+import at.hannibal2.skyhanni.utils.OSUtils
+import kotlinx.coroutines.launch
import net.minecraft.util.ChatComponentText
-import net.minecraftforge.client.event.ClientChatReceivedEvent
-import net.minecraftforge.common.MinecraftForge
object TestChatCommand {
@@ -13,12 +15,36 @@ object TestChatCommand {
return
}
- val hidden = args.last() == "-s"
+ val last = args.last()
+ if (last == "-clipboard") {
+ SkyHanniMod.coroutineScope.launch {
+ OSUtils.readFromClipboard()?.let {
+ test(it)
+ } ?: run {
+ ChatUtils.userError("Clipboard does not contain a string!")
+ }
+ }
+ return
+ }
+ val hidden = last == "-s"
var rawMessage = args.toList().joinToString(" ")
if (!hidden) ChatUtils.chat("Testing message: §7$rawMessage", prefixColor = "§a")
if (hidden) rawMessage = rawMessage.replace(" -s", "")
- val formattedMessage = rawMessage.replace("&", "§")
- ChatUtils.chat(formattedMessage, false)
- MinecraftForge.EVENT_BUS.post(ClientChatReceivedEvent(0, ChatComponentText(formattedMessage)))
+ test(rawMessage.replace("&", "§"))
+ }
+
+ private fun test(message: String) {
+ val event = LorenzChatEvent(message, ChatComponentText(message))
+ event.postAndCatch()
+
+ if (event.blockedReason != "") {
+ ChatUtils.chat("§cChat blocked: ${event.blockedReason}")
+ } else {
+ val finalMessage = event.chatComponent.formattedText
+ if (finalMessage != message) {
+ ChatUtils.chat("§eChat modified!")
+ }
+ ChatUtils.chat(finalMessage, false)
+ }
}
}