diff options
author | hannibal2 <24389977+hannibal002@users.noreply.github.com> | 2024-09-12 02:33:44 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-12 02:33:44 +0200 |
commit | e350ade0d86955ce1a865f4286cd208d54693777 (patch) | |
tree | 9fcfaaf1a15a55b85a55df58d83b1c0c9e66b885 /src/main/java/at/hannibal2/skyhanni/events | |
parent | b2d1c22d4baebc6eaf9eef823b11fa9d1801ced1 (diff) | |
download | skyhanni-e350ade0d86955ce1a865f4286cd208d54693777.tar.gz skyhanni-e350ade0d86955ce1a865f4286cd208d54693777.tar.bz2 skyhanni-e350ade0d86955ce1a865f4286cd208d54693777.zip |
Improvement: Stars in Estimated Item Value (#2492)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/events')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/events/NeuRepositoryReloadEvent.kt | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/events/NeuRepositoryReloadEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/NeuRepositoryReloadEvent.kt index 6f7df5964..c2bd261ca 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/NeuRepositoryReloadEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/NeuRepositoryReloadEvent.kt @@ -1,6 +1,9 @@ + package at.hannibal2.skyhanni.events import at.hannibal2.skyhanni.config.ConfigManager +import at.hannibal2.skyhanni.data.repo.RepoError +import at.hannibal2.skyhanni.data.repo.RepoUtils import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.NEUItems.manager import at.hannibal2.skyhanni.utils.json.fromJson @@ -8,6 +11,7 @@ import com.google.gson.Gson import com.google.gson.JsonObject import com.google.gson.JsonSyntaxException import java.io.File +import java.lang.reflect.Type class NeuRepositoryReloadEvent : LorenzEvent() { fun getConstant(file: String): JsonObject? { @@ -26,4 +30,11 @@ class NeuRepositoryReloadEvent : LorenzEvent() { throw e } } + + inline fun <reified T : Any> getConstant(constant: String, type: Type? = null, gson: Gson = ConfigManager.gson): T = try { + if (!manager.repoLocation.exists()) throw RepoError("NEU-Repo folder does not exist!") + RepoUtils.getConstant(manager.repoLocation, constant, gson, T::class.java, type) + } catch (e: Exception) { + throw RepoError("Repo parsing error while trying to read constant '$constant'", e) + } } |