aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/com/raeids/stratus/hook/ChatSearching.kt
diff options
context:
space:
mode:
authorWyvest <45589059+Wyvest@users.noreply.github.com>2021-12-26 19:42:24 +0700
committerWyvest <45589059+Wyvest@users.noreply.github.com>2021-12-26 19:42:24 +0700
commit641e50e9c509981df6a7d3fb5a29ff7e3dbe4d47 (patch)
treeb9f429d0e9e73f9f2ad0f6597e3da4683fdb663d /src/main/kotlin/com/raeids/stratus/hook/ChatSearching.kt
parent913ab61c3637833e445669ad252a72b9d6e5947d (diff)
downloadChatting-641e50e9c509981df6a7d3fb5a29ff7e3dbe4d47.tar.gz
Chatting-641e50e9c509981df6a7d3fb5a29ff7e3dbe4d47.tar.bz2
Chatting-641e50e9c509981df6a7d3fb5a29ff7e3dbe4d47.zip
enabled (real)
Diffstat (limited to 'src/main/kotlin/com/raeids/stratus/hook/ChatSearching.kt')
-rw-r--r--src/main/kotlin/com/raeids/stratus/hook/ChatSearching.kt41
1 files changed, 0 insertions, 41 deletions
diff --git a/src/main/kotlin/com/raeids/stratus/hook/ChatSearching.kt b/src/main/kotlin/com/raeids/stratus/hook/ChatSearching.kt
deleted file mode 100644
index 6dd4904..0000000
--- a/src/main/kotlin/com/raeids/stratus/hook/ChatSearching.kt
+++ /dev/null
@@ -1,41 +0,0 @@
-package com.raeids.stratus.hook
-
-import gg.essential.lib.caffeine.cache.Cache
-import gg.essential.lib.caffeine.cache.Caffeine
-import gg.essential.universal.wrappers.message.UTextComponent
-import net.minecraft.client.Minecraft
-import net.minecraft.client.gui.ChatLine
-import java.util.concurrent.LinkedBlockingQueue
-import java.util.concurrent.ThreadPoolExecutor
-import java.util.concurrent.TimeUnit
-import java.util.concurrent.atomic.AtomicInteger
-
-private var counter: AtomicInteger = AtomicInteger(0)
-private var POOL: ThreadPoolExecutor = ThreadPoolExecutor(
- 50, 50,
- 0L, TimeUnit.SECONDS,
- LinkedBlockingQueue()
-) { r ->
- Thread(
- r,
- "Chat Filter Cache Thread ${counter.incrementAndGet()}"
- )
-}
-
-val cache: Cache<String, List<ChatLine>> = Caffeine.newBuilder().executor(POOL).maximumSize(5000).build()
-
-fun filterMessages(text: String, list: List<ChatLine>): List<ChatLine>? {
- if (text.isBlank()) return list
- val cached = cache.getIfPresent(text)
- return cached ?: run {
- cache.put(text, list.filter {
- UTextComponent.stripFormatting(it.chatComponent.unformattedText).lowercase()
- .contains(text.lowercase())
- })
- cache.getIfPresent(text)
- }
-}
-
-fun setPrevText(text: String) {
- (Minecraft.getMinecraft().ingameGUI.chatGUI as GuiNewChatHook).prevText = text
-} \ No newline at end of file