aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt20
2 files changed, 19 insertions, 3 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt
index d01a4a8c3..3b1c02bb0 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt
+++ b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt
@@ -391,7 +391,7 @@ object Commands {
registerCommand("shtestwaypoint", "Set a waypoint on that location") { SkyHanniDebugsAndTests.waypoint(it) }
registerCommand("shtesttablist", "Set your clipboard as a fake tab list.") { TabListData.toggleDebugCommand() }
registerCommand("shreloadlocalrepo", "Reloading the local repo data") { SkyHanniMod.repo.reloadLocalRepo() }
- registerCommand("shchathistory", "Show the unfiltered chat history") { ChatManager.openChatFilterGUI() }
+ registerCommand("shchathistory", "Show the unfiltered chat history") { ChatManager.openChatFilterGUI(it) }
registerCommand(
"shstoplisteners",
"Unregistering all loaded forge event listeners"
diff --git a/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt b/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt
index 915acf214..8573a629f 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt
@@ -5,12 +5,14 @@ import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.events.MessageSendToServerEvent
import at.hannibal2.skyhanni.events.PacketEvent
import at.hannibal2.skyhanni.features.chat.ChatFilterGui
+import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.IdentityCharacteristics
import at.hannibal2.skyhanni.utils.LorenzLogger
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.ReflectionUtils.getClassInstance
import at.hannibal2.skyhanni.utils.ReflectionUtils.getModContainer
import at.hannibal2.skyhanni.utils.ReflectionUtils.makeAccessible
+import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.ChatLine
import net.minecraft.client.gui.GuiNewChat
@@ -40,6 +42,10 @@ object ChatManager {
private fun getRecentMessageHistory(): List<MessageFilteringResult> = messageHistory.toList().map { it.second }
+ private fun getRecentMessageHistoryWithSearch(searchTerm: String): List<MessageFilteringResult> =
+ messageHistory.toList().map { it.second }
+ .filter { it.message.formattedText.removeColor().contains(searchTerm, ignoreCase = true) }
+
enum class ActionKind(format: Any) {
BLOCKED(EnumChatFormatting.RED.toString() + EnumChatFormatting.BOLD),
RETRACTED(EnumChatFormatting.DARK_PURPLE.toString() + EnumChatFormatting.BOLD),
@@ -182,8 +188,18 @@ object ChatManager {
return false
}
- fun openChatFilterGUI() {
- SkyHanniMod.screenToOpen = ChatFilterGui(getRecentMessageHistory())
+ fun openChatFilterGUI(args: Array<String>) {
+ SkyHanniMod.screenToOpen = if (args.isEmpty()) {
+ ChatFilterGui(getRecentMessageHistory())
+ } else {
+ val searchTerm = args.joinToString(" ")
+ val history = getRecentMessageHistoryWithSearch(searchTerm)
+ if (history.isEmpty()) {
+ ChatUtils.chat("§eNot found in chat history! ($searchTerm)")
+ return
+ }
+ ChatFilterGui(history)
+ }
}
private val chatLinesField by lazy {