element.getAttribute("server").substring(element.getAttribute("server")
.lastIndexOf('/'), element.getAttribute("server").length())));
}
downloadTo = new File(App.settings.getLibrariesDir(), file);
if (download == Download.server) {
libraries.add(new Downloadable(App.settings.getFileURL(url), downloadTo, md5, this, false));
} else {
libraries.add(new Downloadable(url, downloadTo, md5, this, false));
}
libraryNamesAdded.add(file.substring(0, file.lastIndexOf("-")));
}
}
} catch (SAXException e) {
App.settings.logStackTrace(e);
} catch (ParserConfigurationException e) {
App.settings.logStackTrace(e);
} catch (IOException e) {
App.settings.logStackTrace(e);
}
} else {
for (com.atlauncher.data.json.Library library : this.jsonVersion.getLibraries()) {
if (library.hasDepends()) {
boolean found = false;
for (com.atlauncher.data.json.Mod mod : selectedJsonMods) {
if (library.getDepends().equalsIgnoreCase(mod.getName())) {
found = true;
break;
}
}
if (!found) {
continue;
}
} else if (library.hasDependsGroup()) {
boolean found = false;
for (com.atlauncher.data.json.Mod mod : selectedJsonMods) {
if (library.getDependsGroup().equalsIgnoreCase(mod.getGroup())) {
found = true;
break;
}
}
if (!found) {
continue;
}
}
if (librariesNeeded == null) {
this.librariesNeeded = library.getFile();
} else {
this.librariesNeeded += "," + library.getFile();
}
forgeLibraries.add(library.getFile());
File downloadTo = null;
if (this.isServer) {
if (!library.forServer()) {
continue;
}
serverLibraries.add(new File(getLibrariesDirectory(), library.getServer()));
}
downloadTo = new File(App.settings.getLibrariesDir(), library.getFile());
if (library.getDownloadType() == DownloadType.server) {
libraries.add(new Downloadable(App.settings.getFileURL(library.getUrl()), downloadTo,
library.getMD5(), this, false));
} else if (library.getDownloadType() == DownloadType.direct) {
libraries.add(new Downloadable(library.getUrl(), downloadTo, library.getMD5(), this, false));
} else {
LogManager.error("DownloadType for server library " + library.getFile() + " is invalid with a " +
"value of " + library.getDownloadType());
this.cancel(true);
return null;
}
if (library.getFile().contains("-")) {
libraryNamesAdded.add(library.getFile().substring(0, library.getFile().lastIndexOf("-")));
} else {
libraryNamesAdded.add(library.getFile());
}
}
}
// Now read in the library jars needed from Mojang
if (!this.isServer) {
for (Library library : this.version.getMinecraftVersion().getMojangVersion().getLibraries()) {
if (library.shouldInstall()) {
if (libraryNamesAdded.contains(library.getFile().getName().substring(0,
library.getFile().getName().lastIndexOf("-")))) {
LogManager.debug("Not adding library " + library.getName() + " as it's been overwritten " +
"already by the packs libraries!");
continue;
}
if (!library.shouldExtract()) {
if (librariesNeeded == null) {
this.librariesNeeded = library.getFile().getName();
} else {
this.librariesNeeded += "," + library.getFile().getName();
}
}
libraries.add(new Downloadable(library.getURL(), library.getFile(), null, this, false));
}
}
}
// Add Minecraft.jar
if (isServer) {
libraries.add(new Downloadable(MojangConstants.DOWNLOAD_BASE.getURL("versions/" + this.version
.getMinecraftVersion().getVersion() + "/minecraft_server." + this.version.getMinecraftVersion()
.getVersion() + ".jar"), new File(App.settings.getJarsDir(), "minecraft_server." + this.version
.getMinecraftVersion().getVersion() + ".jar"), null, this, false));
} else {
libraries.add(new Downloadable(MojangConstants.DOWNLOAD_BASE.getURL("versions/" + this.version
.getMinecraftVersion().getVersion() + "/" + this.version.getMinecraftVersion().getVersion() + "" +
".jar"), new File(App.settings.getJarsDir(), this.version.getMinecraftVersion().getVersion() + "" +
".jar"), null, this, false));
}
return libraries;