diff options
author | Empa <42304516+ItsEmpa@users.noreply.github.com> | 2024-03-23 18:48:02 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-23 18:48:02 +0100 |
commit | 64984949a048be142dec75c54358c754351181f2 (patch) | |
tree | 8f172b9152b7d58cbf8689dd32ec1a93eac825d9 /src | |
parent | 2e579fc0444724de51f1a4bb023e3b5278f3421b (diff) | |
download | skyhanni-64984949a048be142dec75c54358c754351181f2.tar.gz skyhanni-64984949a048be142dec75c54358c754351181f2.tar.bz2 skyhanni-64984949a048be142dec75c54358c754351181f2.zip |
Fix Crop milestones pest drops (#1243)
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneFix.kt | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneFix.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneFix.kt index bba86c595..79461a78a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneFix.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneFix.kt @@ -8,6 +8,9 @@ import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.TabListUpdateEvent import at.hannibal2.skyhanni.features.garden.farming.GardenCropMilestoneDisplay import at.hannibal2.skyhanni.utils.ChatUtils +import at.hannibal2.skyhanni.utils.ItemUtils.itemNameWithoutColor +import at.hannibal2.skyhanni.utils.NEUInternalName +import at.hannibal2.skyhanni.utils.NEUItems import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimalIfNecessary import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher @@ -24,6 +27,21 @@ class GardenCropMilestoneFix { "levelup", " {2}§r§b§lGARDEN MILESTONE §3(?<crop>.*) §8.*➜§3(?<tier>.*)" ) + /** + * REGEX-TEST: §eYou received §a7x Enchanted Potato §efor killing a §6Locust§e! + * REGEX-TEST: §eYou received §a6x Enchanted Cocoa Beans §efor killing a §6Moth§e! + */ + private val pestLootPattern by patternGroup.pattern( + "pests.loot", + "§eYou received §a(?<amount>[0-9]*)x (?<item>.*) §efor killing an? §6(?<pest>.*)§e!" + ) + /** + * REGEX-TEST: §6§lRARE DROP! §9Mutant Nether Wart §6(§6+1,344☘) + */ + private val pestRareDropPattern by patternGroup.pattern( + "pests.raredrop", + "§6§lRARE DROP! (?:§.)*(?<item>.+) §6\\(§6\\+.*☘\\)" + ) private val tabListCropProgress = mutableMapOf<CropType, Long>() @@ -38,6 +56,31 @@ class GardenCropMilestoneFix { val crops = GardenCropMilestones.getCropsForTier(tier, crop) changedValue(crop, crops, "level up chat message", 0) } + pestLootPattern.matchMatcher(event.message) { + val amount = group("amount").toInt() + val item = NEUInternalName.fromItemNameOrNull(group("item")) ?: return + + val multiplier = NEUItems.getMultiplier(item) + val rawName = multiplier.first.itemNameWithoutColor + val cropType = CropType.getByNameOrNull(rawName) ?: return + + cropType.setCounter( + cropType.getCounter() + (amount * multiplier.second) + ) + GardenCropMilestoneDisplay.update() + } + pestRareDropPattern.matchMatcher(event.message) { + val item = NEUInternalName.fromItemNameOrNull(group("item")) ?: return + + val multiplier = NEUItems.getMultiplier(item) + val rawName = multiplier.first.itemNameWithoutColor + val cropType = CropType.getByNameOrNull(rawName) ?: return + + cropType.setCounter( + cropType.getCounter() + multiplier.second + ) + GardenCropMilestoneDisplay.update() + } } @SubscribeEvent |