Skip to content

Commit 20c0bae

Browse files
committed
v2.4.3 错误修复和自述文件更新
1 parent eae2362 commit 20c0bae

5 files changed

Lines changed: 57 additions & 52 deletions

File tree

README.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ enablePreviousUpdate: true
8484

8585
# 文件完整性检查, 只对 .jar / .zip 等文件有效. 尝试以压缩包的形式打开, 若失败则表示不完整
8686
zipFileCheck: true
87+
# 如果 file 配置与此正则匹配, 则启用 zip 完整性检查, 否则不会启用
88+
zipFileCheckList: '\.(?:jar|zip)$'
8789

8890
# 如果下载后的文件哈希与更新目录中待更新的文件 (或者服务器正在运行的文件) 哈希值一致则不移动到更新目录 (MD5
8991
ignoreDuplicates: true
@@ -98,11 +100,11 @@ setRequestProperty:
98100

99101
# 启用哪些日志等级
100102
logLevel:
101-
- "DEBUG" # 用于调试, 可在测试完成后注释掉
102-
- "MARK" # 与 DEBUG 相同, 显示绿色, 用于标记任务完成
103-
- "INFO" # 输出日志
104-
- "WARN" # 输出警告
105-
- "NET_WARN" # 网络请求模块的警告
103+
- 'DEBUG' # 用于调试, 可在测试完成后注释掉
104+
- 'MARK' # 与 DEBUG 相同, 显示绿色, 用于标记任务完成
105+
- 'INFO' # 输出日志
106+
- 'WARN' # 输出警告
107+
- 'NET_WARN' # 网络请求模块的警告
106108

107109

108110
# 插件列表
@@ -149,10 +151,9 @@ list:
149151
# url: https://builds.guizhanss.com/SlimefunGuguProject/FluffyMachines/master
150152

151153
# # 可以像这样为每个文件添加配置
152-
# - file: 'serverConfig.yml'
154+
# # 如果 file 配置中包含路径, 则自动设置 path 参数
155+
# - file: './serverConfig.yml'
153156
# url: 'http://[::]:5212/serverConfig.yml'
154-
# path: './' # 设置单独的安装目录, path 会同时设置哈希检查的位置 (filePath)
155-
# zipFileCheck: false # 关闭完整性检查
156157

157158

158159
### list 中的所有可用配置 ###
@@ -165,7 +166,7 @@ list:
165166
# String path; // 同时覆盖 updatePath 和 filePath 配置
166167
# String get; // 选择指定文件的正则表达式, 默认选择第一个. 仅限 GitHub, Jenkins, Modrinth
167168
# boolean getPreRelease; // 允许下载预发布版本, 默认 false. 仅限 GitHub
168-
# boolean zipFileCheck; // 启用 zip 文件完整性检查, 默认 true
169+
# boolean zipFileCheck; // 启用 zip 文件完整性检查
169170
# boolean ignoreDuplicates; // 关闭哈希检查
170171

171172
```

README_EN.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ enablePreviousUpdate: true
8282

8383
# File integrity check, only works on .jar / .zip files. Try to open it as a zip file, if it fails, it is incomplete.
8484
zipFileCheck: true
85+
# If the file configuration matches this regex, zip integrity checking is enabled, otherwise it is not enabled
86+
zipFileCheckList: '\.(?:jar|zip)$'
8587

8688
# Do not move to the update directory if the hash of the downloaded file matches the hash of the file to be updated in the update directory (or the file running on the server) (MD5)
8789
ignoreDuplicates: true
@@ -96,11 +98,11 @@ setRequestProperty:
9698

9799
# 启用哪些日志等级
98100
logLevel:
99-
- "DEBUG" # for debugging, can be commented out after testing is complete
100-
- "MARK" # Same as DEBUG, green color, used to mark task completion.
101-
- "INFO" # Output logs
102-
- "WARN" # Output warnings
103-
- "NET_WARN" # Warnings from the web request module
101+
- 'DEBUG' # for debugging, can be commented out after testing is complete
102+
- 'MARK' # Same as DEBUG, green color, used to mark task completion.
103+
- 'INFO' # Output logs
104+
- 'WARN' # Output warnings
105+
- 'NET_WARN' # Warnings from the web request module
104106

105107

106108
# Plugin List
@@ -146,11 +148,10 @@ list:
146148
# - file: 'SF4_FluffyMachines.jar'
147149
# url: https://builds.guizhanss.com/SlimefunGuguProject/FluffyMachines/master
148150

149-
# # Too many requests
150-
# - file: 'serverConfig.yml'
151+
# # Configuration can be added to each file like this
152+
# # If the file configuration contains a path, the path parameter is automatically set.
153+
# - file: './serverConfig.yml'
151154
# url: 'http://[::]:5212/serverConfig.yml'
152-
# path: './' # Too many requests
153-
# zipFileCheck: false # Too many requests
154155

155156

156157
### All available configurations in list ###
@@ -163,7 +164,7 @@ list:
163164
# String path; // Overriding both updatePath and filePath configurations
164165
# String get; // Regular expression to select the specified file, first one is selected by default. GitHub, Jenkins, Modrinth only.
165166
# boolean getPreRelease; // Allow downloading of pre-releases, false by default. GitHub only.
166-
# boolean zipFileCheck; // Enable zip file integrity checking, true by default.
167+
# boolean zipFileCheck; // Enable zip file integrity checking
167168
# boolean ignoreDuplicates; // Turn off hash checking
168169

169170
```

README_MCBBS.md.txt

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,6 @@ https://github.com/ApliNi/AutoUpdatePlugins
88

99
[[中文文档]](https://github.com/ApliNi/AutoUpdatePlugins/blob/main/README.md) -- [[English document]](https://github.com/ApliNi/AutoUpdatePlugins/blob/main/README_EN.md)
1010

11-
下载: https://modrinth.com/plugin/AutoUpdatePlugins
12-
13-
---
14-
15-
## AutoUpdatePlugins
16-
17-
[[中文文档]](https://github.com/ApliNi/AutoUpdatePlugins/blob/main/README.md) -- [[English document]](https://github.com/ApliNi/AutoUpdatePlugins/blob/main/README_EN.md)
18-
1911
更好的自动更新插件
2012

2113
下载: https://modrinth.com/plugin/AutoUpdatePlugins
@@ -98,6 +90,8 @@ enablePreviousUpdate: true
9890

9991
# 文件完整性检查, 只对 .jar / .zip 等文件有效. 尝试以压缩包的形式打开, 若失败则表示不完整
10092
zipFileCheck: true
93+
# 如果 file 配置与此正则匹配, 则启用 zip 完整性检查, 否则不会启用
94+
zipFileCheckList: '\.(?:jar|zip)$'
10195

10296
# 如果下载后的文件哈希与更新目录中待更新的文件 (或者服务器正在运行的文件) 哈希值一致则不移动到更新目录 (MD5
10397
ignoreDuplicates: true
@@ -112,11 +106,11 @@ setRequestProperty:
112106

113107
# 启用哪些日志等级
114108
logLevel:
115-
- "DEBUG" # 用于调试, 可在测试完成后注释掉
116-
- "MARK" # 与 DEBUG 相同, 显示绿色, 用于标记任务完成
117-
- "INFO" # 输出日志
118-
- "WARN" # 输出警告
119-
- "NET_WARN" # 网络请求模块的警告
109+
- 'DEBUG' # 用于调试, 可在测试完成后注释掉
110+
- 'MARK' # 与 DEBUG 相同, 显示绿色, 用于标记任务完成
111+
- 'INFO' # 输出日志
112+
- 'WARN' # 输出警告
113+
- 'NET_WARN' # 网络请求模块的警告
120114

121115

122116
# 插件列表
@@ -163,10 +157,9 @@ list:
163157
# url: https://builds.guizhanss.com/SlimefunGuguProject/FluffyMachines/master
164158

165159
# # 可以像这样为每个文件添加配置
166-
# - file: 'serverConfig.yml'
160+
# # 如果 file 配置中包含路径, 则自动设置 path 参数
161+
# - file: './serverConfig.yml'
167162
# url: 'http://[::]:5212/serverConfig.yml'
168-
# path: './' # 设置单独的安装目录, path 会同时设置哈希检查的位置 (filePath)
169-
# zipFileCheck: false # 关闭完整性检查
170163

171164

172165
### list 中的所有可用配置 ###
@@ -179,7 +172,7 @@ list:
179172
# String path; // 同时覆盖 updatePath 和 filePath 配置
180173
# String get; // 选择指定文件的正则表达式, 默认选择第一个. 仅限 GitHub, Jenkins, Modrinth
181174
# boolean getPreRelease; // 允许下载预发布版本, 默认 false. 仅限 GitHub
182-
# boolean zipFileCheck; // 启用 zip 文件完整性检查, 默认 true
175+
# boolean zipFileCheck; // 启用 zip 文件完整性检查
183176
# boolean ignoreDuplicates; // 关闭哈希检查
184177

185178
```

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>io.github.aplini</groupId>
88
<artifactId>AutoUpdatePlugins</artifactId>
9-
<version>2.4.2</version>
9+
<version>2.4.3</version>
1010
<packaging>jar</packaging>
1111

1212
<name>AutoUpdatePlugins</name>

src/main/java/io/github/aplini/autoupdateplugins/AutoUpdatePlugins.java

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ else if(args[0].equals("stop")){
246246

247247

248248
private class updatePlugins extends TimerTask {
249-
String _nowFile = "[???] "; // 当前文件的名称
249+
String _fileName = "[???] "; // 当前文件的名称
250250
String _nowParser = "[???] "; // 用于解析直链的解析器名称
251251
int _fail = 0; // 更新失败数量
252252
int _success = 0; // 更新成功数量
@@ -299,6 +299,9 @@ public void run() {
299299
lastSender.sendMessage("[AUP] "+ m.logReloadOK);
300300
}
301301
}
302+
303+
_fileName = "[???] ";
304+
_nowParser = "[???] ";
302305
lock = false;
303306
});
304307
}
@@ -345,36 +348,46 @@ public void runUpdate() {
345348
continue;
346349
}
347350

348-
_nowFile = "["+ c_file +"] "; // 用于显示日志的插件名称
349-
c_tempPath = getPath(getConfig().getString("tempPath", "./plugins/AutoUpdatePlugins/temp/")) + c_file;
350-
351-
// 每个单独的配置
351+
// 获取用于显示日志的插件名称
352+
Matcher tempMatcher = Pattern.compile("([^/\\\\]+)\\..*$").matcher(c_file);
353+
if(tempMatcher.find()){
354+
_fileName = "["+ tempMatcher.group(1) +"] ";
355+
}else{
356+
_fileName = "["+ c_file +"] ";
357+
}
352358

353359
// 如果 file 配置中包含路径, 则自动提取并设置 path 参数
354-
if(c_file.contains("/") || c_file.contains("\\")){ // windows 下的反斜杠路径
360+
tempMatcher = Pattern.compile("(.*/|.*\\\\)([^/\\\\]+)$").matcher(c_file);
361+
if(tempMatcher.find()){ // windows 下的反斜杠路径
362+
getPath(tempMatcher.group(1));
355363
c_updatePath = c_file;
356364
c_filePath = c_file;
365+
c_tempPath = getPath(getConfig().getString("tempPath", "./plugins/AutoUpdatePlugins/temp/")) + tempMatcher.group(2);
357366
}
358367
// path 参数将同时设置 c_updatePath 和 c_filePath
359368
else if(li.get("path") != null){
360369
c_updatePath = getPath((String) li.get("path")) + c_file;
361370
c_filePath = c_updatePath;
371+
c_tempPath = getPath(getConfig().getString("tempPath", "./plugins/AutoUpdatePlugins/temp/")) + c_file;
362372
}
363373
// 使用全局配置
364374
else{
365375
c_updatePath = getPath((String) SEL(li.get("updatePath"), getConfig().getString("updatePath", "./plugins/update/"))) + c_file;
366376
c_filePath = getPath((String) SEL(li.get("filePath"), getConfig().getString("filePath", "./plugins/"))) + c_file;
377+
c_tempPath = getPath(getConfig().getString("tempPath", "./plugins/AutoUpdatePlugins/temp/")) + c_file;
367378
}
368379

369380
c_get = (String) SEL(li.get("get"), "");
370381
c_zipFileCheck = (boolean) SEL(li.get("zipFileCheck"), getConfig().getBoolean("zipFileCheck", true));
371382
c_getPreRelease = (boolean) SEL(li.get("getPreRelease"), false);
372383

373-
// 下载文件到缓存目录
384+
// "[xx] 正在检查更新..."
374385
log(logLevel.DEBUG, m.updateChecking);
386+
387+
// 下载文件到缓存目录
375388
String dUrl = getFileUrl(c_url, c_get);
376389
if(dUrl == null){
377-
log(logLevel.WARN, _nowFile + _nowParser + m.updateErrParsingDUrl);
390+
log(logLevel.WARN, _fileName + _nowParser + m.updateErrParsingDUrl);
378391
continue;
379392
}
380393
dUrl = checkURL(dUrl);
@@ -456,11 +469,8 @@ else if(li.get("path") != null){
456469
log(logLevel.DEBUG, m.piece(m.updateFulSizeDifference, String.format("%.2f", oldFileSize / 1048576), String.format("%.2f", fileSize / 1048576)));
457470
_success ++;
458471

459-
_nowFile = "[???] ";
460-
_nowParser = "[???] ";
461472
_fail --;
462473
}
463-
464474
saveDate();
465475
}
466476

@@ -760,24 +770,24 @@ public void log(logLevel level, String text){
760770
if(userLogLevel.contains(level.name)){
761771
switch(level.name){
762772
case "DEBUG":
763-
getLogger().info(_nowFile + text);
773+
getLogger().info(_fileName + text);
764774
break;
765775
case "INFO":
766776
getLogger().info(text);
767777
break;
768778
case "MARK":
769779
// 一些新版本的控制台似乎很难显示颜色
770-
Bukkit.getConsoleSender().sendMessage(level.color +"[AUP] "+ _nowFile + text);
780+
Bukkit.getConsoleSender().sendMessage(level.color +"[AUP] "+ _fileName + text);
771781
break;
772782
case "WARN", "NET_WARN":
773-
getLogger().warning(_nowFile + text);
783+
getLogger().warning(_fileName + text);
774784
break;
775785
}
776786
}
777787

778788
// 根据日志等级添加样式代码, 并记录到 logList
779789
// 非 INFO 日志添加 _nowFile 文本
780-
logList.add(level.color + (level.name.equals("INFO") ? "" : _nowFile) + text);
790+
logList.add(level.color + (level.name.equals("INFO") ? "" : _fileName) + text);
781791
}
782792
enum logLevel {
783793
// 允许被忽略的 INFO

0 commit comments

Comments
 (0)