Skip to content

Commit

Permalink
Fix index downloading bug
Browse files Browse the repository at this point in the history
Change from using HTTP downloader to NIO downloader
  • Loading branch information
MajickTek committed Feb 26, 2022
1 parent 7a1f16d commit 91cd5ad
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
28 changes: 28 additions & 0 deletions MiniCraftLauncher/src/com/mt/minilauncher/Debug.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,41 @@
import javax.swing.JOptionPane;

public class Debug {

/**
* Equal to JOptionPane.INFORMATION_MESSAGE
*/
public static int INF = JOptionPane.INFORMATION_MESSAGE;

/**
* Equal to JOptionPane.ERROR_MESSAGE
*/
public static int ERR = JOptionPane.ERROR_MESSAGE;

/**
* Equal to JOptionPane.PLAIN_MESSAGE
*/
public static int TST = JOptionPane.PLAIN_MESSAGE;

/**
* Equal to JOptionPane.WARNING_MESSAGE
*/
public static int WARN = JOptionPane.WARNING_MESSAGE;


/**
* Equal to JOptionPane.OK_CANCEL_OPTION
*/
public static int OK_CANCEL = JOptionPane.OK_CANCEL_OPTION;

/**
* Equal to JOptionPane.OK_OPTION
*/
public static int OK = JOptionPane.OK_OPTION;

/**
* Equal to JOptionPane.CANCEL_OPTION
*/
public static int CANCEL = JOptionPane.CANCEL_OPTION;

public static void callCrashDialog(String title, String message, int msgtype) {
Expand Down
9 changes: 6 additions & 3 deletions MiniCraftLauncher/src/com/mt/minilauncher/util/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,12 @@ public static DefaultListModel<VersionObject> buildIndex(boolean isRelease, bool
}
String indexURL = baseURL + indexFileName;

Downloader downloader = new Downloader(indexURL, Paths.get(Initializer.indexPath.toString(), indexFileName).toString());
downloader.download();

try {
downloadUsingNIO(indexURL, Paths.get(Initializer.indexPath.toString(), indexFileName).toString());
} catch (IOException e1) {
Debug.callCrashDialog("ERROR", "Failed to download index file. Check console for details.", Debug.ERR);
e1.printStackTrace();
}
DefaultListModel<VersionObject> model = new DefaultListModel<>();

VersionObject[] vos;
Expand Down

0 comments on commit 91cd5ad

Please sign in to comment.