Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Totem of Corruption expiry warning sometimes not working #2554

Merged
merged 3 commits into from
Sep 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,17 @@ 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
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
Expand All @@ -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(
Expand Down Expand Up @@ -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)
}
Expand Down
Loading