From 85e0a1fd2868504a084a872b5f6f9af31d8bd020 Mon Sep 17 00:00:00 2001 From: OMGeeky <> Date: Sun, 16 Feb 2025 17:29:01 +0100 Subject: [PATCH] Add version comparison logic to not notify for updates if current version is higher than latest --- .../rpg/atcontentstudio/ATContentStudio.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/com/gpl/rpg/atcontentstudio/ATContentStudio.java b/src/com/gpl/rpg/atcontentstudio/ATContentStudio.java index e53645f..e9d4f20 100644 --- a/src/com/gpl/rpg/atcontentstudio/ATContentStudio.java +++ b/src/com/gpl/rpg/atcontentstudio/ATContentStudio.java @@ -153,8 +153,7 @@ public class ATContentStudio { while ((inputLine = in.readLine()) != null) { lastLine = inputLine; } - if (lastLine != null && !lastLine.equals(APP_VERSION)) { - + if (lastLine != null && compareVersions(lastLine) < 0) { // for copying style JLabel label = new JLabel(); Font font = label.getFont(); @@ -231,4 +230,19 @@ public class ATContentStudio { } } } + + /// returns The difference between the the latest version and the current one (CURRENT - LATEST) + private static int compareVersions(String latest) { + String[] levels1 = ATContentStudio.APP_VERSION.substring(1).split("\\."); + String[] levels2 = latest.substring(1).split("\\."); + int length = Math.max(levels1.length, levels2.length); + for (int i = 0; i < length; i++) { + int v1 = i < levels1.length ? Integer.parseInt(levels1[i]) : 0; + int v2 = i < levels2.length ? Integer.parseInt(levels2[i]) : 0; + if (v1 != v2) { + return v1 - v2; + } + } + return 0; + } }