Refactor plugin config logic into Configurable

This commit is contained in:
grimsi
2025-05-15 16:34:50 +02:00
parent 4230bf31cc
commit 75a5d5997a
7 changed files with 40 additions and 38 deletions
@@ -0,0 +1,9 @@
package de.grimsi.gameyfin.pluginapi.core
interface Configurable {
val configMetadata: List<PluginConfigElement>
var config: Map<String, String?>
fun validateConfig(): Boolean = validateConfig(config)
fun validateConfig(config: Map<String, String?>): Boolean
}
@@ -10,23 +10,6 @@ abstract class GameyfinPlugin(wrapper: PluginWrapper) : Plugin(wrapper) {
val SUPPORTED_LOGO_FORMATS: List<String> = listOf("png", "jpg", "jpeg", "gif", "svg", "webp")
}
abstract val configMetadata: List<PluginConfigElement>
protected open var config: Map<String, String?> = emptyMap()
open fun getCurrentConfig(): Map<String, String?> {
return config
}
open fun loadConfig(config: Map<String, String?>) {
this.config = config
}
open fun validateConfig(): Boolean {
return validateConfig(config)
}
abstract fun validateConfig(config: Map<String, String?>): Boolean
fun hasLogo(): Boolean {
for (format in SUPPORTED_LOGO_FORMATS) {
val resourcePath = "$LOGO_FILE_NAME.$format"