private class TexturePackManagerWorker extends SwingWorker<Boolean, Void> {
@Override
protected Boolean doInBackground () throws Exception {
String installPath = Settings.getSettings().getInstallPath();
TexturePack texturePack = TexturePack.getSelectedTexturePack();
String compDir = texturePack.getSelectedCompatible();
ModPack compPack = ModPack.getPack(compDir);
int mcversion = Integer.parseInt(compPack.getMcVersion().replace(".", ""));
if (updating) {
texturePack = updateTexture;
compDir = updateModPack.getDir();
compPack = updateModPack;
}
if (compPack == null) {
ErrorUtils.tossError("Error: Invalid Mod Pack destination selected.");
return false;
}
String packVer = (Settings.getSettings().getPackVer(compDir).equalsIgnoreCase("Recommended Version") ? compPack.getVersion() : Settings.getSettings().getPackVer(compDir))
.replace(".", "_");
String packStr;
if (mcversion > 160) {
packStr = "";
} else {
packStr = "/" + packVer;
}
if (!compPack.hasCustomTP()
&& DownloadUtils.fileExists(TEXTUREPACKS + texturePack.getName().replace(" ", "_") + "/" + "master_" + compPack.getMcVersion().replace(".", "_") + packStr + "/"
+ texturePack.getUrl())) {
populateInstalledTextures(compPack);
File oldFile = new File(installPath, texturePack.getSelectedCompatible() + sep + "minecraft" + sep + getTPDirectory(mcversion) + sep + texturePack.getUrl());
if (oldFile.exists()) {
oldFile.delete();
}
return downloadTexturePack(texturePack.getUrl(), texturePack.getName(), "master_" + compPack.getMcVersion().replace(".", "_"), compDir, packVer);
} else if (DownloadUtils.fileExists(TEXTUREPACKS + texturePack.getName().replace(" ", "_") + "/" + compDir + packStr + "/" + texturePack.getUrl())) {
populateInstalledTextures(compPack);
File oldFile = new File(installPath, texturePack.getSelectedCompatible() + sep + "minecraft" + sep + getTPDirectory(mcversion) + sep + texturePack.getUrl());
if (oldFile.exists()) {
oldFile.delete();
}
return downloadTexturePack(texturePack.getUrl(), texturePack.getName(), compDir, compDir, packVer);
} else {
ErrorUtils.tossError("Error: Texture Pack not found for selected mod pack's version!");
return false;
}
}