package codes.som.hibiscus.api.feature import codes.som.hibiscus.Hibiscus import codes.som.hibiscus.api.command.Command import codes.som.hibiscus.api.event.* import codes.som.hibiscus.api.feature.values.ValueRegistry abstract class Feature(val name: String, val category: FeatureCategory) { private val listeners = mutableListOf>() protected inline fun on(listener: Listener) = on(object : TypedListener(T::class.java), Listener by listener {}) protected fun on(listener: TypedListener) = listeners.add(listener) val values = ValueRegistry() var enabled: Boolean = false set(value) { val hasChanged = value != field if (hasChanged) { field = value if (value) { onEnable() listeners.forEach { Hibiscus.bus.registerTyped(it) } } else { listeners.forEach { Hibiscus.bus.unregisterTyped(it) } onDisable() } } } var hiddenInOverlay = false open fun onEnable() {} open fun onDisable() {} open fun createFeatureCommand(): Command { return FeatureCommand(this) } // TODO: Module commands }