Open-source multiplayer game server compatible with the RuneScape client https://www.openrs2.org/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
openrs2/conf/src/main/java/dev/openrs2/conf/ConfigProvider.kt

24 lines
752 B

package dev.openrs2.conf
import com.fasterxml.jackson.databind.ObjectMapper
import java.nio.file.Files
import java.nio.file.Paths
import javax.inject.Inject
import javax.inject.Provider
class ConfigProvider @Inject constructor(private val mapper: ObjectMapper) : Provider<Config> {
override fun get(): Config {
if (Files.notExists(CONFIG_PATH)) {
Files.copy(EXAMPLE_CONFIG_PATH, CONFIG_PATH)
}
return Files.newBufferedReader(CONFIG_PATH).use { reader ->
mapper.readValue(reader, Config::class.java)
}
}
private companion object {
private val CONFIG_PATH = Paths.get("etc/config.yaml")
private val EXAMPLE_CONFIG_PATH = Paths.get("etc/config.example.yaml")
}
}