Skip to content
This repository has been archived by the owner on Mar 30, 2018. It is now read-only.

Commit

Permalink
Better version number checking and version bump.
Browse files Browse the repository at this point in the history
  • Loading branch information
mkalus committed Apr 18, 2012
1 parent 70f364b commit 5b81d99
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
20 changes: 18 additions & 2 deletions src/main/java/de/beimax/simplespleef/util/UpdateChecker.java
Expand Up @@ -51,11 +51,27 @@ public String checkForUpdate(String version) throws Exception {
// just read first line // just read first line
String inputLine = in.readLine(); String inputLine = in.readLine();
in.close(); 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 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. * Update configuration files, if needed.
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
@@ -1,6 +1,6 @@
name: SimpleSpleef name: SimpleSpleef
main: de.beimax.simplespleef.SimpleSpleef main: de.beimax.simplespleef.SimpleSpleef
version: 3.0.12 version: 3.0.13
dev-url: http://dev.bukkit.org/server-mods/simple-spleef/ dev-url: http://dev.bukkit.org/server-mods/simple-spleef/
author: maxkalus author: maxkalus
description: > description: >
Expand Down

0 comments on commit 5b81d99

Please sign in to comment.