blob: bb741ae808d68e045b9985c2654a706acbc73920 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
package at.hannibal2.skyhanni.events
import at.hannibal2.skyhanni.config.ConfigManager
import at.hannibal2.skyhanni.test.command.ErrorManager
import at.hannibal2.skyhanni.utils.NEUItems.manager
import at.hannibal2.skyhanni.utils.fromJson
import com.google.gson.JsonObject
import com.google.gson.JsonSyntaxException
import java.io.File
class NeuRepositoryReloadEvent : LorenzEvent() {
fun getConstant(file: String): JsonObject? {
return manager.getJsonFromFile(File(manager.repoLocation, "constants/$file.json"))
}
inline fun <reified T : Any> readConstant(file: String): T {
val data = getConstant(file) ?: ErrorManager.skyHanniError("$file failed to load from neu repo!")
return try {
ConfigManager.gson.fromJson<T>(data)
} catch (e: JsonSyntaxException) {
ErrorManager.logErrorWithData(
e, "$file failed to read from neu repo!",
"data" to data
)
throw e
}
}
}
|