mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2025-02-13 16:24:23 +01:00
Only offer a save dialog if the response was ok
This commit is contained in:
parent
f90814a730
commit
b46c082ae3
1 changed files with 15 additions and 13 deletions
|
@ -74,22 +74,24 @@ public class SkinChooser {
|
||||||
|
|
||||||
public void openSavePNG(Minecraft mc, String title, Runnable callback) {
|
public void openSavePNG(Minecraft mc, String title, Runnable callback) {
|
||||||
uploader.downloadSkin().thenAccept(response -> {
|
uploader.downloadSkin().thenAccept(response -> {
|
||||||
openFileThread = new ThreadOpenFileFolder(mc, title, (fileDialog, dialogResult) -> {
|
if (response.ok()) {
|
||||||
openFileThread = null;
|
openFileThread = new ThreadOpenFileFolder(mc, title, (fileDialog, dialogResult) -> {
|
||||||
callback.run();
|
openFileThread = null;
|
||||||
if (dialogResult == 0) {
|
callback.run();
|
||||||
File out = fileDialog.getSelectedFile();
|
if (dialogResult == 0) {
|
||||||
|
File out = fileDialog.getSelectedFile();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
out.createNewFile();
|
out.createNewFile();
|
||||||
|
|
||||||
FileUtils.copyInputStreamToFile(response.getInputStream(), out);
|
FileUtils.copyInputStreamToFile(response.getInputStream(), out);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
openFileThread.start();
|
||||||
openFileThread.start();
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue