diff options
author | DeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com> | 2022-06-12 17:25:44 +0200 |
---|---|---|
committer | DeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com> | 2022-06-12 17:25:44 +0200 |
commit | 354cab5542687c1272c8aab3f26834ecdc93de39 (patch) | |
tree | 0938fd6d9f22d721c756093d7bddef42790b9ac4 /src/main/java/cc/polyfrost/oneconfigloader/OneConfigLoader.java | |
parent | 26cbabadc91da0b7032440a0a84ae1b762f9f2b4 (diff) | |
download | OneConfigLoader-354cab5542687c1272c8aab3f26834ecdc93de39.tar.gz OneConfigLoader-354cab5542687c1272c8aab3f26834ecdc93de39.tar.bz2 OneConfigLoader-354cab5542687c1272c8aab3f26834ecdc93de39.zip |
update version
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfigloader/OneConfigLoader.java')
-rw-r--r-- | src/main/java/cc/polyfrost/oneconfigloader/OneConfigLoader.java | 15 |
1 files changed, 2 insertions, 13 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfigloader/OneConfigLoader.java b/src/main/java/cc/polyfrost/oneconfigloader/OneConfigLoader.java index 9259b36..892d524 100644 --- a/src/main/java/cc/polyfrost/oneconfigloader/OneConfigLoader.java +++ b/src/main/java/cc/polyfrost/oneconfigloader/OneConfigLoader.java @@ -65,16 +65,9 @@ public class OneConfigLoader implements IFMLLoadingPlugin { String downloadUrl = jsonObject.getAsJsonObject(channel).get("url").getAsString(); if (!oneConfigFile.exists() || !checksum.equals(getChecksum(oneConfigFile))) { - logger.info("Updating OneConfig..."); - File newOneConfigFile = new File(oneConfigDir, "OneConfig-NEW (1.8.9).jar"); downloadFile(downloadUrl, newOneConfigFile); - String newChecksum = getChecksum(newOneConfigFile); - if (!checksum.equals(newChecksum)) { - newOneConfigFile.delete(); - throw new SecurityException("Checksum mismatch! Expected " + checksum + ", but got " + newChecksum + "!"); - } - if (newOneConfigFile.exists()) { + if (newOneConfigFile.exists() && checksum.equals(getChecksum(newOneConfigFile))) { try { Files.move(newOneConfigFile.toPath(), oneConfigFile.toPath(), StandardCopyOption.REPLACE_EXISTING); logger.info("Updated OneConfig"); @@ -126,13 +119,9 @@ public class OneConfigLoader implements IFMLLoadingPlugin { DownloadUI ui = new DownloadUI(); try { URLConnection con = new URL(url).openConnection(); - con.setUseCaches(false); con.setRequestProperty("User-Agent", "OneConfig-Loader"); int length = con.getContentLength(); - if (location.exists()) { - logger.info("Deleting old file..."); - location.delete(); - } + if (location.exists()) location.delete(); location.createNewFile(); logger.info("Downloading new version of OneConfig... (" + length / 1024f + "KB)"); Thread downloader = new Thread(() -> { |