XDG!
This commit is contained in:
parent
5ef0f2c9e3
commit
d1e55aeac7
2 changed files with 8 additions and 4 deletions
|
@ -42,6 +42,8 @@ dependencies {
|
||||||
|
|
||||||
implementation("com.akuleshov7:ktoml-core:0.5.0")
|
implementation("com.akuleshov7:ktoml-core:0.5.0")
|
||||||
implementation("com.akuleshov7:ktoml-file:0.5.0")
|
implementation("com.akuleshov7:ktoml-file:0.5.0")
|
||||||
|
|
||||||
|
implementation("dev.dirs:directories:26")
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks {
|
tasks {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package group.ouroboros.potrogue.data.config
|
package group.ouroboros.potrogue.data.config
|
||||||
|
|
||||||
|
import dev.dirs.ProjectDirectories
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.FileInputStream
|
import java.io.FileInputStream
|
||||||
import java.io.FileOutputStream
|
import java.io.FileOutputStream
|
||||||
|
@ -12,8 +13,9 @@ import java.util.*
|
||||||
|
|
||||||
val prop = Properties()
|
val prop = Properties()
|
||||||
class Config {
|
class Config {
|
||||||
val runDir = File("./run")
|
val confDir = ProjectDirectories.from("xyz", "limepot", "potrogue")
|
||||||
val confFile = File("./run/potrogue.conf")
|
val runDir = File(confDir.configDir)
|
||||||
|
val confFile = File(confDir.configDir + "/potrogue.conf")
|
||||||
private val prop = Properties()
|
private val prop = Properties()
|
||||||
private var runDirExists = runDir.exists()
|
private var runDirExists = runDir.exists()
|
||||||
init {
|
init {
|
||||||
|
@ -21,14 +23,14 @@ class Config {
|
||||||
//TODO: DataPacks and Advanced configuration system (see values.conf in jar)
|
//TODO: DataPacks and Advanced configuration system (see values.conf in jar)
|
||||||
//Files.createDirectories(Paths.get("./run/data"))
|
//Files.createDirectories(Paths.get("./run/data"))
|
||||||
if(!runDirExists){
|
if(!runDirExists){
|
||||||
Files.createDirectories(Paths.get("./run"))
|
Files.createDirectories(Paths.get(confDir.configDir))
|
||||||
}
|
}
|
||||||
if(confFile.exists()) {
|
if(confFile.exists()) {
|
||||||
FileInputStream(confFile).use { prop.load(it) }
|
FileInputStream(confFile).use { prop.load(it) }
|
||||||
}
|
}
|
||||||
//Otherwise create the necessary directories
|
//Otherwise create the necessary directories
|
||||||
else{
|
else{
|
||||||
Files.createFile(Path.of("./run/potrogue.conf"))
|
Files.createFile(Path.of(confDir.configDir + "/potrogue.conf"))
|
||||||
FileInputStream(confFile).use {
|
FileInputStream(confFile).use {
|
||||||
prop.load(it)
|
prop.load(it)
|
||||||
prop.setProperty("configVersion", "1")
|
prop.setProperty("configVersion", "1")
|
||||||
|
|
Loading…
Reference in a new issue