aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features/fishing
diff options
context:
space:
mode:
authorLuna <me@lunya.dev>2024-09-21 11:06:46 +0200
committerGitHub <noreply@github.com>2024-09-21 11:06:46 +0200
commit8a0a2fb1e27ee2a08a0bcb14634ab8ef134ba61b (patch)
tree42f50bc409b60d04ac2d14f2ace41c03e17eddd6 /src/main/java/at/hannibal2/skyhanni/features/fishing
parentbbbb9c22ad99ac887d1a4d624c594818e81a7189 (diff)
downloadskyhanni-8a0a2fb1e27ee2a08a0bcb14634ab8ef134ba61b.tar.gz
skyhanni-8a0a2fb1e27ee2a08a0bcb14634ab8ef134ba61b.tar.bz2
skyhanni-8a0a2fb1e27ee2a08a0bcb14634ab8ef134ba61b.zip
Fix: Totem of Corruption expiry warning sometimes not working (#2554)
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/fishing')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt
index 0410a04a9..c8ff17a9e 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt
@@ -22,6 +22,7 @@ import at.hannibal2.skyhanni.utils.RenderUtils.drawSphereInWorld
import at.hannibal2.skyhanni.utils.RenderUtils.drawSphereWireframeInWorld
import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings
import at.hannibal2.skyhanni.utils.SoundUtils.playPlingSound
+import at.hannibal2.skyhanni.utils.TimeLimitedSet
import at.hannibal2.skyhanni.utils.TimeUnit
import at.hannibal2.skyhanni.utils.TimeUtils.format
import at.hannibal2.skyhanni.utils.getLorenzVec
@@ -29,7 +30,9 @@ import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraft.entity.item.EntityArmorStand
import net.minecraft.util.EnumParticleTypes
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import java.util.UUID
import kotlin.time.Duration
+import kotlin.time.Duration.Companion.minutes
import kotlin.time.Duration.Companion.seconds
@SkyHanniModule
@@ -39,6 +42,7 @@ object TotemOfCorruption {
private var display = emptyList<String>()
private var totems: List<Totem> = emptyList()
+ private val warnedTotems = TimeLimitedSet<UUID>(2.minutes)
private val patternGroup = RepoPattern.group("fishing.totemofcorruption")
private val totemNamePattern by patternGroup.pattern(
@@ -154,9 +158,10 @@ object TotemOfCorruption {
val owner = getOwner(totem) ?: return@mapNotNull null
val timeToWarn = config.warnWhenAboutToExpire.seconds
- if (timeToWarn > 0.seconds && timeRemaining == timeToWarn) {
+ if (timeToWarn > 0.seconds && timeRemaining <= timeToWarn && !warnedTotems.contains(totem.uniqueID)) {
playPlingSound()
sendTitle("§c§lTotem of Corruption §eabout to expire!", 5.seconds)
+ warnedTotems.add(totem.uniqueID)
}
Totem(totem.getLorenzVec(), timeRemaining, owner)
}