Moved config
This commit is contained in:
parent
8516685a51
commit
d695f2820b
@ -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)
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -1,2 +0,0 @@
|
||||
apiURL: http://localhost/api/
|
||||
apiKey: abcd
|
@ -1,2 +0,0 @@
|
||||
apiURL: http://localhost:8044/api/graphql
|
||||
apiKey: 7b93e3b46bbfbdafc7b1e7a9d3fc05ebf68c0ead3093bda8802fa241081c7173
|
@ -1,2 +0,0 @@
|
||||
apiURL=https://kdb.keksdose-gaming.de/api/
|
||||
apiKey=abcd
|
@ -1,2 +0,0 @@
|
||||
apiURL: https://kdb-test.keksdose-gaming.de/api/
|
||||
apiKey: abcd
|
Loading…
Reference in New Issue
Block a user