diff options
author | Empa <42304516+ItsEmpa@users.noreply.github.com> | 2024-04-13 22:00:12 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-13 22:00:12 +0200 |
commit | 714a722e748cb082af808c3168e7e7ab0c594adb (patch) | |
tree | bb1a0d34dac7ace1088c0fd51fd717f4989a6c2f /src/main/java/at/hannibal2 | |
parent | e3f1794b61cc4ad7a48b15ed1abb0b28eeaa71eb (diff) | |
download | skyhanni-714a722e748cb082af808c3168e7e7ab0c594adb.tar.gz skyhanni-714a722e748cb082af808c3168e7e7ab0c594adb.tar.bz2 skyhanni-714a722e748cb082af808c3168e7e7ab0c594adb.zip |
Improvement: More pet drop messages (#1213)
Diffstat (limited to 'src/main/java/at/hannibal2')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/chat/RareDropMessages.kt | 55 |
1 files changed, 46 insertions, 9 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/RareDropMessages.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/RareDropMessages.kt index 6d67b757a..297c3b098 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/chat/RareDropMessages.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/chat/RareDropMessages.kt @@ -4,16 +4,50 @@ 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.StringUtils.matchMatchers 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", - "(?<typeOfDrop>§6§lPET DROP!|§5§lGREAT CATCH! §r§bYou found a §r§7\\[Lvl 1]) (?:§r)?§(?<rarityColor>.)(?<petName>[^§(.]+)(?<magicFindOrFarmingFortune>.*)" + private val chatGroup = RepoPattern.group("pet.chatdrop") + + /** + * REGEX-TEST: §6§lPET DROP! §r§5Baby Yeti §r§b(+§r§b168% §r§b✯ Magic Find§r§b) + * REGEX-TEST: §6§lPET DROP! §r§5Slug §6(§6+1300☘) + */ + private val petDroppedPattern by chatGroup.pattern( + "pet.petdroppedmessage", + "(?<start>(?:§.)*PET DROP! )(?:§.)*§(?<rarityColor>.)(?<petName>[^§(.]+)(?<end> .*)" + ) + + /** + * REGEX-TEST: §5§lGREAT CATCH! §r§bYou found a §r§7[Lvl 1] §r§aGuardian§r§b. + */ + private val petFishedPattern by chatGroup.pattern( + "pet.petfishedmessage", + "(?<start>(?:§.)*GREAT CATCH! (?:§.)*You found a (?:§.)*\\[Lvl 1] )(?:§.)*§(?<rarityColor>.)(?<petName>[^§(.]+)(?<end>.*)" + ) + + /** + * REGEX-TEST: §aYou claimed a §5Tarantula Pet§a! §r§aYou can manage your Pets in the §r§fPets Menu§r§a in your §r§fSkyBlock Menu§r§a. + */ + private val petClaimedPattern by chatGroup.pattern( + "pet.petclaimedmessage", + "(?<start>(?:§.)*You claimed a )(?:§.)*§(?<rarityColor>.)(?<petName>[^§(.]+)(?<end>.*)" + ) + + /** + * REGEX-TEST: §b[MVP§r§c+§r§b] Empa_§r§f §r§ehas obtained §r§a§r§7[Lvl 1] §r§6Bal§r§e! + */ + private val petObtainedPattern by chatGroup.pattern( + "pet.petobtainedmessage", + "(?<start>.*has obtained (?:§.)*\\[Lvl 1] )(?:§.)*§(?<rarityColor>.)(?<petName>[^§(.]+)(?<end>.*)" + ) + + private val patterns = listOf( + petDroppedPattern, petFishedPattern, petClaimedPattern, petObtainedPattern ) private val config get() = SkyHanniMod.feature.chat.petRarityDropMessage @@ -23,15 +57,18 @@ class RareDropMessages { if (!LorenzUtils.inSkyBlock) return if (!config) return - petDropPattern.matchMatcher(event.message) { - val typeOfDrop = group("typeOfDrop") + patterns.matchMatchers(event.message) { + var start = group("start") val rarityColor = group("rarityColor") + val rarityName = colorCodeToRarity(rarityColor.first()).uppercase() val petName = group("petName") - val magicFindOrFarmingFortune = group("magicFindOrFarmingFortune") + val end = group("end") + if (start.endsWith("a ") && rarityName.matches("(?i)[aeiou].*".toRegex())) + start = start.replace(" $".toRegex(), "n ") event.chatComponent = ChatComponentText( - "$typeOfDrop §$rarityColor§l${colorCodeToRarity(rarityColor.first()).uppercase()} §$rarityColor$petName$magicFindOrFarmingFortune" + "$start§$rarityColor§l$rarityName §$rarityColor$petName$end" ) - } ?: return + } } } |