parent
7fdbe5113f
commit
d0df60cc1c
@ -0,0 +1,3 @@ |
||||
package org.openrs2.archive |
||||
|
||||
public data class ArchiveConfig(val databaseUrl: String) |
@ -0,0 +1,27 @@ |
||||
package org.openrs2.archive |
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper |
||||
import org.openrs2.yaml.Yaml |
||||
import java.nio.file.Files |
||||
import java.nio.file.Path |
||||
import javax.inject.Inject |
||||
import javax.inject.Provider |
||||
|
||||
public class ArchiveConfigProvider @Inject constructor( |
||||
@Yaml private val mapper: ObjectMapper |
||||
) : Provider<ArchiveConfig> { |
||||
override fun get(): ArchiveConfig { |
||||
if (Files.notExists(CONFIG_PATH)) { |
||||
Files.copy(EXAMPLE_CONFIG_PATH, CONFIG_PATH) |
||||
} |
||||
|
||||
return Files.newBufferedReader(CONFIG_PATH).use { reader -> |
||||
mapper.readValue(reader, ArchiveConfig::class.java) |
||||
} |
||||
} |
||||
|
||||
private companion object { |
||||
private val CONFIG_PATH = Path.of("etc/archive.yaml") |
||||
private val EXAMPLE_CONFIG_PATH = Path.of("etc/archive.example.yaml") |
||||
} |
||||
} |
@ -1,3 +1,4 @@ |
||||
/archive.yaml |
||||
/config.yaml |
||||
/game.key |
||||
/loader.p12 |
||||
|
@ -0,0 +1,2 @@ |
||||
--- |
||||
database_url: jdbc:postgresql://localhost/openrs2_archive?user=openrs2&password=openrs2 |
Loading…
Reference in new issue