diff options
author | CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> | 2023-06-22 23:29:04 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-22 23:29:04 +1000 |
commit | 72aad9e2b79fbe3ffdb4a0dc950ed5aebdf5166f (patch) | |
tree | 59c57d34ea16df02bd07c37d9aa4e54b0749133f /src/main/java/at/hannibal2/skyhanni/data | |
parent | a9fdc5c1cced1faa54c04cad93fe35249583fe89 (diff) | |
parent | b3e289dbec40cdd0632bac41f510d94af545983c (diff) | |
download | skyhanni-72aad9e2b79fbe3ffdb4a0dc950ed5aebdf5166f.tar.gz skyhanni-72aad9e2b79fbe3ffdb4a0dc950ed5aebdf5166f.tar.bz2 skyhanni-72aad9e2b79fbe3ffdb4a0dc950ed5aebdf5166f.zip |
Merge branch 'beta' into frozen_treasure_tracker
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/data')
5 files changed, 12 insertions, 23 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/EntityMovementData.kt b/src/main/java/at/hannibal2/skyhanni/data/EntityMovementData.kt index 30f88f48e..b5a2d2b92 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/EntityMovementData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/EntityMovementData.kt @@ -21,8 +21,6 @@ class EntityMovementData { } } - var tick = 0 - @SubscribeEvent fun onTick(event: TickEvent.ClientTickEvent) { if (!LorenzUtils.inSkyBlock) return diff --git a/src/main/java/at/hannibal2/skyhanni/data/IslandType.kt b/src/main/java/at/hannibal2/skyhanni/data/IslandType.kt index 7935bf985..91f2bed9a 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/IslandType.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/IslandType.kt @@ -19,6 +19,7 @@ enum class IslandType(val displayName: String, val apiName: String = "null") { GARDEN_GUEST("Garden Guest"), SPIDER_DEN("Spider's Den"), WINTER("Jerry's Workshop"), //todo confirm + THE_RIFT("The Rift"), NONE(""), UNKNOWN("???"), diff --git a/src/main/java/at/hannibal2/skyhanni/data/MayorElection.kt b/src/main/java/at/hannibal2/skyhanni/data/MayorElection.kt index ddd208db1..7c4cfd7c1 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/MayorElection.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/MayorElection.kt @@ -1,11 +1,10 @@ package at.hannibal2.skyhanni.data import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.config.ConfigManager import at.hannibal2.skyhanni.utils.APIUtil import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.jsonobjects.MayorJson -import com.google.gson.GsonBuilder -import io.github.moulberry.moulconfig.observer.PropertyTypeAdapterFactory import io.github.moulberry.notenoughupdates.util.SkyBlockTime import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch @@ -17,10 +16,6 @@ class MayorElection { private var tick = 0 private var lastUpdate = 0L - private val gson = GsonBuilder().setPrettyPrinting() - .registerTypeAdapterFactory(PropertyTypeAdapterFactory()) - .create() - companion object { var rawMayorData: MayorJson? = null var candidates = mapOf<Int, MayorJson.Candidate>() @@ -52,7 +47,7 @@ class MayorElection { SkyHanniMod.coroutineScope.launch { val url = "https://api.hypixel.net/resources/skyblock/election" val jsonObject = withContext(Dispatchers.IO) { APIUtil.getJSONResponse(url) } - rawMayorData = gson.fromJson(jsonObject, MayorJson::class.java) + 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() diff --git a/src/main/java/at/hannibal2/skyhanni/data/repo/RepoManager.kt b/src/main/java/at/hannibal2/skyhanni/data/repo/RepoManager.kt index 2dc65f358..e1d6aa933 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/repo/RepoManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/repo/RepoManager.kt @@ -1,10 +1,9 @@ package at.hannibal2.skyhanni.data.repo import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.config.ConfigManager import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.utils.LorenzUtils -import com.google.gson.Gson -import com.google.gson.GsonBuilder import com.google.gson.JsonObject import net.minecraft.client.Minecraft import org.apache.commons.io.FileUtils @@ -15,7 +14,7 @@ import java.util.concurrent.CompletableFuture import java.util.concurrent.atomic.AtomicBoolean class RepoManager(private val configLocation: File) { - val gson: Gson = GsonBuilder().setPrettyPrinting().create() + private val gson get() = ConfigManager.gson private var latestRepoCommit: String? = null private val repoLocation: File = File(configLocation, "repo") diff --git a/src/main/java/at/hannibal2/skyhanni/data/repo/RepoUtils.kt b/src/main/java/at/hannibal2/skyhanni/data/repo/RepoUtils.kt index 3e67adcac..9719c70ff 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/repo/RepoUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/repo/RepoUtils.kt @@ -79,17 +79,13 @@ object RepoUtils { fun <T> getConstant(repo: File, constant: String, gson: Gson, clazz: Class<T>?): T? { if (repo.exists()) { val jsonFile = File(repo, "constants/$constant.json") - try { - BufferedReader( - InputStreamReader( - FileInputStream(jsonFile), - StandardCharsets.UTF_8 - ) - ).use { reader -> - return gson.fromJson(reader, clazz) - } - } catch (e: Exception) { - return null + BufferedReader( + InputStreamReader( + FileInputStream(jsonFile), + StandardCharsets.UTF_8 + ) + ).use { reader -> + return gson.fromJson(reader, clazz) } } return null |