From a3a41c44a92d846bc04eeb7589f9dc7dab9df7e0 Mon Sep 17 00:00:00 2001 From: coolGi Date: Sat, 2 Sep 2023 20:10:56 +0930 Subject: [PATCH] Fixed crash ran on version not on Modrinth --- .../core/jar/installer/ModrinthGetter.java | 9 ++++++++- .../distanthorizons/core/jar/updater/SelfUpdater.java | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/com/seibel/distanthorizons/core/jar/installer/ModrinthGetter.java b/core/src/main/java/com/seibel/distanthorizons/core/jar/installer/ModrinthGetter.java index 92fd0ebf2..8d2976a1c 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/jar/installer/ModrinthGetter.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/jar/installer/ModrinthGetter.java @@ -122,7 +122,14 @@ public class ModrinthGetter public static String getLatestIDForVersion(String mcVer) { - return mcVerToReleaseID.get(mcVer).get(0); + try + { + return mcVerToReleaseID.get(mcVer).get(0); + } + catch (Exception e) + { + return null; + } } public static String getLatestNameForVersion(String mcVer) { diff --git a/core/src/main/java/com/seibel/distanthorizons/core/jar/updater/SelfUpdater.java b/core/src/main/java/com/seibel/distanthorizons/core/jar/updater/SelfUpdater.java index 89345f11e..615690a6a 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/jar/updater/SelfUpdater.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/jar/updater/SelfUpdater.java @@ -57,9 +57,11 @@ public class SelfUpdater */ public static boolean onStart() { + LOGGER.info("Checking for DH update"); // Some init stuff // We use sha1 to check the version as our versioning system is different to the one on modrinth - if (!ModrinthGetter.init()) return false; + if (!ModrinthGetter.init()) + return false; String jarSha = ""; try { @@ -71,6 +73,11 @@ public class SelfUpdater return false; } String mcVersion = SingletonInjector.INSTANCE.get(IVersionConstants.class).getMinecraftVersion(); + if (!ModrinthGetter.mcVersions.contains(mcVersion)) + { + LOGGER.warn("Minecraft version ["+ mcVersion +"] is not findable on Modrinth, only findable versions are ["+ ModrinthGetter.mcVersions.toString() +"]"); + return false; + } // Check the sha's of both our stuff if (jarSha.equals(ModrinthGetter.getLatestShaForVersion(mcVersion)))