diff options
author | ingle <inglettronald@gmail.com> | 2022-10-29 12:12:03 -0500 |
---|---|---|
committer | ingle <inglettronald@gmail.com> | 2022-10-29 12:12:03 -0500 |
commit | 393d4c8e14730a5c9b31695f722b6de9480508ec (patch) | |
tree | f8c9c1143e17e8578cc1567d3a464e219459f69f /src/main/kotlin/dulkirmod/features/chat/ThrottleNotif.kt | |
parent | 798b38e5f3579469192916b69427ce46127deead (diff) | |
download | DulkirMod-393d4c8e14730a5c9b31695f722b6de9480508ec.tar.gz DulkirMod-393d4c8e14730a5c9b31695f722b6de9480508ec.tar.bz2 DulkirMod-393d4c8e14730a5c9b31695f722b6de9480508ec.zip |
+ abiphone do not disturb
= refactored chatevent code for readability
Diffstat (limited to 'src/main/kotlin/dulkirmod/features/chat/ThrottleNotif.kt')
-rw-r--r-- | src/main/kotlin/dulkirmod/features/chat/ThrottleNotif.kt | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/main/kotlin/dulkirmod/features/chat/ThrottleNotif.kt b/src/main/kotlin/dulkirmod/features/chat/ThrottleNotif.kt new file mode 100644 index 0000000..b17f301 --- /dev/null +++ b/src/main/kotlin/dulkirmod/features/chat/ThrottleNotif.kt @@ -0,0 +1,23 @@ +package dulkirmod.features.chat + +import dulkirmod.DulkirMod +import dulkirmod.config.Config +import dulkirmod.utils.Utils +import net.minecraftforge.client.event.ClientChatReceivedEvent + +object ThrottleNotif { + private var lastThrottle : Long = 0 + fun handle(event: ClientChatReceivedEvent, unformatted: String) { + if (unformatted == "This menu has been throttled! Please slow down..." && DulkirMod.config.throttleNotifier + && Utils.isInDungeons()) { + event.isCanceled = true; + if (!Config.throttleNotifierSpam && System.currentTimeMillis() - lastThrottle > 3000) { + DulkirMod.mc.thePlayer.sendChatMessage("/pc " + DulkirMod.config.customMessage) + } + else { + DulkirMod.mc.thePlayer.sendChatMessage("/pc " + DulkirMod.config.customMessage) + } + lastThrottle = System.currentTimeMillis() + } + } +}
\ No newline at end of file |