Moved config #9

Merged
edraft merged 1 commits from #8 into 1.0 2023-02-14 08:06:42 +01:00
6 changed files with 17 additions and 15 deletions
Showing only changes of commit d695f2820b - Show all commits

View File

@ -14,9 +14,9 @@ open class OntimeHandlerPlugin() : JavaPlugin() {
override fun onEnable() {
this.config = Config(logger)
this.config.read("/config.properties", false)
this.config.read("/config.${this.config.environment}.properties", true)
this.config.read("/config.${this.config.hostName}.properties", true)
this.config.read("plugins/kd_ontime/config.properties", false)
this.config.read("plugins/kd_ontime/config.${this.config.environment}.properties", true)
this.config.read("plugins/kd_ontime/config.${this.config.hostName}.properties", true)
this.dataService = DataService(logger, this.config)

View File

@ -1,5 +1,6 @@
package de.sh_edraft.config
import java.io.File
import java.net.InetAddress
import java.net.UnknownHostException
import java.util.*
@ -40,12 +41,21 @@ class Config(private var logger: Logger) {
logger.config("Try to read config ${filename}")
var foundFile = false
try {
val file = this::class.java.getResourceAsStream(filename)
if (file == null && optional) {
logger.config("${filename} not found")
val file = File(filename);
if (!file.exists()) {
if (!optional) {
file.parentFile.mkdirs();
logger.config("${filename} not found")
file.writeText(
"""
apiURL: http://localhost/api/graphql
apiKey: abcd
""".trimIndent()
)
}
return
}
this.properties.load(file)
this.properties.load(file.reader())
logger.info("Found config ${filename}")
foundFile = true
} catch (e: Exception) {

View File

@ -1,2 +0,0 @@
apiURL: http://localhost/api/
apiKey: abcd

View File

@ -1,2 +0,0 @@
apiURL: http://localhost:8044/api/graphql
apiKey: 7b93e3b46bbfbdafc7b1e7a9d3fc05ebf68c0ead3093bda8802fa241081c7173

View File

@ -1,2 +0,0 @@
apiURL=https://kdb.keksdose-gaming.de/api/
apiKey=abcd

View File

@ -1,2 +0,0 @@
apiURL: https://kdb-test.keksdose-gaming.de/api/
apiKey: abcd