77import javax .swing .*;
88import javax .swing .border .EmptyBorder ;
99import java .awt .*;
10- import java .awt .event .ActionEvent ;
11- import java .awt .event .ActionListener ;
1210import java .io .File ;
1311import java .net .URI ;
1412import 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 }
0 commit comments