Only offer a save dialog if the response was ok

This commit is contained in:
Sollace 2018-08-23 00:49:58 +02:00
parent f90814a730
commit b46c082ae3

View file

@ -74,22 +74,24 @@ public class SkinChooser {
public void openSavePNG(Minecraft mc, String title, Runnable callback) {
uploader.downloadSkin().thenAccept(response -> {
openFileThread = new ThreadOpenFileFolder(mc, title, (fileDialog, dialogResult) -> {
openFileThread = null;
callback.run();
if (dialogResult == 0) {
File out = fileDialog.getSelectedFile();
if (response.ok()) {
openFileThread = new ThreadOpenFileFolder(mc, title, (fileDialog, dialogResult) -> {
openFileThread = null;
callback.run();
if (dialogResult == 0) {
File out = fileDialog.getSelectedFile();
try {
out.createNewFile();
try {
out.createNewFile();
FileUtils.copyInputStreamToFile(response.getInputStream(), out);
} catch (IOException e) {
e.printStackTrace();
FileUtils.copyInputStreamToFile(response.getInputStream(), out);
} catch (IOException e) {
e.printStackTrace();
}
}
}
});
openFileThread.start();
});
openFileThread.start();
}
});
}