Skip to content

Commit

Permalink
fixed toggle setting spamming api
Browse files Browse the repository at this point in the history
  • Loading branch information
catgirlseraid committed May 18, 2024
1 parent 920112d commit ea26a8b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,15 @@ import kotlinx.coroutines.launch
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import java.util.UUID
import kotlin.time.Duration.Companion.minutes
import kotlin.time.Duration.Companion.seconds

object FarmingCollectionDisplay {

private val config get() = SkyHanniMod.feature.garden.eliteFarmingCollection

private var checkDuration = 10.minutes
private var worldSwapRefresh = true
private var settingToggleCooldown = SimpleTimeMark.farPast()

@SubscribeEvent
fun onRepoReload(event: RepositoryReloadEvent) {
Expand Down Expand Up @@ -78,7 +80,6 @@ object FarmingCollectionDisplay {

private var display = emptyList<Renderable>()


@SubscribeEvent
fun onRenderOverlay(event: GuiRenderEvent) {
if (GardenAPI.hideExtraGuis()) return
Expand All @@ -98,7 +99,10 @@ object FarmingCollectionDisplay {
@SubscribeEvent
fun onConfigLoad(event: ConfigLoadEvent) {
config.crop.afterChange {
lastLeaderboardFetch = SimpleTimeMark.farPast()
if (settingToggleCooldown.passedSince() < 30.seconds) {
settingToggleCooldown = SimpleTimeMark.now()
lastLeaderboardFetch = SimpleTimeMark.farPast()
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ object SkillRankDisplay {

private var checkDuration = 10.minutes
private var worldSwapRefresh = true
private var settingToggleCooldown = SimpleTimeMark.farPast()

@SubscribeEvent
fun onRepoReload(event: RepositoryReloadEvent) {
Expand Down Expand Up @@ -86,7 +87,10 @@ object SkillRankDisplay {
@SubscribeEvent
fun onConfigLoad(event: ConfigLoadEvent) {
config.skill.afterChange {
lastLeaderboardFetch = SimpleTimeMark.farPast()
if (settingToggleCooldown.passedSince() < 30.seconds) {
settingToggleCooldown = SimpleTimeMark.now()
lastLeaderboardFetch = SimpleTimeMark.farPast()
}
}
}

Expand Down

0 comments on commit ea26a8b

Please sign in to comment.