Fixed crash ran on version not on Modrinth

This commit is contained in:
coolGi
2023-09-02 20:10:56 +09:30
parent 1af6e83086
commit a3a41c44a9
2 changed files with 16 additions and 2 deletions
@@ -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)
{
@@ -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)))