diff options
author | Wyvest <45589059+Wyvest@users.noreply.github.com> | 2022-07-06 20:27:30 +0900 |
---|---|---|
committer | Wyvest <45589059+Wyvest@users.noreply.github.com> | 2022-07-06 20:27:30 +0900 |
commit | c11fe89a44f3084aaaca41f24ec61a5c602c115c (patch) | |
tree | dd196da42bd13b49621f521e15daff1394ff4837 /src/main | |
parent | 144b280be826320a47e6dc483c417680b9d83250 (diff) | |
download | OneConfigLoader-main.tar.gz OneConfigLoader-main.tar.bz2 OneConfigLoader-main.zip |
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/cc/polyfrost/oneconfigloader/OneConfigLoader.java | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfigloader/OneConfigLoader.java b/src/main/java/cc/polyfrost/oneconfigloader/OneConfigLoader.java index 8f7600b..0bb6300 100644 --- a/src/main/java/cc/polyfrost/oneconfigloader/OneConfigLoader.java +++ b/src/main/java/cc/polyfrost/oneconfigloader/OneConfigLoader.java @@ -6,6 +6,7 @@ import com.google.gson.JsonParser; import net.minecraft.launchwrapper.ITweaker; import net.minecraft.launchwrapper.Launch; import net.minecraft.launchwrapper.LaunchClassLoader; +import net.minecraftforge.common.ForgeVersion; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -24,6 +25,7 @@ import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.Arrays; import java.util.List; +import java.util.Map; import java.util.Objects; public class OneConfigLoader implements ITweaker { @@ -54,10 +56,19 @@ public class OneConfigLoader implements ITweaker { if (!oneConfigDir.exists() && !oneConfigDir.mkdir()) throw new IllegalStateException("Could not create OneConfig dir!"); - File oneConfigFile = new File(oneConfigDir, "OneConfig (1.8.9).jar"); + Object mcVersion = "1.8.9"; + try { + mcVersion = ForgeVersion.class.getDeclaredField("mcVersion").get(null); + System.out.println("OneConfig has detected the version " + mcVersion + ". If this is false, report this at https://inv.wtf/polyfrost"); + } catch (Exception e) { + e.printStackTrace(); + System.out.println("Getting the Minecraft version failed, defaulting to 1.8.9. Please report this to https://inv.wtf/polyfrost"); + } + + File oneConfigFile = new File(oneConfigDir, "OneConfig (" + mcVersion + "-forge" + ").jar"); if (!isInitialized(oneConfigFile)) { - JsonElement json = update ? getRequest("https://api.polyfrost.cc/oneconfig/1.8.9-forge") : null; + JsonElement json = update ? getRequest("https://api.polyfrost.cc/oneconfig/" + mcVersion + "-forge") : null; if (json != null && json.isJsonObject()) { JsonObject jsonObject = json.getAsJsonObject(); @@ -69,7 +80,7 @@ public class OneConfigLoader implements ITweaker { String downloadUrl = jsonObject.getAsJsonObject(channel).get("url").getAsString(); if (!oneConfigFile.exists() || !checksum.equals(getChecksum(oneConfigFile))) { - File newOneConfigFile = new File(oneConfigDir, "OneConfig-NEW (1.8.9).jar"); + File newOneConfigFile = new File(oneConfigDir, "OneConfig-NEW (" + mcVersion + "-forge" + ").jar"); downloadFile(downloadUrl, newOneConfigFile); if (newOneConfigFile.exists() && checksum.equals(getChecksum(newOneConfigFile))) { try { |