mirror of
https://github.com/BlueMap-Minecraft/BlueMap.git
synced 2024-11-22 10:35:16 +01:00
Fix error when loading minecraft version pre 1.14 Fixes: #579
This commit is contained in:
parent
79fd4d0201
commit
56369c9143
@ -39,7 +39,8 @@
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.Reader;
|
||||
import java.net.URL;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.*;
|
||||
import java.security.DigestInputStream;
|
||||
@ -140,7 +141,7 @@ private static void download(VersionManifest.Version version, Path file) throws
|
||||
FileHelper.createDirectories(file.toAbsolutePath().normalize().getParent());
|
||||
|
||||
try (
|
||||
DigestInputStream in = new DigestInputStream(new URL(download.getUrl()).openStream(), MessageDigest.getInstance("SHA-1"));
|
||||
DigestInputStream in = new DigestInputStream(new URI(download.getUrl()).toURL().openStream(), MessageDigest.getInstance("SHA-1"));
|
||||
OutputStream out = Files.newOutputStream(file, StandardOpenOption.WRITE, StandardOpenOption.CREATE_NEW, StandardOpenOption.TRUNCATE_EXISTING)
|
||||
) {
|
||||
in.transferTo(out);
|
||||
@ -154,7 +155,7 @@ private static void download(VersionManifest.Version version, Path file) throws
|
||||
}
|
||||
|
||||
downloadCompletedAndVerified = true;
|
||||
} catch (NoSuchAlgorithmException | IOException ex) {
|
||||
} catch (NoSuchAlgorithmException | IOException | URISyntaxException ex) {
|
||||
Logger.global.logWarning("Failed to download '" + download.getUrl() + "': " + ex);
|
||||
} finally {
|
||||
if (!downloadCompletedAndVerified)
|
||||
@ -200,7 +201,8 @@ private static VersionInfo loadVersionInfo(Path file) throws IOException {
|
||||
}
|
||||
}
|
||||
|
||||
throw new IOException("'" + file + "' does not contain a 'version.json'");
|
||||
// no version.json found, assume 1.13 - 1.14.4
|
||||
return new VersionInfo(4, 4);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user