@@ -119,11 +119,16 @@ private void initBottomLayout() {
119119
120120 Stack <Path > instancePathStack = new Stack <>();
121121 try {
122- String [] pathArr = pathField .getText ().split (String .format ("\\ %s" , File .separator ));
122+ String pathSeparator = String .format ("\\ %s" , File .separator );
123+ String [] pathArr = (pathField .getText ().endsWith (pathSeparator ) ?
124+ pathField .getText ().substring (0 , pathField .getText ().lastIndexOf (pathSeparator )-1 ) :
125+ pathField .getText ()
126+ ).split (pathSeparator );
127+ System .out .println ("Selected Path : " + String .join (pathSeparator , pathArr ));
123128 String lastPath = pathArr [pathArr .length - 1 ];
124129 if (lastPath .contains ("*" ) && lastPath .chars ().filter (c -> c == '*' ).count () == 1 ) {
125130 pathArr [pathArr .length - 1 ] = "" ;
126- File [] pathFiles = Paths .get (String .join (File . separator , pathArr )).toFile ().listFiles ();
131+ File [] pathFiles = Paths .get (String .join (pathSeparator , pathArr )).toFile ().listFiles ();
127132 if (pathFiles == null ) {
128133 throw new IllegalAccessException ();
129134 }
@@ -147,7 +152,7 @@ private void initBottomLayout() {
147152 }
148153 }
149154 } else {
150- instancePathStack .push (Paths .get (String .join (File . separator , pathArr )));
155+ instancePathStack .push (Paths .get (String .join (pathSeparator , pathArr )));
151156 }
152157 } catch (Exception exception ) {
153158 exception .printStackTrace ();
@@ -157,15 +162,21 @@ private void initBottomLayout() {
157162 }
158163
159164 Stack <File > modsFileStack = new Stack <>();
160- for (Path instancePath : instancePathStack ) {
165+ for (Path ip : instancePathStack ) {
166+ Path instancePath = ip ;
167+ File dotMinecraft = instancePath .resolve (".minecraft" ).toFile ();
168+ if (dotMinecraft .isDirectory ()) {
169+ instancePath = instancePath .resolve (".minecraft" );
170+ }
171+
161172 Path modsPath = instancePath .resolve ("mods" );
162- File instanceDir = modsPath .toFile ();
163- if (!instanceDir .isDirectory ()) {
173+ File modsDir = modsPath .toFile ();
174+ if (!modsDir .isDirectory ()) {
164175 JOptionPane .showMessageDialog (this , "Please select a instance path(directory)!" , "Please try again" , JOptionPane .ERROR_MESSAGE );
165176 downloadButton .setEnabled (true );
166177 return ;
167178 }
168- modsFileStack .push (instanceDir );
179+ modsFileStack .push (modsDir );
169180 }
170181
171182 if (this .versionSelection .getSelectedItem () == null ) {
@@ -178,6 +189,7 @@ private void initBottomLayout() {
178189 int maxCount = 0 ;
179190 for (Map .Entry <ModData , JCheckBox > modEntry : modCheckBoxes .entrySet ()) {
180191 if (modEntry .getValue ().isSelected () && modEntry .getValue ().isEnabled ()) {
192+ System .out .println ("Selected " +modEntry .getKey ().getName ());
181193 targetMods .add (modEntry .getKey ());
182194 maxCount ++;
183195 }
@@ -214,18 +226,29 @@ private void initBottomLayout() {
214226 ArrayList <ModData > failedMods = new ArrayList <>();
215227 for (ModData targetMod : targetMods ) {
216228 this .progressBar .setString ("Downloading '" + targetMod .getName () + "'" );
217- if (!targetMod .downloadModJarFile (mcVersion , modsFileStack )) {
229+ System .out .println ("Downloading " +targetMod .getName ());
230+ Stack <File > downloadFiles = new Stack <>();
231+ downloadFiles .addAll (modsFileStack );
232+ if (!targetMod .downloadModJarFile (mcVersion , downloadFiles )) {
233+ System .out .println ("Failed to downloading " +targetMod .getName ());
218234 failedMods .add (targetMod );
219235 }
220236 this .progressBar .setValue ((int ) ((++count / (finalMaxCount * 1f )) * 100 ));
221237 }
222238 this .progressBar .setValue (100 );
223239 ModCheck .setStatus (ModCheckStatus .IDLE );
224240
225- for (ModData failedMod : failedMods ) {
226- JOptionPane .showMessageDialog (this , "Failed to download '" + failedMod .getName () +"'." , "Please try again" , JOptionPane .ERROR_MESSAGE );
241+ System .out .println ("Done with download mods" );
242+
243+ if (failedMods .size () > 0 ) {
244+ StringBuilder failedModString = new StringBuilder ();
245+ for (ModData failedMod : failedMods ) {
246+ failedModString .append (failedMod .getName ()).append (", " );
247+ }
248+ JOptionPane .showMessageDialog (this , "Failed to download " + failedModString .substring (0 , failedModString .length () - 2 ) +"." , "Please try again" , JOptionPane .ERROR_MESSAGE );
249+ } else {
250+ JOptionPane .showMessageDialog (this , "All selected mods have been downloaded!" );
227251 }
228- JOptionPane .showMessageDialog (this , "All selected mods have been downloaded!" );
229252 downloadButton .setEnabled (true );
230253 });
231254 });
@@ -374,15 +397,16 @@ public void updateModList() {
374397 }
375398 });
376399
400+ int line = modData .getDescription ().split ("\n " ).length ;
377401 JLabel description = new JLabel ("<html><body>" + modData .getDescription ().replace ("\n " , "<br>" ) + "</body></html>" );
378- description .setMaximumSize (new Dimension (800 , 60 ));
402+ description .setMaximumSize (new Dimension (800 , 60 * line ));
379403 description .setBorder (new EmptyBorder (0 , 15 ,0 , 0 ));
380404 Font f = description .getFont ();
381405 description .setFont (f .deriveFont (f .getStyle () & ~Font .BOLD ));
382406
383407 modPanel .add (checkBox );
384408 modPanel .add (description );
385- modPanel .setMaximumSize (new Dimension (950 , 60 ));
409+ modPanel .setMaximumSize (new Dimension (950 , 60 * line ));
386410 modPanel .setBorder (new EmptyBorder (0 , 10 ,10 , 0 ));
387411
388412 versionJPanel .add (modPanel );
0 commit comments