add match types to config

This commit is contained in:
kageru 2019-06-08 12:27:32 +02:00
parent effd106847
commit dd37444393
Signed by: kageru
GPG Key ID: 8282A2BEA4ADA3D2

View File

@ -17,13 +17,24 @@ class Config(val system: System, val commands: Commands) {
println("Config not found, falling back to defaults...")
File(this::class.java.classLoader.getResource(path)!!.toURI())
})
return rawConfig.to(Config::class.java)
val parsed = rawConfig.to(Config::class.java)
return Config(
System(parsed.system),
Commands(parsed.commands.commands.map { Command(it) })
)
}
}
}
data class System(val serverId: String, val admins: List<String>)
data class System(val serverId: String, val admins: List<String>) {
/**
* Self constructor to explicitly repeat the nullability checks after TOML parsing.
*/
constructor(system: System) : this(system.serverId, system.admins)
}
// wrapper for toml deserialization
/**
* Wrapper around [Command]s for TOML deserialization.
*/
data class Commands(val commands: List<Command>)