if (getLatestMinecraft().equals(getMinecraft())) {
int build;
String url = RestAPI.getSpoutcraftURL(channel);
try {
stream = RestAPI.getCachingInputStream(new URL(url), true);
Project project = mapper.readValue(stream, Project.class);
build = project.getBuild();
} catch (IOException e) {
throw new RestfulAPIException("Error accessing URL [" + url + "]", e);
} finally {
IOUtils.closeQuietly(stream);
}
// Check to see if stable has newer release
if (channel == Channel.STABLE) {
return String.valueOf(build);
} else {
url = RestAPI.getSpoutcraftURL(Channel.STABLE);
try {
stream = RestAPI.getCachingInputStream(new URL(url), true);
Project stable = mapper.readValue(stream, Project.class);
// Stable release is newer
if (stable.getBuild() > build) {
return String.valueOf(stable.getBuild());
} else {
return String.valueOf(build);
}
} catch (IOException e) {
throw new RestfulAPIException("Error accessing URL [" + url + "]", e);