drtshock loves formatting, so I may as well

This commit is contained in:
gomeow
2013-04-12 10:54:25 -07:00
parent 678f61127e
commit 03a7b52a8e
22 changed files with 677 additions and 793 deletions
@@ -28,7 +28,7 @@ public class Updater extends Main {
}
try {
langConf.save(super.getLangFile());
} catch (IOException e) {
} catch(IOException e) {
log.log(Level.WARNING, "PlayerVaults: Failed to save lang.yml.");
log.log(Level.WARNING, "PlayerVaults: Report this stack trace to drtshock and gomeow.");
e.printStackTrace();
@@ -40,34 +40,47 @@ public class Updater extends Main {
public String getNewVersion() {
return this.newVersion;
}
public boolean getUpdate() throws Exception {
String version = this.version;
URL url = new URL("http://dev.bukkit.org/server-mods/playervaults/files.rss");
InputStreamReader isr = null;
try {
isr = new InputStreamReader(url.openStream());
}
catch(UnknownHostException e) {
return false; //Cannot connect
} catch(UnknownHostException e) {
return false; // Cannot connect
}
BufferedReader in = new BufferedReader(isr);
String line;
int lineNum = 0;
while((line = in.readLine()) != null) {
while ((line = in.readLine()) != null) {
if(line.length() != line.replace("<title>", "").length()) {
line = line.replaceAll("<title>", "").replaceAll("</title>", "").replaceAll(" ", "").substring(1); //Substring 1 for me, takes off the beginning v on my file name "v1.3.2"
line = line.replaceAll("<title>", "").replaceAll("</title>", "").replaceAll(" ", "").substring(1); // Substring
// 1
// for
// me,
// takes
// off
// the
// beginning
// v
// on
// my
// file
// name
// "v1.3.2"
if(lineNum == 1) {
this.newVersion = line;
Integer newVer = Integer.parseInt(line.replace(".", ""));
Integer oldVer = Integer.parseInt(version.replace(".", ""));
if(oldVer < newVer) {
return true; //They are using an old version
return true; // They are using an old version
}
else if(oldVer > newVer) {
return false; //They are using a FUTURE version!
return false; // They are using a FUTURE version!
}
else {
return false; //They are up to date!
return false; // They are up to date!
}
}
lineNum = lineNum + 1;