aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-07-31 16:48:49 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-07-31 16:48:49 +0200
commit64f6c78b40f616e2f11264a8c7acaaa78248a385 (patch)
tree299590e81406ff294407a78ccf8df6b154638a27 /src/main
parent26138ee8c513627914bbc83a2510ced69ca017ff (diff)
downloadskyhanni-64f6c78b40f616e2f11264a8c7acaaa78248a385.tar.gz
skyhanni-64f6c78b40f616e2f11264a8c7acaaa78248a385.tar.bz2
skyhanni-64f6c78b40f616e2f11264a8c7acaaa78248a385.zip
Added repo switch user_api_keys
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/ApiDataLoader.kt16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/ApiDataLoader.kt b/src/main/java/at/hannibal2/skyhanni/data/ApiDataLoader.kt
index 54d86d1de..df8c511ee 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/ApiDataLoader.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/ApiDataLoader.kt
@@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.events.LorenzTickEvent
import at.hannibal2.skyhanni.events.ProfileApiDataLoadedEvent
import at.hannibal2.skyhanni.events.ProfileJoinEvent
+import at.hannibal2.skyhanni.events.RepositoryReloadEvent
import at.hannibal2.skyhanni.utils.APIUtil
import at.hannibal2.skyhanni.utils.LorenzUtils
import kotlinx.coroutines.Dispatchers
@@ -15,14 +16,26 @@ import java.io.File
import java.util.*
class ApiDataLoader {
-
private var currentProfileName = ""
private var currentProfileId = ""
+ private var usePlayerApiKey = false
+
+ @SubscribeEvent
+ fun onRepositoryReload(event: RepositoryReloadEvent) {
+ usePlayerApiKey = false
+ event.getConstant("DisabledFeatures")?.let {
+ if (it.asJsonObject["user_api_keys"]?.asBoolean ?: false) {
+ usePlayerApiKey = true
+ }
+ }
+ }
+
@SubscribeEvent
fun onTick(event: LorenzTickEvent) {
val thePlayer = Minecraft.getMinecraft().thePlayer ?: return
thePlayer.worldObj ?: return
+ if (!usePlayerApiKey) return
if (nextApiCallTime != -1L && System.currentTimeMillis() > nextApiCallTime) {
nextApiCallTime = System.currentTimeMillis() + 60_000 * 5
@@ -37,6 +50,7 @@ class ApiDataLoader {
@SubscribeEvent
fun onProfileJoin(event: ProfileJoinEvent) {
currentProfileName = event.name
+ if (!usePlayerApiKey) return
updateApiData()
}