Permalink
Browse files

Better version number checking and version bump.

  • Loading branch information...
1 parent 70f364b commit 5b81d994388598b1f1b6d549b476e37b487fdb6a @mkalus committed Apr 18, 2012
Showing with 19 additions and 3 deletions.
  1. +18 −2 src/main/java/de/beimax/simplespleef/util/UpdateChecker.java
  2. +1 −1 src/main/resources/plugin.yml
@@ -51,11 +51,27 @@ public String checkForUpdate(String version) throws Exception {
// just read first line
String inputLine = in.readLine();
in.close();
-
- if (inputLine != null && inputLine.equals(version)) return null; // no new update
+
+ // convert versions to number and compare
+ if (inputLine != null && versionToNumber(inputLine) <= versionToNumber(version)) return null; // no new update
return inputLine; // new version
}
+
+ /**
+ * convert version string to long
+ * @param version
+ * @return
+ */
+ protected long versionToNumber(String versionString) {
+ String[] noPoints = versionString.split("\\.");
+ if (noPoints.length != 3) return 0;
+ long version = 0;
+ for (int i = 0; i < noPoints.length; i++)
+ version = version * 100 + Integer.valueOf(noPoints[i]);
+
+ return version;
+ }
/**
* Update configuration files, if needed.
@@ -1,6 +1,6 @@
name: SimpleSpleef
main: de.beimax.simplespleef.SimpleSpleef
-version: 3.0.12
+version: 3.0.13
dev-url: http://dev.bukkit.org/server-mods/simple-spleef/
author: maxkalus
description: >

0 comments on commit 5b81d99

Please sign in to comment.