Skip to content

Commit 5853252

Browse files
committed
修复命令行模式下调用了GUI相关代码报错的问题
1 parent a7624bb commit 5853252

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

src/main/java/com/github/balloonupdate/mcpatch/client/Main.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ static boolean AppMain(boolean graphicsMode, StartMethod startMethod, boolean en
113113
SetupSwing.init();
114114

115115
// 初始化UI
116-
// window = graphicsMode ? new McPatchWindow() : null;
116+
window = graphicsMode ? new McPatchWindow() : null;
117117

118118
// 初始化窗口
119119
if (window != null) {

src/main/java/com/github/balloonupdate/mcpatch/client/Work.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -411,8 +411,6 @@ boolean run2(Servers server) throws IOException, McpatchBusinessException {
411411

412412
McpatchBusinessException ex = null;
413413

414-
window.setProgressBarValue(500);
415-
416414
for (int i = 0; i < config.reties + 1; i++) {
417415
// 空文件不需要下载
418416
if (f.length == 0) {
@@ -462,8 +460,10 @@ boolean run2(Servers server) throws IOException, McpatchBusinessException {
462460
// 进度回退
463461
totalDownloaded.addAndGet(-bytesCounter.get());
464462

465-
window.setProgressBarText(String.format("%s/%s - %s/s", BytesUtils.convertBytes(totalDownloaded.get()), BytesUtils.convertBytes(totalBytes), speed.sampleSpeed2()));
466-
window.setProgressBarValue((int) (totalDownloaded.get() / (float) totalBytes * 1000));
463+
if (window != null) {
464+
window.setProgressBarText(String.format("%s/%s - %s/s", BytesUtils.convertBytes(totalDownloaded.get()), BytesUtils.convertBytes(totalBytes), speed.sampleSpeed2()));
465+
window.setProgressBarValue((int) (totalDownloaded.get() / (float) totalBytes * 1000));
466+
}
467467

468468
if (i != config.reties) {
469469
Log.error("retrying");

0 commit comments

Comments
 (0)