package fr.username404.snowygui import com.google.gson.Gson import com.google.gson.GsonBuilder import fr.username404.snowygui.EventSnowy.Companion.useKey import fr.username404.snowygui.config.Configuration.obtained import fr.username404.snowygui.gui.feature.Ignored import fr.username404.snowygui.misc.AddKeyMaps import io.github.config4k.getValue import org.apache.logging.log4j.LogManager import org.apache.logging.log4j.Logger import kotlin.reflect.full.hasAnnotation abstract class Snowy { protected fun Class<*>.isValidForButtonCollection(): Boolean = (!(kotlin.isAbstract || kotlin.hasAnnotation())) private val displayInitMessage: Boolean by obtained companion object { val Gson: Gson = GsonBuilder().excludeFieldsWithoutExposeAnnotation().create() @JvmStatic protected val FeaturePackage: String = "fr.username404.snowygui.gui.feature" lateinit var annotatedButtons: Set> fun onEvent(e: String, lambda: argsLambda) = useKey(e).add(lambda) @JvmField val logs: Logger = LogManager.getLogger() } private fun eventsInit() { onEvent("EndTick") { for (Key in AddKeyMaps.list.keys) { if (Key.isDown) { AddKeyMaps.list[Key]?.invoke() } } } } fun atInit() { if (displayInitMessage) logs.info("Init point of SnowyGUI hit.") eventsInit() } }