2
2
3
3
import me .dreamvoid .miraimc .api .MiraiBot ;
4
4
import me .dreamvoid .miraimc .internal .*;
5
+ import me .dreamvoid .miraimc .internal .config .PluginConfig ;
5
6
import me .dreamvoid .miraimc .internal .database .DatabaseHandler ;
6
7
import me .dreamvoid .miraimc .internal .database .MySQL ;
7
8
import me .dreamvoid .miraimc .internal .database .SQLite ;
@@ -60,29 +61,29 @@ public void preLoad() throws IOException, ParserConfigurationException, SAXExcep
60
61
61
62
// 加载配置
62
63
logger .info ("Loading config." );
63
- platform . getPluginConfig (). loadConfig ();
64
- if (platform .getPluginVersion ().contains ("dev-" ) && MiraiMCConfig .General .MiraiCoreVersion .equalsIgnoreCase ("stable" )) {
65
- MiraiMCConfig .General .MiraiCoreVersion = "latest" ; // Fix dev version
64
+ PluginConfig . reloadConfig ();
65
+ if (platform .getPluginVersion ().contains ("dev-" ) && PluginConfig .General .MiraiCoreVersion .equalsIgnoreCase ("stable" )) {
66
+ PluginConfig .General .MiraiCoreVersion = "latest" ; // Fix dev version
66
67
}
67
68
68
- logger .info ("Mirai working dir: " + MiraiMCConfig .General .MiraiWorkingDir );
69
+ logger .info ("Mirai working dir: " + PluginConfig .General .MiraiWorkingDir );
69
70
70
71
// 加载 mirai 核心
71
72
if (System .getProperty ("MiraiMC.do-not-load-mirai-core" ) == null ){
72
- logger .info ("Selected mirai core version: " + MiraiMCConfig .General .MiraiCoreVersion );
73
- if (MiraiMCConfig .General .MiraiCoreVersion .equalsIgnoreCase ("latest" )) {
73
+ logger .info ("Selected mirai core version: " + PluginConfig .General .MiraiCoreVersion );
74
+ if (PluginConfig .General .MiraiCoreVersion .equalsIgnoreCase ("latest" )) {
74
75
MiraiLoader .loadMiraiCore ();
75
- } else if (MiraiMCConfig .General .MiraiCoreVersion .equalsIgnoreCase ("stable" )) {
76
+ } else if (PluginConfig .General .MiraiCoreVersion .equalsIgnoreCase ("stable" )) {
76
77
MiraiLoader .loadMiraiCore (MiraiLoader .getStableVersion (getPlatform ().getPluginVersion ()));
77
78
} else {
78
- MiraiLoader .loadMiraiCore (MiraiMCConfig .General .MiraiCoreVersion );
79
+ MiraiLoader .loadMiraiCore (PluginConfig .General .MiraiCoreVersion );
79
80
}
80
81
} else {
81
82
logger .info ("MiraiMC will not load mirai core, please ensure you have custom mirai core loaded." );
82
83
}
83
84
84
85
// 加载 EncryptService
85
- if (MiraiMCConfig .Bot .RegisterEncryptService ){
86
+ if (PluginConfig .Bot .RegisterEncryptService ){
86
87
logger .info ("Registering Mirai Encrypt Service." );
87
88
try {
88
89
MiraiEncryptServiceFactory .install ();
@@ -94,14 +95,14 @@ public void preLoad() throws IOException, ParserConfigurationException, SAXExcep
94
95
}
95
96
96
97
// 加载来自 cssxsh 的 fix-protocol-version
97
- if (MiraiMCConfig .Bot .UpdateProtocolVersion ){
98
+ if (PluginConfig .Bot .UpdateProtocolVersion ){
98
99
logger .info ("Updating mirai protocol version. (Author: cssxsh)" );
99
100
100
101
logger .info ("协议版本检查更新..." );
101
102
try {
102
103
FixProtocolVersion .update ();
103
104
for (BotConfiguration .MiraiProtocol protocol : BotConfiguration .MiraiProtocol .values ()) {
104
- File file = new File (new File (MiraiMCConfig .PluginDir , "protocol" ), protocol .name ().toLowerCase () + ".json" );
105
+ File file = new File (new File (PluginConfig .PluginDir , "protocol" ), protocol .name ().toLowerCase () + ".json" );
105
106
if (file .exists ()) {
106
107
logger .info (protocol + " load from " + file .toPath ().toUri ());
107
108
FixProtocolVersion .load (protocol );
@@ -127,7 +128,7 @@ public void postLoad() {
127
128
128
129
// 数据库
129
130
try {
130
- switch (MiraiMCConfig .Database .Type .toLowerCase ()){
131
+ switch (PluginConfig .Database .Type .toLowerCase ()){
131
132
case "sqlite" :
132
133
default : {
133
134
logger .info ("Initializing SQLite database." );
@@ -155,7 +156,7 @@ public void postLoad() {
155
156
platform .getAutoLogin ().doStartUpAutoLogin ();
156
157
157
158
// 安全警告
158
- if (!(MiraiMCConfig .General .DisableSafeWarningMessage )){
159
+ if (!(PluginConfig .General .DisableSafeWarningMessage )){
159
160
logger .warning ("确保您正在使用开源的 MiraiMC 插件,未知来源的插件可能会盗取您的账号!" );
160
161
logger .warning ("请始终从 GitHub 或作者指定的其他途径下载插件: https://github.com/DreamVoid/MiraiMC" );
161
162
}
@@ -164,7 +165,7 @@ public void postLoad() {
164
165
platform .runTaskLaterAsync (() -> {
165
166
try {
166
167
List <String > announcement = Info .init ().announcement ;
167
- if (announcement != null && announcement .size () != 0 ){
168
+ if (announcement != null && ! announcement .isEmpty () ){
168
169
logger .info ("========== [ MiraiMC 公告版 ] ==========" );
169
170
announcement .forEach (logger ::info );
170
171
logger .info ("=======================================" );
@@ -173,7 +174,7 @@ public void postLoad() {
173
174
}, 40 );
174
175
175
176
// 检查更新
176
- if (MiraiMCConfig .General .CheckUpdate && !platform .getPluginVersion ().contains ("dev" )){
177
+ if (PluginConfig .General .CheckUpdate && !platform .getPluginVersion ().contains ("dev" )){
177
178
platform .runTaskAsync (() -> {
178
179
logger .info ("正在检查更新..." );
179
180
try {
0 commit comments