diff options
author | David Cole <40234707+DavidArthurCole@users.noreply.github.com> | 2024-07-31 17:57:43 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-31 23:57:43 +0200 |
commit | 1829187fd20c43c79810688729fde4ff40f51757 (patch) | |
tree | a00f3deec5a4a8311a608b3989cec275241efae8 /src/main/java | |
parent | a69f9373e0d2311fc9a7c26d318ed168d7fce252 (diff) | |
download | skyhanni-1829187fd20c43c79810688729fde4ff40f51757.tar.gz skyhanni-1829187fd20c43c79810688729fde4ff40f51757.tar.bz2 skyhanni-1829187fd20c43c79810688729fde4ff40f51757.zip |
Fix: Hoppity Goal Levels Off-by-One (#2280)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java')
2 files changed, 37 insertions, 1 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryAPI.kt index 36e8a206a..57b572fe4 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryAPI.kt @@ -12,8 +12,12 @@ import at.hannibal2.skyhanni.features.event.hoppity.HoppityCollectionStats import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.CollectionUtils.nextAfter import at.hannibal2.skyhanni.utils.DelayedRun +import at.hannibal2.skyhanni.utils.ItemUtils.getLore +import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NumberUtil.formatLong +import at.hannibal2.skyhanni.utils.RegexUtils.firstMatcher +import at.hannibal2.skyhanni.utils.RegexUtils.groupOrNull import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.RegexUtils.matches import at.hannibal2.skyhanni.utils.SkyblockSeason @@ -21,6 +25,7 @@ import at.hannibal2.skyhanni.utils.SoundUtils import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.UtilsPatterns import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern +import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration import kotlin.time.Duration.Companion.hours @@ -42,6 +47,25 @@ object ChocolateFactoryAPI { "Hoppity|Chocolate Factory Milestones", ) + /** + * REGEX-TEST: §a§lPROMOTE §8➜ §7[208§7] §dExecutive + * REGEX-TEST: §a§lUPGRADE §8➜ §aRabbit Barn CCXXI + */ + private val upgradeLorePattern by patternGroup.pattern( + "item.lore.upgrade", + "§a§l(?:UPGRADE|PROMOTE) §8➜ (?:§7\\[(?<nextlevel>\\d+)§7] )?(?<upgradename>.*?) ?(?<nextlevelalt>[IVXLCDM]*)\$", + ) + + /** + * REGEX-TEST: §bRabbit Bro§8 - §7[220§7] §bBoard Member + * REGEX-TEST: §6Rabbit Dog§8 - §7[190§7] §6Director + * REGEX-TEST: §dRabbit Daddy§8 - §7[201§7] §dExecutive + */ + private val employeeNamePattern by patternGroup.pattern( + "item.name.employee", + "(?<employee>(?:§.+)+Rabbit .*)§8 - §7\\[\\d*§7] .*", + ) + var rabbitSlots = mapOf<Int, Int>() var otherUpgradeSlots = setOf<Int>() var noPickblockSlots = setOf<Int>() @@ -155,6 +179,17 @@ object ChocolateFactoryAPI { } } + fun getNextLevelName(stack: ItemStack): String? = + upgradeLorePattern.firstMatcher(stack.getLore()) { + val upgradeName = if (stack.getLore().any { it == "§8Employee" }) employeeNamePattern.matchMatcher(stack.name) { + groupOrNull("employee") + } else groupOrNull("upgradename") + val nextLevel = groupOrNull("nextlevel") ?: groupOrNull("nextlevelalt") + if (upgradeName == null || nextLevel == null) null + else "$upgradeName $nextLevel" + } + + fun isEnabled() = LorenzUtils.inSkyBlock && config.enabled // TODO add debug toggle diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryCustomReminder.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryCustomReminder.kt index 10c9ce24a..1f7de017c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryCustomReminder.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryCustomReminder.kt @@ -67,13 +67,14 @@ object ChocolateFactoryCustomReminder { // TODO add support for prestige and for Chocolate Milestone val cost = ChocolateFactoryAPI.getChocolateBuyCost(item.getLore()) ?: return val duration = ChocolateAmount.CURRENT.timeUntilGoal(cost) + val nextLevelName = ChocolateFactoryAPI.getNextLevelName(item) ?: return // the user has enough chocolate, and just bought something if (duration.isNegative()) { reset() return } - setReminder(cost, item.name) + setReminder(cost, nextLevelName) } @SubscribeEvent |