aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni
diff options
context:
space:
mode:
authorLorenz <lo.scherf@gmail.com>2022-09-15 15:37:24 +0200
committerLorenz <lo.scherf@gmail.com>2022-09-15 15:37:24 +0200
commit5503770c826201ab40e141937e6cdd2b0e9788f6 (patch)
tree378d86127037f9a291925d8065a752565f5439dc /src/main/java/at/hannibal2/skyhanni
parent7036145597c0059433c02a047bbf59096ed1d244 (diff)
downloadskyhanni-5503770c826201ab40e141937e6cdd2b0e9788f6.tar.gz
skyhanni-5503770c826201ab40e141937e6cdd2b0e9788f6.tar.bz2
skyhanni-5503770c826201ab40e141937e6cdd2b0e9788f6.zip
fixed skytils dungeon timers not working
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt (renamed from src/main/java/at/hannibal2/skyhanni/features/chat/ChatManager.kt)47
1 files changed, 26 insertions, 21 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/ChatManager.kt b/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt
index f222705cb..38a50da6e 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/chat/ChatManager.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt
@@ -1,4 +1,4 @@
-package at.hannibal2.skyhanni.features.chat
+package at.hannibal2.skyhanni.data
import at.hannibal2.skyhanni.events.LorenzActionBarEvent
import at.hannibal2.skyhanni.events.LorenzChatEvent
@@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.events.PacketEvent
import at.hannibal2.skyhanni.utils.LorenzLogger
import at.hannibal2.skyhanni.utils.LorenzUtils
import net.minecraft.network.play.server.S02PacketChat
+import net.minecraftforge.client.event.ClientChatReceivedEvent
import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -17,7 +18,7 @@ class ChatManager {
private val loggerFilteredTypes = mutableMapOf<String, LorenzLogger>()
@SubscribeEvent(priority = EventPriority.LOW, receiveCanceled = true)
- fun onChatPacket(event: PacketEvent.ReceiveEvent) {
+ fun onActionBarPacket(event: PacketEvent.ReceiveEvent) {
val packet = event.packet
if (packet !is S02PacketChat) return
val messageComponent = packet.chatComponent
@@ -26,26 +27,30 @@ class ChatManager {
if (packet.type.toInt() == 2) {
val actionBarEvent = LorenzActionBarEvent(message)
actionBarEvent.postAndCatch()
- } else {
-
- val chatEvent = LorenzChatEvent(message, messageComponent)
- chatEvent.postAndCatch()
-
- val blockReason = chatEvent.blockedReason.uppercase()
- if (blockReason != "") {
- event.isCanceled = true
- loggerFiltered.log("[$blockReason] $message")
- loggerAll.log("[$blockReason] $message")
- loggerFilteredTypes.getOrPut(blockReason) { LorenzLogger("chat/filter_blocked/$blockReason") }
- .log(message)
- return
- }
-
- if (!message.startsWith("§f{\"server\":\"")) {
- loggerAllowed.log(message)
- loggerAll.log("[allowed] $message")
- }
+ }
+ }
+
+ @SubscribeEvent(receiveCanceled = true)
+ fun onChatReceive(event: ClientChatReceivedEvent) {
+ val messageComponent = event.message
+ val message = LorenzUtils.stripVanillaMessage(messageComponent.formattedText)
+
+ val chatEvent = LorenzChatEvent(message, messageComponent)
+ chatEvent.postAndCatch()
+
+ val blockReason = chatEvent.blockedReason.uppercase()
+ if (blockReason != "") {
+ event.isCanceled = true
+ loggerFiltered.log("[$blockReason] $message")
+ loggerAll.log("[$blockReason] $message")
+ loggerFilteredTypes.getOrPut(blockReason) { LorenzLogger("chat/filter_blocked/$blockReason") }
+ .log(message)
+ return
+ }
+ if (!message.startsWith("§f{\"server\":\"")) {
+ loggerAllowed.log(message)
+ loggerAll.log("[allowed] $message")
}
}
} \ No newline at end of file