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 readConstant(file: String): T { val data = getConstant(file) ?: ErrorManager.skyHanniError("$file failed to load from neu repo!") return try { ConfigManager.gson.fromJson(data) } catch (e: JsonSyntaxException) { ErrorManager.logErrorWithData( e, "$file failed to read from neu repo!", "data" to data ) throw e } } }