From ad1a4fe26eb5a0ecba9a48333b437b6b92f2388e Mon Sep 17 00:00:00 2001 From: sebampuero Date: Sat, 15 Mar 2025 16:00:00 +0100 Subject: [PATCH] fix: catch unhandled exception when version does not exist yet --- pom.xml | 2 +- src/main/java/lol/hyper/toolstats/ToolStats.java | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 283c749..9a3fe5f 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ lol.hyper toolstats - 1.9.2-hotfix-2 + 1.9.3 jar ToolStats diff --git a/src/main/java/lol/hyper/toolstats/ToolStats.java b/src/main/java/lol/hyper/toolstats/ToolStats.java index d8fccd9..f1023af 100644 --- a/src/main/java/lol/hyper/toolstats/ToolStats.java +++ b/src/main/java/lol/hyper/toolstats/ToolStats.java @@ -19,6 +19,7 @@ package lol.hyper.toolstats; import lol.hyper.githubreleaseapi.GitHubRelease; import lol.hyper.githubreleaseapi.GitHubReleaseAPI; +import lol.hyper.githubreleaseapi.ReleaseNotFoundException; import lol.hyper.toolstats.commands.CommandToolStats; import lol.hyper.toolstats.events.*; import lol.hyper.toolstats.tools.*; @@ -251,12 +252,14 @@ public final class ToolStats extends JavaPlugin { e.printStackTrace(); return; } - GitHubRelease current = api.getReleaseByTag(this.getPluginMeta().getVersion()); - GitHubRelease latest = api.getLatestVersion(); - if (current == null) { + GitHubRelease current; + try{ + current = api.getReleaseByTag(this.getPluginMeta().getVersion()); + }catch(ReleaseNotFoundException e){ logger.warning("You are running a version that does not exist on GitHub. If you are in a dev environment, you can ignore this. Otherwise, this is a bug!"); return; } + GitHubRelease latest = api.getLatestVersion(); int buildsBehind = api.getBuildsBehind(current); if (buildsBehind == 0) { logger.info("You are running the latest version.");