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

import dulkirmod.DulkirMod
import net.minecraftforge.client.event.ClientChatReceivedEvent
import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent

class ChatEvent {
    @SubscribeEvent(receiveCanceled = true, priority = EventPriority.LOW)
    fun onChat(event: ClientChatReceivedEvent) {
        if (event.type == 2.toByte()) {
            return
        }
        val unformatted = stripColorCodes(event.message.unformattedText)
        if (unformatted == "Warping you to your SkyBlock island..." && DulkirMod.config.throttleNotifier) {
            event.isCanceled = true;
            DulkirMod.mc.thePlayer.sendChatMessage("/pc " + DulkirMod.config.customMessage)
        }
    }
    private fun stripColorCodes(string: String): String {
        return string.replace("§.".toRegex(), "")
    }
}