From fde65b16b8b27216ae452716d7e24eceb20af085 Mon Sep 17 00:00:00 2001 From: John Yorke Date: Sat, 8 Jan 2022 00:02:58 -0400 Subject: [PATCH] UpdateHandler changes --- .../common/handler/UpdateHandler.java | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/main/java/taintedmagic/common/handler/UpdateHandler.java b/src/main/java/taintedmagic/common/handler/UpdateHandler.java index 49585f07..f1e87c0e 100644 --- a/src/main/java/taintedmagic/common/handler/UpdateHandler.java +++ b/src/main/java/taintedmagic/common/handler/UpdateHandler.java @@ -9,25 +9,26 @@ import taintedmagic.common.TaintedMagic; public class UpdateHandler { - private static String currentVersion = TaintedMagic.VERSION; - private static String newestVersion; - public static String updateStatus = null; + private static String latestVersion = null; + public static String message = null; public static void checkForUpdate () { getNewestVersion(); - if (newestVersion != null) { - if (newestVersion.equalsIgnoreCase(currentVersion)) { + if (latestVersion != null) { + if (TaintedMagic.VERSION.equals("@VERSION@")) { + message = String.format("%sTainted Magic is running in DEV!", EnumChatFormatting.GREEN); + TaintedMagic.logger.info("Tainted Magic is running in DEV!"); } - else if (!newestVersion.equalsIgnoreCase(currentVersion)) { - updateStatus = EnumChatFormatting.RED + "Tainted Magic is out of date! The latest version is " - + EnumChatFormatting.GREEN + newestVersion; + else if (!latestVersion.equalsIgnoreCase(TaintedMagic.VERSION)) { + message = String.format("%sTainted Magic is out of date! The latest version is %s%s", EnumChatFormatting.RED, + EnumChatFormatting.GREEN, latestVersion); TaintedMagic.logger.warn("Mod out of date! You're still running {} ... the latest version is {}", - currentVersion, newestVersion); + TaintedMagic.VERSION, latestVersion); } } else { - updateStatus = EnumChatFormatting.RED + "Tainted Magic failed to connect to the update server!"; + message = String.format("%sTainted Magic failed to connect to the update server!", EnumChatFormatting.RED); } } @@ -35,7 +36,7 @@ private static void getNewestVersion () { try { final URL url = new URL("https://raw.githubusercontent.com/yorkeJohn/Tainted-Magic/master/version.txt"); final Scanner scan = new Scanner(url.openStream()); - newestVersion = scan.next(); + latestVersion = scan.next(); scan.close(); } catch (final MalformedURLException e) {