From c59e76b4968f18bd91bc46834913cab0fcbf670a Mon Sep 17 00:00:00 2001 From: Empa <42304516+ItsEmpa@users.noreply.github.com> Date: Mon, 11 Mar 2024 17:43:10 +0100 Subject: Pet rarity on pet drop message (#1136) --- .../skyhanni/features/chat/RareDropMessages.kt | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/main/java/at/hannibal2/skyhanni/features/chat/RareDropMessages.kt (limited to 'src/main/java/at/hannibal2/skyhanni/features') diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/RareDropMessages.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/RareDropMessages.kt new file mode 100644 index 000000000..6d67b757a --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/chat/RareDropMessages.kt @@ -0,0 +1,37 @@ +package at.hannibal2.skyhanni.features.chat + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.LorenzUtils.colorCodeToRarity +import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern +import net.minecraft.util.ChatComponentText +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class RareDropMessages { + + private val petDropPattern by RepoPattern.pattern( + "pet.petdropmessage", + "(?§6§lPET DROP!|§5§lGREAT CATCH! §r§bYou found a §r§7\\[Lvl 1]) (?:§r)?§(?.)(?[^§(.]+)(?.*)" + ) + + private val config get() = SkyHanniMod.feature.chat.petRarityDropMessage + + @SubscribeEvent + fun onChat(event: LorenzChatEvent) { + if (!LorenzUtils.inSkyBlock) return + if (!config) return + + petDropPattern.matchMatcher(event.message) { + val typeOfDrop = group("typeOfDrop") + val rarityColor = group("rarityColor") + val petName = group("petName") + val magicFindOrFarmingFortune = group("magicFindOrFarmingFortune") + + event.chatComponent = ChatComponentText( + "$typeOfDrop §$rarityColor§l${colorCodeToRarity(rarityColor.first()).uppercase()} §$rarityColor$petName$magicFindOrFarmingFortune" + ) + } ?: return + } +} -- cgit