diff options
author | ronald <inglettronald@gmail.com> | 2023-07-29 12:28:34 -0500 |
---|---|---|
committer | ronald <inglettronald@gmail.com> | 2023-07-29 12:28:34 -0500 |
commit | 7705c7606298a5c67c64f1e088c4ef93ee042e95 (patch) | |
tree | 6bf06cec66e846f1a35f0463c46d9a5407768cd7 /src/main/kotlin | |
parent | d3e13e38e22b8eecd5198c59cf6a132cc9425b33 (diff) | |
download | DulkirMod-Fabric-7705c7606298a5c67c64f1e088c4ef93ee042e95.tar.gz DulkirMod-Fabric-7705c7606298a5c67c64f1e088c4ef93ee042e95.tar.bz2 DulkirMod-Fabric-7705c7606298a5c67c64f1e088c4ef93ee042e95.zip |
Removed this for now, too buggy and other mods accomplish this
Diffstat (limited to 'src/main/kotlin')
-rw-r--r-- | src/main/kotlin/com/dulkirfabric/features/chat/ChatStacking.kt | 89 |
1 files changed, 46 insertions, 43 deletions
diff --git a/src/main/kotlin/com/dulkirfabric/features/chat/ChatStacking.kt b/src/main/kotlin/com/dulkirfabric/features/chat/ChatStacking.kt index d222540..b7837bd 100644 --- a/src/main/kotlin/com/dulkirfabric/features/chat/ChatStacking.kt +++ b/src/main/kotlin/com/dulkirfabric/features/chat/ChatStacking.kt @@ -9,47 +9,50 @@ import meteordevelopment.orbit.EventHandler import net.minecraft.text.MutableText import net.minecraft.text.Text -object ChatStacking { +// TODO: Fix - this tends to mess with other mod features and also doesn't work on player messages +// and ALSO doesn't work on some multi-line messages sent by the server: For example, the double tap +// to confirm drop message does not stack properly. - data class ChatLog(var timestamp: Long, val message: Text, var frequency: Int) - - private var chatLogs = mutableSetOf<ChatLog>() - private val stackRegex = """ §7\((\d+)\)$""".toRegex() - private val whiteListedMessages = listOf( - "".toRegex(), - "(-+)".toRegex() - ) - - @EventHandler - fun modifyChat(event: ChatEvents.AllowChat) { - chatLogs.forEach { curMsg -> - if (curMsg.message.string.equals(event.message.string)) { - // Probably don't stack empty lines and the long bars - if (whiteListedMessages.any { - it matches event.message.string - }) return - - curMsg.timestamp = System.currentTimeMillis() - curMsg.frequency++ - mc.inGameHud.chatHud.messages.removeIf { msg -> - TextUtils.stripColorCodes(msg.content.string.replace(stackRegex, "")) == curMsg.message.string - && mc.inGameHud.ticks - msg.creationTick <= 1200 - } - mc.inGameHud.chatHud.addMessage(Text.literal("${curMsg.message.formattedString()} §7(${curMsg.frequency})")) - mc.inGameHud.chatHud.refresh() - // TODO: implement something like this to avoid stripColorCodes call - // MutableText.of(event.message.content).append(Text.literal(" §7(${curMsg.frequency})")) - event.cancel() - return - } - } - chatLogs.add(ChatLog(System.currentTimeMillis(), event.message, 1)) - } - - @EventHandler - fun cullLogs(event: LongUpdateEvent) { - chatLogs.removeIf { - System.currentTimeMillis() - it.timestamp >= 60000 - } - } -}
\ No newline at end of file +//object ChatStacking { +// +// data class ChatLog(var timestamp: Long, val message: Text, var frequency: Int) +// +// private var chatLogs = mutableSetOf<ChatLog>() +// private val stackRegex = """ §7\((\d+)\)$""".toRegex() +// private val whiteListedMessages = listOf( +// "".toRegex(), +// "(-+)".toRegex() +// ) +// +// @EventHandler +// fun modifyChat(event: ChatEvents.AllowChat) { +// chatLogs.forEach { curMsg -> +// if (curMsg.message.string.equals(event.message.string)) { +// // Probably don't stack empty lines and the long bars +// if (whiteListedMessages.any { +// it matches event.message.string +// }) return +// +// curMsg.timestamp = System.currentTimeMillis() +// curMsg.frequency++ +// mc.inGameHud.chatHud.messages.removeIf { msg -> +// TextUtils.stripColorCodes(msg.content.string.replace(stackRegex, "")) == curMsg.message.string +// && mc.inGameHud.ticks - msg.creationTick <= 1200 +// } +// mc.inGameHud.chatHud.addMessage(MutableText.of(event.message.content).append(Text.literal(" §7(${curMsg.frequency})"))) +// mc.inGameHud.chatHud.refresh() +// // TODO: implement something like this to avoid stripColorCodes call +// event.cancel() +// return +// } +// } +// chatLogs.add(ChatLog(System.currentTimeMillis(), event.message, 1)) +// } +// +// @EventHandler +// fun cullLogs(event: LongUpdateEvent) { +// chatLogs.removeIf { +// System.currentTimeMillis() - it.timestamp >= 60000 +// } +// } +//}
\ No newline at end of file |