aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/chat/RareDropMessages.kt55
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
+ }
}
}