aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/dulkirmod/features/chat/ThrottleNotif.kt
blob: f6a90ebabfb01ed15e9fb70576d645e6745607a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package dulkirmod.features.chat

import dulkirmod.DulkirMod
import dulkirmod.config.Config
import dulkirmod.utils.TextUtils
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 > 8000) {
                TextUtils.sendPartyChatMessage(DulkirMod.config.customMessage)
            } else if (Config.throttleNotifierSpam) {
                TextUtils.sendPartyChatMessage(DulkirMod.config.customMessage)
            }
            lastThrottle = System.currentTimeMillis()
        }
    }
}