-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
5 changed files
with
46 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 38 additions & 15 deletions
53
project/module-common/src/main/kotlin/cn/fd/ratziel/common/config/Settings.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,47 @@ | ||
package cn.fd.ratziel.common.config | ||
|
||
import taboolib.common.platform.function.getDataFolder | ||
import taboolib.module.configuration.Config | ||
import taboolib.module.configuration.ConfigNode | ||
import taboolib.common.platform.function.releaseResourceFile | ||
import taboolib.common.util.asList | ||
import taboolib.module.configuration.Configuration | ||
|
||
object Settings { | ||
|
||
private const val FILE = "settings.yml" | ||
|
||
@Config(FILE) | ||
lateinit var conf: Configuration internal set | ||
|
||
@ConfigNode("Workspaces.listen", FILE) | ||
var listenFiles = true | ||
|
||
@ConfigNode("Workspaces.paths", FILE) | ||
var workspacePaths = listOf("${getDataFolder()}/workspace") | ||
|
||
@ConfigNode("Workspaces.filter", FILE) | ||
var fileFilter = "^(?![#!]).*\\.(?i)(yaml|yml|toml|tml|json|conf)\$" | ||
/** | ||
* 配置文件路径 | ||
*/ | ||
val file by lazy { releaseResourceFile(source = "settings.yml", target = "settings.yml") } | ||
|
||
/** | ||
* 配置文件 | ||
*/ | ||
lateinit var conf: Configuration | ||
internal set | ||
|
||
/** | ||
* 重载配置文件 | ||
*/ | ||
fun reloadConfig() { | ||
conf = Configuration.loadFromFile(file) | ||
} | ||
|
||
init { | ||
reloadConfig() | ||
} | ||
|
||
/** | ||
* 配置项 - 工作空间路径列表 | ||
*/ | ||
val workspacePaths get() = conf["Workspaces.paths"]?.asList() ?: listOf("${getDataFolder()}/workspace") | ||
|
||
/** | ||
* 配置项 - 工作空间文件过滤器 (正则表达式) | ||
*/ | ||
var fileFilter = conf["Workspaces.filter"]?.toString() ?: "^(?![#!]).*\\.(?i)(yaml|yml|toml|tml|json|conf)\$" | ||
|
||
/** | ||
* 配置项 - 是否启用文件监听 | ||
*/ | ||
val listenFiles get() = conf["Workspaces.listen"]?.toString()?.toBooleanStrictOrNull() ?: true | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters