1
1
package me.regadpole.plumbot.config
2
2
3
- import taboolib.common.io.newFile
4
3
import taboolib.common.platform.function.getDataFolder
5
4
import taboolib.module.configuration.Configuration
6
5
import taboolib.module.configuration.util.getMap
@@ -13,61 +12,101 @@ class ConfigLoader(config: Configuration, commandsConfig: Configuration, returns
13
12
14
13
15
14
class Config (config : Configuration ){
16
- val ver = config.getString(" Ver " )
15
+ val version = config.getString(" version " )
17
16
val lang = config.getString(" lang" )
18
- val prefix = config.getString(" commandPrefix" )
19
- val forwarding = Forwarding (config)
20
- val dieReport = config.getBoolean(" dieReport" )
21
- val whiteList = WhiteList (config)
22
- val cmd = config.getBoolean(" cmd" )
23
- val joinAndLeave = config.getBoolean(" joinAndLeave" )
24
- val online = config.getBoolean(" online" )
25
- val tps = config.getBoolean(" tps" )
26
- val sdc = config.getBoolean(" SDC" )
27
- val sdr = config.getBoolean(" SDR" )
28
- val database = DataBase (config)
29
- val enableGroups = config.getStringList(" enableGroups" )
30
- val botAdmins = config.getStringList(" botAdmins" )
31
- val bot = Bot (config)
17
+ class Groups (config : Configuration ) {
18
+ val enableGroups = config.getStringList(" groups.enableGroups" )
19
+ val botAdmins = config.getStringList(" groups.botAdmins" )
20
+ val prefix = config.getString(" groups.commandPrefix" )
21
+ val forwarding = Forwarding (config)
22
+ class Forwarding (config : Configuration ) {
23
+ val message = Message (config)
24
+ class Message (config : Configuration ) {
25
+ val enable = config.getBoolean(" groups.forwarding.message.enable" )
26
+ val mode = config.getInt(" groups.forwarding.message.mode" )
27
+ val prefix = config.getString(" groups.forwarding.message.prefix" )
28
+ }
29
+ val dieMessage = config.getBoolean(" groups.forwarding.dieMessage" )
30
+ val whitelist = Whitelist (config)
31
+ class Whitelist (config : Configuration ) {
32
+ val enable = config.getBoolean(" groups.forwarding.whitelist.enable" )
33
+ val maxCount = config.getInt(" maxCount" )
34
+ }
35
+ val cmd = config.getBoolean(" groups.forwarding.cmd" )
36
+ val joinAndLeave = config.getBoolean(" gorups.forwarding.joinAndLeave" )
37
+ val online = config.getBoolean(" groups.forwarding.online" )
38
+ val tps = config.getBoolean(" groups.forwarding.tps" )
39
+ val sdc = config.getBoolean(" groups.forwarding.SDC" )
40
+ val sdr = config.getBoolean(" groups.forwarding.SDR" )
41
+ }
42
+ }
43
+ class DataBase (config : Configuration ) {
44
+ val type = config.getString(" database.type" )
45
+ val settings = Settings (config)
46
+ class Settings (config : Configuration ) {
47
+ val sqlite = SQLite (config)
48
+ val mysql = MySQL (config)
49
+ val pool = Pool (config)
50
+ class SQLite (config : Configuration ) {
51
+ val path = config.getString(" database.setting.sqlite.path" )?.replace(" %plugin_folder%" , getDataFolder().path)
52
+ }
53
+ class MySQL (config : Configuration ) {
54
+ val host = config.getHost(" database.settings.mysql.host" )
55
+ val port = config.getInt(" database.settings.mysql.port" )
56
+ val database = config.getString(" database.settings.mysql.database" )
57
+ val username = config.getString(" database.settings.mysql.username" )
58
+ val password = config.getString(" database.settings.mysql.password" )
59
+ val flagsURL = config.getString(" database.settings.mysql.flagsURL" )
60
+ }
61
+ class Pool (config : Configuration ) {
62
+ val connectionTimeout = config.getInt(" database.settings.pool.connectionTimeout" )
63
+ val idleTimeout = config.getInt(" database.settings.pool.idleTimeout" )
64
+ val maxLifetime = config.getInt(" database.settings.pool.maxLifetime" )
65
+ val maximumPoolSize = config.getInt(" database.settings.pool.maximumPoolSize" )
66
+ val keepaliveTime = config.getInt(" database.settings.pool.keepaliveTime" )
67
+ val minimumIdle = config.getInt(" database.settings.pool.minimumIdle" )
68
+ }
69
+ }
70
+ val enable = config.getBoolean(" enable" )
71
+ val host = config.getHost(" host" )
72
+ val port = config.getInt(" port" )
73
+ val database = config.getString(" database" )
74
+ val username = config.getString(" username" )
75
+ val password = config.getString(" password" )
76
+ val table = config.getString(" table" )
77
+ val columns = config.getMap<String , String >(" columns" )
78
+ val prefix = config.getString(" prefix" )
79
+ val suffix = config.getString(" suffix" )
80
+ }
32
81
class Bot (config : Configuration ){
33
82
val mode = config.getString(" bot.mode" )
34
- val gocqhttp = Gocqhttp (config)
83
+ val onebot = Onebot (config)
35
84
val kook = Kook (config)
36
- class Gocqhttp (config : Configuration ){
37
- val ws = config.getString(" bot.go-cqhttp.ws" )
38
- val token = config.getString(" bot.go-cqhttp.token" )
39
- val hasAccessToken = config.getBoolean(" bot.go-cqhttp.hasAccessToken" )
85
+ class Onebot (config : Configuration ){
86
+ val ws = config.getString(" bot.onebot.ws" )
87
+ val token = Token (config)
88
+ class Token (config : Configuration ) {
89
+ val enable = config.getBoolean(" bot.onebot.token.enable" )
90
+ val token = config.getString(" bot.onebot.token.token" )
91
+ }
40
92
}
41
93
class Kook (config : Configuration ) {
42
94
val token = config.getString(" bot.kook.token" )
43
95
}
44
96
}
45
- class Forwarding (config : Configuration ) {
46
- val enable = config.getBoolean(" forwarding.enable" )
47
- val mode = config.getInt(" forwarding.mode" )
48
- val prefix = config.getString(" forwarding.prefix" )
49
- }
50
- class WhiteList (config : Configuration ) {
51
- val enable = config.getBoolean(" whiteList.enable" )
52
- val maxCount = config.getInt(" whitelist.maxCount" )
53
- }
54
- class DataBase (config : Configuration ) {
55
- val type = config.getString(" database.type" )
56
- private val sqlitePath =
57
- config.getString(" database.setting.sqlite.path" )?.replace(" %plugin_folder%" , getDataFolder().path)
58
- val sqliteHost = newFile(sqlitePath!! , create = true , folder = false ).getHost()
59
- val host = config.getHost(" database.settings.mysql" )
60
- }
97
+ val groups = Groups (config)
98
+ val database = DataBase (config)
99
+ val bot = Bot (config)
61
100
}
62
101
63
102
class Commands (config : Configuration ) {
64
- val ver = config.getString(" ver " )
103
+ val version = config.getString(" version " )
65
104
val adminCommand = config.getMap<String , String >(" admin" )
66
105
val userCommand = config.getMap<String , String >(" user" )
67
106
}
68
107
69
108
class Returns (config : Configuration ) {
70
- val ver = config.getString(" ver " )
109
+ val version = config.getString(" version " )
71
110
val adminReturn = config.getMap<String , String >(" admin" )
72
111
val userReturn = config.getMap<String , String >(" user" )
73
112
}
0 commit comments