Skip to content

Commit

Permalink
Upped the check api time like in hannibal002#966 and stole the check …
Browse files Browse the repository at this point in the history
…code :)
  • Loading branch information
j10a1n15 committed Jan 30, 2024
1 parent 50e7ae2 commit 3938a4c
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/main/java/at/hannibal2/skyhanni/data/MayorAPI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -91,20 +91,20 @@ object MayorAPI {
}

private fun checkHypixelAPI() {
if (SimpleTimeMark.now() > lastUpdate.plus(5.minutes)) {
lastUpdate = SimpleTimeMark.now()
SkyHanniMod.coroutineScope.launch {
val url = "https://api.hypixel.net/v2/resources/skyblock/election"
val jsonObject = withContext(dispatcher) { APIUtil.getJSONResponse(url) }
rawMayorData = ConfigManager.gson.fromJson(jsonObject, MayorJson::class.java)
val data = rawMayorData ?: return@launch
val map = mutableMapOf<Int, MayorJson.Candidate>()
map put data.mayor.election.getPairs()
data.current?.let {
map put data.current.getPairs()
}
candidates = map
if (lastUpdate.passedSince() < 20.minutes) return
lastUpdate = SimpleTimeMark.now()

SkyHanniMod.coroutineScope.launch {
val url = "https://api.hypixel.net/v2/resources/skyblock/election"
val jsonObject = withContext(dispatcher) { APIUtil.getJSONResponse(url) }
rawMayorData = ConfigManager.gson.fromJson(jsonObject, MayorJson::class.java)
val data = rawMayorData ?: return@launch
val map = mutableMapOf<Int, MayorJson.Candidate>()
map put data.mayor.election.getPairs()
data.current?.let {
map put data.current.getPairs()
}
candidates = map
}

checkCurrentMayor()
Expand Down

0 comments on commit 3938a4c

Please sign in to comment.