diff options
author | David Cole <40234707+DavidArthurCole@users.noreply.github.com> | 2024-09-28 15:48:48 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-28 21:48:48 +0200 |
commit | 4ce974d559a080ac8ac95c8cae9147938fc97123 (patch) | |
tree | 9ef13afd7a123e8b239d63d15ea20d17d588c583 /src/main/java/at | |
parent | 533e0448f08d32bc2f6b67775631b47f048bf9ef (diff) | |
download | skyhanni-4ce974d559a080ac8ac95c8cae9147938fc97123.tar.gz skyhanni-4ce974d559a080ac8ac95c8cae9147938fc97123.tar.bz2 skyhanni-4ce974d559a080ac8ac95c8cae9147938fc97123.zip |
Fix: Race Condition in Hoppity Duplicate Number & Stray no-fire (#2595)
Diffstat (limited to 'src/main/java/at')
4 files changed, 20 insertions, 6 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityAPI.kt index 93c9efc04..881b8b5e7 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityAPI.kt @@ -9,6 +9,7 @@ import at.hannibal2.skyhanni.events.hoppity.RabbitFoundEvent import at.hannibal2.skyhanni.features.event.hoppity.HoppityEggType.CHOCOLATE_FACTORY_MILESTONE import at.hannibal2.skyhanni.features.event.hoppity.HoppityEggType.CHOCOLATE_SHOP_MILESTONE import at.hannibal2.skyhanni.features.event.hoppity.HoppityEggType.SIDE_DISH +import at.hannibal2.skyhanni.features.event.hoppity.HoppityEggType.STRAY import at.hannibal2.skyhanni.features.event.hoppity.HoppityEggsManager.eggFoundPattern import at.hannibal2.skyhanni.features.event.hoppity.HoppityEggsManager.getEggType import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryAPI @@ -103,8 +104,18 @@ object HoppityAPI { ChocolateFactoryStrayTracker.strayCaughtPattern.matchMatcher(it.stack.displayName) { ChocolateFactoryStrayTracker.handleStrayClicked(it) when (groupOrNull("name") ?: return@matchMatcher) { - "Fish the Rabbit" -> EggFoundEvent(HoppityEggType.STRAY, it.slotNumber, null).post() - "El Dorado" -> EggFoundEvent(HoppityEggType.STRAY, it.slotNumber, null).post() + "Fish the Rabbit" -> { + EggFoundEvent(STRAY, it.slotNumber, null).post() + lastName = "§9Fish the Rabbit" + lastMeal = STRAY + attemptFireRabbitFound() + } + "El Dorado" -> { + EggFoundEvent(STRAY, it.slotNumber, null).post() + lastName = "§6El Dorado" + lastMeal = STRAY + attemptFireRabbitFound() + } else -> return@matchMatcher } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggsCompactChat.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggsCompactChat.kt index 4a33820d8..0803cd0ea 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggsCompactChat.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggsCompactChat.kt @@ -95,7 +95,7 @@ object HoppityEggsCompactChat { } ?: "?" val dupeNumberFormat = if (eventConfig.showDuplicateNumber) { - (HoppityCollectionStats.getRabbitCount(this.lastName) - 1).takeIf { it > 1}?.let { + (HoppityCollectionStats.getRabbitCount(this.lastName)).takeIf { it > 0 }?.let { " §7(§b#$it§7)" } ?: "" } else "" diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggsManager.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggsManager.kt index b8143d311..bdbe4cd7e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggsManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggsManager.kt @@ -25,6 +25,7 @@ import at.hannibal2.skyhanni.utils.SimpleTimeMark.Companion.now import at.hannibal2.skyhanni.utils.SkyBlockTime import at.hannibal2.skyhanni.utils.SoundUtils import at.hannibal2.skyhanni.utils.TimeUtils.format +import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.util.regex.Matcher import kotlin.time.Duration.Companion.minutes @@ -120,9 +121,11 @@ object HoppityEggsManager { lastNote = event.note } - @HandleEvent + @HandleEvent(priority = HandleEvent.LOWEST) fun onRabbitFound(event: RabbitFoundEvent) { - HoppityCollectionStats.incrementRabbitCount(event.rabbitName) + DelayedRun.runDelayed(1.seconds) { + HoppityCollectionStats.incrementRabbitCount(event.rabbitName) + } } @SubscribeEvent diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryBarnManager.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryBarnManager.kt index a2b264b35..8ce0047d0 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryBarnManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryBarnManager.kt @@ -62,7 +62,7 @@ object ChocolateFactoryBarnManager { HoppityAPI.attemptFireRabbitFound(lastDuplicateAmount = amount) if (hoppityConfig.showDuplicateNumber && !hoppityConfig.compactChat) { - (HoppityCollectionStats.getRabbitCount(HoppityAPI.getLastRabbit()) - 1).takeIf { it > 1 }?.let { + (HoppityCollectionStats.getRabbitCount(HoppityAPI.getLastRabbit())).takeIf { it > 0 }?.let { event.chatComponent = ChatComponentText( event.message.replace("§7§lDUPLICATE RABBIT!", "§7§lDUPLICATE RABBIT! §7(Duplicate §b#$it§7)§r"), ) |