if(forceDownload || CurrentVersion.fromJar()) {
XMLElementDecorator downloads = elem.getPath("bnubot/downloads");
if(downloads != null) {
for(XMLElementDecorator file : downloads.getChildren("file")) {
XMLElementDecorator sha1Element = file.getChild("sha1");
SHA1Sum sha1 = null;
if(sha1Element != null)
sha1 = new SHA1Sum(sha1Element.getString());
String from = file.getChild("from").getString();
String to = file.getChild("to").getString();
if(downloadFolder != null)
to = downloadFolder + File.separatorChar + to;
URLDownloader.downloadURL(
new URL(from),
new File(to),
sha1,
false);
}
}
}
XMLElementDecorator gamesElem = elem.getPath("bnubot/games");
if(gamesElem != null)
for(int i = 0; i < Constants.prods.length; i++) {
String game = Constants.prods[i];
int verByte = Constants.IX86verbytes[i];
XMLElementDecorator gameElem = gamesElem.getPath(game);
if(gameElem == null)
continue;
int vb = gameElem.getPath("verbyte").getInt();
if(verByte != vb) {
Out.error(VersionCheck.class, "Verbyte for game " + game + " is updating from 0x" + Integer.toHexString(verByte) + " to 0x" + Integer.toHexString(vb));
Constants.IX86verbytes[i] = vb;
}
}
XMLElementDecorator verLatest = elem.getPath("bnubot/latestVersion");
if(verLatest == null)
return false;
String releaseType = verLatest.getChild("type").getString();
// FIXME: this is for logging, to collect data
if(releaseType == null)
throw new NullPointerException("type is null\n" + verLatest.toString());
vnLatest = new VersionNumber(
Enum.valueOf(ReleaseType.class, releaseType),
verLatest.getChild("major").getInt(),
verLatest.getChild("minor").getInt(),
verLatest.getChild("revision").getInt(),
verLatest.getChild("release").getInt(),
verLatest.getChild("svn").getInt(),
verLatest.getChild("built").getDate());
String url = verLatest.getChild("url").getString();
XMLElementDecorator sha1Element = verLatest.getChild("sha1");
SHA1Sum sha1 = null;
if((sha1Element != null) && (sha1Element.getString() != null))
sha1 = new SHA1Sum(sha1Element.getString());
if(forceDownload) {
if(url == null)
return false;