blob: c5e465b54e3c99d70d31ca374e08d3bbfada474b (
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
25
26
27
28
29
30
31
32
33
34
35
36
|
package at.hannibal2.skyhanni.features.misc
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import net.minecraft.util.ChatComponentText
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import java.util.regex.Pattern
class CompactSplashPotionMessage {
private val POTION_EFFECT_PATTERN =
Pattern.compile("§a§lBUFF! §fYou have gained §r(.*)§r§f! Press TAB or type /effects to view your active effects!")
private val POTION_EFFECT_OTHERS_PATTERN =
Pattern.compile("§a§lBUFF! §fYou were splashed by (.*) §fwith §r(.*)§r§f! Press TAB or type /effects to view your active effects!")
@SubscribeEvent
fun onChatMessage(event: LorenzChatEvent) {
if (!LorenzUtils.inSkyBlock || !SkyHanniMod.feature.chat.compactPotionMessage) return
var matcher = POTION_EFFECT_PATTERN.matcher(event.message)
if (matcher.matches()) {
val name = matcher.group(1)
event.chatComponent = ChatComponentText("§a§lPotion Effect! §r$name")
}
matcher = POTION_EFFECT_OTHERS_PATTERN.matcher(event.message)
if (matcher.matches()) {
val playerName = matcher.group(1).removeColor()
val effectName = matcher.group(2)
event.chatComponent = ChatComponentText("§a§lPotion Effect! §r$effectName by §b$playerName")
}
}
}
|