aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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()
}