From 45428b06e4cc99255a358f9e9dd34515670c70f5 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Fri, 16 Jun 2023 14:01:52 +0200 Subject: made copied error logs smaller --- .../hannibal2/skyhanni/test/command/CopyErrorCommand.kt | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/main/java/at/hannibal2/skyhanni/test/command/CopyErrorCommand.kt b/src/main/java/at/hannibal2/skyhanni/test/command/CopyErrorCommand.kt index c2a35027d..a8c6660f3 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/command/CopyErrorCommand.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/command/CopyErrorCommand.kt @@ -31,15 +31,25 @@ object CopyErrorCommand { if (cache.getIfPresent(pair) != null) return cache.put(pair, Unit) - val stackTrace = error.stackTraceToString() + val stackTrace = error.stackTraceToString().removeSpam() val randomId = UUID.randomUUID().toString() errorMessages[randomId] = - "```\nSkyHanni ${SkyHanniMod.version}: $message\n$stackTrace```" + "```\nSkyHanni ${SkyHanniMod.version}: $message\n \n$stackTrace```" LorenzUtils.clickableChat( "§c[SkyHanni ${SkyHanniMod.version}]: $message. Click here to copy the error into the clipboard.", "shcopyerror $randomId" ) } -} \ No newline at end of file +} + +private fun String.removeSpam(): String { + val ignored = listOf( + "at io.netty.", + "at net.minecraft.network.", + "at net.minecraftforge.fml.common.network.handshake.", + "at java.lang.Thread.run", + ) + return split("\r\n\t").filter { line -> !ignored.any { line.startsWith(it) } }.joinToString("\n") +} -- cgit