Skip to content
This repository was archived by the owner on Aug 18, 2024. It is now read-only.

Commit 323647c

Browse files
committed
Fixed some bug
1 parent 2d23b8a commit 323647c

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/main/java/com/pistacium/modcheck/ModCheckFrame.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
import javax.swing.*;
88
import javax.swing.border.EmptyBorder;
99
import java.awt.*;
10-
import java.awt.event.ActionEvent;
11-
import java.awt.event.ActionListener;
1210
import java.io.File;
1311
import java.net.URI;
1412
import java.nio.file.InvalidPathException;
@@ -129,14 +127,16 @@ private void initBottomLayout() {
129127
ModCheck.setStatus(ModCheckStatus.DOWNLOADING_MOD_FILE);
130128

131129
Path finalInstancePath = instancePath;
132-
int maxCount = modCheckBoxes.entrySet().size();
133130
ArrayList<ModData> targetMods = new ArrayList<>();
131+
int maxCount = 0;
134132
for (Map.Entry<ModData, JCheckBox> modEntry : modCheckBoxes.entrySet()) {
135133
if (modEntry.getValue().isSelected() && modEntry.getValue().isEnabled()) {
136134
targetMods.add(modEntry.getKey());
135+
maxCount++;
137136
}
138137
}
139138

139+
int finalMaxCount = maxCount;
140140
ModCheck.THREAD_EXECUTOR.submit(() -> {
141141
int count = 0;
142142
ArrayList<ModData> failedMods = new ArrayList<>();
@@ -145,9 +145,11 @@ private void initBottomLayout() {
145145
if (!targetMod.downloadModJarFile(mcVersion, finalInstancePath)) {
146146
failedMods.add(targetMod);
147147
}
148-
this.progressBar.setValue((int) (++count / (maxCount * 1f)));
148+
this.progressBar.setValue((int) ((++count / (finalMaxCount * 1f)) * 100));
149149
}
150150
this.progressBar.setValue(100);
151+
ModCheck.setStatus(ModCheckStatus.IDLE);
152+
151153
for (ModData failedMod : failedMods) {
152154
JOptionPane.showMessageDialog(this, "Failed to download '" + failedMod.getName() +"'.", "Please try again", JOptionPane.ERROR_MESSAGE);
153155
}

src/main/java/com/pistacium/modcheck/util/ModCheckStatus.java

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

33
public enum ModCheckStatus {
44

5-
IDLE("all works done"),
5+
IDLE(""),
66

77
LOADING_AVAILABLE_VERSIONS("Loading available versions info"),
88

0 commit comments

Comments
 (0)