Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2eaf32b23d | ||
|
|
5899c73ab8 | ||
|
|
6c0a446692 | ||
|
|
7c2cfc171e |
No files matched your search
+8
-4
@@ -57,7 +57,7 @@ public class BMCLAPIDownloadProvider extends IDownloadProvider {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getVersionsListDownloadURL() {
|
public String getVersionsListDownloadURL() {
|
||||||
return "http://bmclapi2.bangbang93.com/versions/versions.json";
|
return "http://bmclapi2.bangbang93.com/mc/game/version_manifest.json";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -66,13 +66,17 @@ public class BMCLAPIDownloadProvider extends IDownloadProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getParsedLibraryDownloadURL(String str) {
|
public String getParsedDownloadURL(String str) {
|
||||||
return str == null ? null : str.replace("http://files.minecraftforge.net/maven", "http://bmclapi2.bangbang93.com/maven");
|
return str == null ? null
|
||||||
|
: str.replace("https://launchermeta.mojang.com", "http://bmclapi2.bangbang93.com")
|
||||||
|
.replace("https://launcher.mojang.com", "http://bmclapi2.bangbang93.com")
|
||||||
|
.replace("https://libraries.minecraft.net", "http://bmclapi2.bangbang93.com/libraries")
|
||||||
|
.replace("http://files.minecraftforge.net/maven", "http://bmclapi2.bangbang93.com/maven");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAllowedToUseSelfURL() {
|
public boolean isAllowedToUseSelfURL() {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+1
-1
@@ -24,7 +24,7 @@ package org.jackhuang.hellominecraft.launcher.core.download;
|
|||||||
public class CurseDownloadProvider extends MojangDownloadProvider {
|
public class CurseDownloadProvider extends MojangDownloadProvider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getParsedLibraryDownloadURL(String str) {
|
public String getParsedDownloadURL(String str) {
|
||||||
return str == null ? null : str.replace("http://files.minecraftforge.net/maven", "http://ftb.cursecdn.com/FTB2/maven/");
|
return str == null ? null : str.replace("http://files.minecraftforge.net/maven", "http://ftb.cursecdn.com/FTB2/maven/");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+9
-1
@@ -55,7 +55,15 @@ public abstract class IDownloadProvider {
|
|||||||
|
|
||||||
public abstract String getAssetsDownloadURL();
|
public abstract String getAssetsDownloadURL();
|
||||||
|
|
||||||
public abstract String getParsedLibraryDownloadURL(String str);
|
/**
|
||||||
|
* For example, minecraft.json/assetIndex/url or
|
||||||
|
* minecraft.json/downloads/client/url
|
||||||
|
*
|
||||||
|
* @param str baseURL
|
||||||
|
*
|
||||||
|
* @return parsedURL
|
||||||
|
*/
|
||||||
|
public abstract String getParsedDownloadURL(String str);
|
||||||
|
|
||||||
public abstract boolean isAllowedToUseSelfURL();
|
public abstract boolean isAllowedToUseSelfURL();
|
||||||
}
|
}
|
||||||
+54
-104
@@ -21,6 +21,7 @@ import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftDownloadServ
|
|||||||
import com.google.gson.JsonSyntaxException;
|
import com.google.gson.JsonSyntaxException;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -31,11 +32,9 @@ import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftService;
|
|||||||
import org.jackhuang.hellominecraft.launcher.core.version.GameDownloadInfo;
|
import org.jackhuang.hellominecraft.launcher.core.version.GameDownloadInfo;
|
||||||
import org.jackhuang.hellominecraft.launcher.core.version.IMinecraftLibrary;
|
import org.jackhuang.hellominecraft.launcher.core.version.IMinecraftLibrary;
|
||||||
import org.jackhuang.hellominecraft.launcher.core.version.MinecraftVersion;
|
import org.jackhuang.hellominecraft.launcher.core.version.MinecraftVersion;
|
||||||
import org.jackhuang.hellominecraft.util.tasks.TaskWindow;
|
|
||||||
import org.jackhuang.hellominecraft.util.tasks.download.FileDownloadTask;
|
import org.jackhuang.hellominecraft.util.tasks.download.FileDownloadTask;
|
||||||
import org.jackhuang.hellominecraft.util.func.Function;
|
import org.jackhuang.hellominecraft.util.func.Function;
|
||||||
import org.jackhuang.hellominecraft.util.system.FileUtils;
|
import org.jackhuang.hellominecraft.util.system.FileUtils;
|
||||||
import org.jackhuang.hellominecraft.util.tasks.DoingDoneListener;
|
|
||||||
import org.jackhuang.hellominecraft.util.tasks.Task;
|
import org.jackhuang.hellominecraft.util.tasks.Task;
|
||||||
import org.jackhuang.hellominecraft.util.tasks.TaskInfo;
|
import org.jackhuang.hellominecraft.util.tasks.TaskInfo;
|
||||||
|
|
||||||
@@ -60,7 +59,7 @@ public class MinecraftDownloadService extends IMinecraftDownloadService {
|
|||||||
if (l.allow()) {
|
if (l.allow()) {
|
||||||
File ff = l.getFilePath(service.baseDirectory());
|
File ff = l.getFilePath(service.baseDirectory());
|
||||||
if (!ff.exists()) {
|
if (!ff.exists()) {
|
||||||
String libURL = service.getDownloadType().getProvider().getParsedLibraryDownloadURL(l.getDownloadInfo().getUrl(service.getDownloadType()));
|
String libURL = l.getDownloadInfo().getUrl(service.getDownloadType());
|
||||||
if (libURL != null)
|
if (libURL != null)
|
||||||
downloadLibraries.add(new DownloadLibraryJob(l, libURL, ff));
|
downloadLibraries.add(new DownloadLibraryJob(l, libURL, ff));
|
||||||
}
|
}
|
||||||
@@ -71,58 +70,31 @@ public class MinecraftDownloadService extends IMinecraftDownloadService {
|
|||||||
@Override
|
@Override
|
||||||
public Task downloadMinecraft(String id) {
|
public Task downloadMinecraft(String id) {
|
||||||
return new TaskInfo("Download Minecraft") {
|
return new TaskInfo("Download Minecraft") {
|
||||||
|
@Override
|
||||||
|
public Collection<Task> getDependTasks() {
|
||||||
|
return Arrays.asList(downloadMinecraftVersionJson(id));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void executeTask() throws Throwable {
|
public void executeTask() throws Throwable {
|
||||||
List<MinecraftRemoteVersion> versions = MinecraftRemoteVersions.getRemoteVersions(service.getDownloadType()).justDo();
|
|
||||||
MinecraftRemoteVersion currentVersion = null;
|
|
||||||
for (MinecraftRemoteVersion v : versions)
|
|
||||||
if (id.equals(v.id)) {
|
|
||||||
currentVersion = v;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (currentVersion == null)
|
|
||||||
throw new RuntimeException("Cannot find version: " + id + " in remote repository.");
|
|
||||||
String jsonURL = currentVersion.getUrl(service.getDownloadType());
|
|
||||||
File vpath = new File(service.baseDirectory(), "versions/" + id);
|
File vpath = new File(service.baseDirectory(), "versions/" + id);
|
||||||
File mvt = new File(vpath, id + ".json");
|
if (!areDependTasksSucceeded) {
|
||||||
|
FileUtils.deleteDirectory(vpath);
|
||||||
|
throw new RuntimeException("Cannot continue because of download failing.");
|
||||||
|
}
|
||||||
File mvj = new File(vpath, id + ".jar");
|
File mvj = new File(vpath, id + ".jar");
|
||||||
if (!vpath.exists() && !vpath.mkdirs())
|
|
||||||
HMCLog.warn("Failed to make directories: " + vpath);
|
|
||||||
if (mvt.exists() && !mvt.delete())
|
|
||||||
HMCLog.warn("Failed to delete " + mvt);
|
|
||||||
if (mvj.exists() && !mvj.delete())
|
if (mvj.exists() && !mvj.delete())
|
||||||
HMCLog.warn("Failed to delete " + mvj);
|
HMCLog.warn("Failed to delete " + mvj);
|
||||||
|
try {
|
||||||
|
MinecraftVersion mv = C.GSON.fromJson(FileUtils.readFileToStringQuietly(new File(vpath, id + ".json")), MinecraftVersion.class);
|
||||||
|
if (mv == null)
|
||||||
|
throw new JsonSyntaxException("incorrect version");
|
||||||
|
|
||||||
Task t = new FileDownloadTask(jsonURL, mvt).setTag(id + ".json");
|
afters.add(downloadMinecraftJar(mv, mvj));
|
||||||
t.addTaskListener(new DoingDoneListener<Task>() {
|
} catch (JsonSyntaxException ex) {
|
||||||
@Override
|
HMCLog.err("Failed to parse minecraft version json.", ex);
|
||||||
public void onDone(Task k, Collection<Task> taskCollection) {
|
FileUtils.deleteDirectory(vpath);
|
||||||
MinecraftVersion mv;
|
}
|
||||||
try {
|
|
||||||
mv = C.GSON.fromJson(FileUtils.readFileToStringQuietly(mvt), MinecraftVersion.class);
|
|
||||||
if (mv == null)
|
|
||||||
throw new JsonSyntaxException("incorrect version");
|
|
||||||
} catch (JsonSyntaxException ex) {
|
|
||||||
HMCLog.err("Failed to parse minecraft version json.", ex);
|
|
||||||
onFailed(k);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
GameDownloadInfo i = mv.getClientDownloadInfo();
|
|
||||||
taskCollection.add(new FileDownloadTask(i.getUrl(service.getDownloadType()), mvj, i.sha1)
|
|
||||||
.setFailedCallbackReturnsNewURL(new DownloadTypeSwitcher(id + "/" + id + ".jar")).setTag(id + ".jar"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDoing(Task k, Collection<Task> taskCollection) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailed(Task k) {
|
|
||||||
FileUtils.deleteDirectoryQuietly(vpath);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
afters.add(t);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Collection<Task> afters = new HashSet<>();
|
Collection<Task> afters = new HashSet<>();
|
||||||
@@ -134,34 +106,6 @@ public class MinecraftDownloadService extends IMinecraftDownloadService {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean downloadMinecraftJar(String id) {
|
|
||||||
String vurl = service.getDownloadType().getProvider().getVersionsDownloadURL() + id + "/";
|
|
||||||
File vpath = new File(service.baseDirectory(), "versions/" + id);
|
|
||||||
File mvv = new File(vpath, id + ".jar"), moved = null;
|
|
||||||
if (mvv.exists()) {
|
|
||||||
moved = new File(vpath, id + "-renamed.jar");
|
|
||||||
if (!mvv.renameTo(moved))
|
|
||||||
HMCLog.warn("Failed to rename " + mvv + " to " + moved);
|
|
||||||
}
|
|
||||||
File mvt = new File(vpath, id + ".jar");
|
|
||||||
if (!vpath.exists() && !vpath.mkdirs())
|
|
||||||
HMCLog.warn("Failed to make version folder " + vpath);
|
|
||||||
if (TaskWindow.factory()
|
|
||||||
.append(new FileDownloadTask(vurl + id + ".jar", mvt).setFailedCallbackReturnsNewURL(new DownloadTypeSwitcher(id + "/" + id + ".jar")).setTag(id + ".jar"))
|
|
||||||
.create()) {
|
|
||||||
if (moved != null && moved.exists() && !moved.delete())
|
|
||||||
HMCLog.warn("Failed to delete " + moved);
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
if (mvt.exists() && !mvt.delete())
|
|
||||||
HMCLog.warn("Failed to delete game jar " + mvt);
|
|
||||||
if (moved != null && moved.exists() && !moved.renameTo(mvt))
|
|
||||||
HMCLog.warn("Failed to rename " + moved + " to " + mvt);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class DownloadTypeSwitcher implements Function<Integer, String> {
|
private static class DownloadTypeSwitcher implements Function<Integer, String> {
|
||||||
|
|
||||||
String suffix;
|
String suffix;
|
||||||
@@ -178,37 +122,43 @@ public class MinecraftDownloadService extends IMinecraftDownloadService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Task downloadMinecraftJarTo(MinecraftVersion mv, File mvt) {
|
public Task downloadMinecraftJar(MinecraftVersion mv, File mvj) {
|
||||||
String jar = mv.jar == null ? mv.id : mv.jar;
|
|
||||||
GameDownloadInfo i = mv.getClientDownloadInfo();
|
GameDownloadInfo i = mv.getClientDownloadInfo();
|
||||||
return new FileDownloadTask(i.getUrl(service.getDownloadType(), true), mvt, i.sha1).setTag(jar + ".jar");
|
return new FileDownloadTask(i.getUrl(service.getDownloadType()), mvj, i.sha1)
|
||||||
|
.setFailedCallbackReturnsNewURL(new DownloadTypeSwitcher(mv.id + "/" + mv.id + ".jar")).setTag(mv.id + ".jar");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean downloadMinecraftVersionJson(String id) {
|
public Task downloadMinecraftVersionJson(String id) {
|
||||||
String vurl = service.getDownloadType().getProvider().getVersionsDownloadURL() + id + "/";
|
return new TaskInfo("Download Minecraft Json") {
|
||||||
File vpath = new File(service.baseDirectory(), "versions/" + id);
|
@Override
|
||||||
File mvv = new File(vpath, id + ".json"), moved = null;
|
public void executeTask() throws Throwable {
|
||||||
if (mvv.exists()) {
|
List<MinecraftRemoteVersion> versions = MinecraftRemoteVersions.getRemoteVersions(service.getDownloadType()).justDo();
|
||||||
moved = new File(vpath, id + "-renamed.json");
|
MinecraftRemoteVersion currentVersion = null;
|
||||||
if (!mvv.renameTo(moved))
|
for (MinecraftRemoteVersion v : versions)
|
||||||
HMCLog.warn("Failed to rename " + mvv + " to " + moved);
|
if (id.equals(v.id)) {
|
||||||
}
|
currentVersion = v;
|
||||||
File mvt = new File(vpath, id + ".json");
|
break;
|
||||||
if (!vpath.exists() && !vpath.mkdirs())
|
}
|
||||||
HMCLog.warn("Failed to make version folder " + vpath);
|
if (currentVersion == null)
|
||||||
if (TaskWindow.factory()
|
throw new RuntimeException("Cannot find version: " + id + " in remote repository.");
|
||||||
.append(new FileDownloadTask(vurl + id + ".json", mvt).setTag(id + ".json"))
|
String jsonURL = currentVersion.getUrl(service.getDownloadType());
|
||||||
.create()) {
|
File vpath = new File(service.baseDirectory(), "versions/" + id);
|
||||||
if (moved != null && moved.exists() && !moved.delete())
|
File mvt = new File(vpath, id + ".json");
|
||||||
HMCLog.warn("Failed to delete " + moved);
|
if (!vpath.exists() && !vpath.mkdirs())
|
||||||
return true;
|
HMCLog.warn("Failed to make directories: " + vpath);
|
||||||
} else {
|
if (mvt.exists() && !mvt.delete())
|
||||||
if (mvt.exists() && !mvt.delete())
|
HMCLog.warn("Failed to delete " + mvt);
|
||||||
HMCLog.warn("Failed to delete minecraft version json" + mvt);
|
|
||||||
if (moved != null && moved.exists() && !moved.renameTo(mvt))
|
afters.add(new FileDownloadTask(jsonURL, mvt).setTag(id + ".json"));
|
||||||
HMCLog.warn("Failed to rename " + moved + " to " + mvt);
|
}
|
||||||
return false;
|
|
||||||
}
|
Collection<Task> afters = new HashSet<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<Task> getAfterTasks() {
|
||||||
|
return afters;
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
-2
@@ -73,7 +73,7 @@ public class MojangDownloadProvider extends IDownloadProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getParsedLibraryDownloadURL(String str) {
|
public String getParsedDownloadURL(String str) {
|
||||||
if (str == null)
|
if (str == null)
|
||||||
return null;
|
return null;
|
||||||
else if (str.contains("scala-swing") || str.contains("scala-xml") || str.contains("scala-parser-combinators"))
|
else if (str.contains("scala-swing") || str.contains("scala-xml") || str.contains("scala-parser-combinators"))
|
||||||
@@ -86,5 +86,4 @@ public class MojangDownloadProvider extends IDownloadProvider {
|
|||||||
else
|
else
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+1
-1
@@ -49,7 +49,7 @@ public class RapidDataDownloadProvider extends MojangDownloadProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getParsedLibraryDownloadURL(String str) {
|
public String getParsedDownloadURL(String str) {
|
||||||
return str == null ? null : str.replace("http://files.minecraftforge.net/maven", "http://mirrors.rapiddata.org/forge/maven");
|
return str == null ? null : str.replace("http://files.minecraftforge.net/maven", "http://mirrors.rapiddata.org/forge/maven");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -64,7 +64,7 @@ public final class MinecraftInstallerService extends IMinecraftInstallerService
|
|||||||
File filepath = IOUtils.tryGetCanonicalFile(IOUtils.currentDirWithSeparator() + "forge-installer.jar");
|
File filepath = IOUtils.tryGetCanonicalFile(IOUtils.currentDirWithSeparator() + "forge-installer.jar");
|
||||||
if (v.installer != null)
|
if (v.installer != null)
|
||||||
TaskWindow.factory()
|
TaskWindow.factory()
|
||||||
.append(new FileDownloadTask(service.getDownloadType().getProvider().getParsedLibraryDownloadURL(v.installer), filepath).setTag("forge"))
|
.append(new FileDownloadTask(service.getDownloadType().getProvider().getParsedDownloadURL(v.installer), filepath).setTag("forge"))
|
||||||
.append(new ForgeInstaller(service, filepath))
|
.append(new ForgeInstaller(service, filepath))
|
||||||
.create();
|
.create();
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -51,7 +51,7 @@ public class MinecraftForgeVersionList extends InstallerVersionList {
|
|||||||
public void refreshList(String[] needed) throws Exception {
|
public void refreshList(String[] needed) throws Exception {
|
||||||
if (root != null)
|
if (root != null)
|
||||||
return;
|
return;
|
||||||
String s = NetUtils.get(DownloadType.getSuggestedDownloadType().getProvider().getParsedLibraryDownloadURL(C.URL_FORGE_LIST));
|
String s = NetUtils.get(DownloadType.getSuggestedDownloadType().getProvider().getParsedDownloadURL(C.URL_FORGE_LIST));
|
||||||
|
|
||||||
root = C.GSON.fromJson(s, MinecraftForgeVersionRoot.class);
|
root = C.GSON.fromJson(s, MinecraftForgeVersionRoot.class);
|
||||||
|
|
||||||
@@ -70,7 +70,7 @@ public class MinecraftForgeVersionList extends InstallerVersionList {
|
|||||||
if (!StrUtils.isBlank(v.branch))
|
if (!StrUtils.isBlank(v.branch))
|
||||||
ver = ver + "-" + v.branch;
|
ver = ver + "-" + v.branch;
|
||||||
String filename = root.artifact + "-" + ver + "-" + f[1] + "." + f[0];
|
String filename = root.artifact + "-" + ver + "-" + f[1] + "." + f[0];
|
||||||
String url = DownloadType.getSuggestedDownloadType().getProvider().getParsedLibraryDownloadURL(root.webpath + ver + "/" + filename);
|
String url = DownloadType.getSuggestedDownloadType().getProvider().getParsedDownloadURL(root.webpath + ver + "/" + filename);
|
||||||
switch (f[1]) {
|
switch (f[1]) {
|
||||||
case "installer":
|
case "installer":
|
||||||
iv.installer = url;
|
iv.installer = url;
|
||||||
|
|||||||
+6
-4
@@ -31,6 +31,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.zip.ZipFile;
|
import java.util.zip.ZipFile;
|
||||||
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import org.jackhuang.hellominecraft.util.C;
|
import org.jackhuang.hellominecraft.util.C;
|
||||||
import org.jackhuang.hellominecraft.util.logging.HMCLog;
|
import org.jackhuang.hellominecraft.util.logging.HMCLog;
|
||||||
@@ -46,6 +47,7 @@ import org.jackhuang.hellominecraft.util.system.ZipEngine;
|
|||||||
import org.jackhuang.hellominecraft.util.tasks.Task;
|
import org.jackhuang.hellominecraft.util.tasks.Task;
|
||||||
import org.jackhuang.hellominecraft.util.ui.WebPage;
|
import org.jackhuang.hellominecraft.util.ui.WebPage;
|
||||||
import org.jackhuang.hellominecraft.util.MinecraftVersionRequest;
|
import org.jackhuang.hellominecraft.util.MinecraftVersionRequest;
|
||||||
|
import org.jackhuang.hellominecraft.util.tasks.NoShownTaskException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A mod pack(*.zip) includes these things:
|
* A mod pack(*.zip) includes these things:
|
||||||
@@ -79,7 +81,7 @@ public final class ModpackManager {
|
|||||||
* @return The installing Task, may take long time, please consider
|
* @return The installing Task, may take long time, please consider
|
||||||
* TaskWindow.
|
* TaskWindow.
|
||||||
*/
|
*/
|
||||||
public static Task install(final File input, final IMinecraftService service, final String idFUCK) {
|
public static Task install(JFrame parFrame, final File input, final IMinecraftService service, final String idFUCK) {
|
||||||
return new Task() {
|
return new Task() {
|
||||||
Collection<Task> c = new ArrayList<>();
|
Collection<Task> c = new ArrayList<>();
|
||||||
|
|
||||||
@@ -109,9 +111,9 @@ public final class ModpackManager {
|
|||||||
msgs[0] = C.i18n("modpack.task.install");
|
msgs[0] = C.i18n("modpack.task.install");
|
||||||
msgs[1] = new WebPage(description);
|
msgs[1] = new WebPage(description);
|
||||||
((WebPage) msgs[1]).setPreferredSize(new Dimension(800, 350));
|
((WebPage) msgs[1]).setPreferredSize(new Dimension(800, 350));
|
||||||
int result = JOptionPane.showOptionDialog(null, msgs, (String) msgs[0], JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null);
|
int result = JOptionPane.showOptionDialog(parFrame, msgs, (String) msgs[0], JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null);
|
||||||
if (result == JOptionPane.NO_OPTION)
|
if (result == JOptionPane.NO_OPTION)
|
||||||
return;
|
throw new NoShownTaskException("Operation was canceled by user.");
|
||||||
|
|
||||||
File versions = new File(service.baseDirectory(), "versions");
|
File versions = new File(service.baseDirectory(), "versions");
|
||||||
|
|
||||||
@@ -166,7 +168,7 @@ public final class ModpackManager {
|
|||||||
if (mv.jar == null)
|
if (mv.jar == null)
|
||||||
throw new FileNotFoundException(C.i18n("modpack.incorrect_format.no_jar"));
|
throw new FileNotFoundException(C.i18n("modpack.incorrect_format.no_jar"));
|
||||||
|
|
||||||
c.add(service.download().downloadMinecraftJarTo(mv, new File(nowFile, id + ".jar")));
|
c.add(service.download().downloadMinecraftJar(mv, new File(nowFile, id + ".jar")));
|
||||||
mv.jar = null;
|
mv.jar = null;
|
||||||
FileUtils.writeStringToFile(json, C.GSON.toJson(mv));
|
FileUtils.writeStringToFile(json, C.GSON.toJson(mv));
|
||||||
if (!json.renameTo(new File(nowFile, id + ".json")))
|
if (!json.renameTo(new File(nowFile, id + ".json")))
|
||||||
|
|||||||
+2
-6
@@ -22,9 +22,7 @@ import java.util.List;
|
|||||||
import org.jackhuang.hellominecraft.launcher.core.GameException;
|
import org.jackhuang.hellominecraft.launcher.core.GameException;
|
||||||
import org.jackhuang.hellominecraft.launcher.core.download.DownloadLibraryJob;
|
import org.jackhuang.hellominecraft.launcher.core.download.DownloadLibraryJob;
|
||||||
import org.jackhuang.hellominecraft.launcher.core.version.MinecraftVersion;
|
import org.jackhuang.hellominecraft.launcher.core.version.MinecraftVersion;
|
||||||
import org.jackhuang.hellominecraft.util.OverridableSwingWorker;
|
|
||||||
import org.jackhuang.hellominecraft.util.tasks.Task;
|
import org.jackhuang.hellominecraft.util.tasks.Task;
|
||||||
import org.jackhuang.hellominecraft.launcher.core.download.MinecraftRemoteVersion;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -38,11 +36,9 @@ public abstract class IMinecraftDownloadService extends IMinecraftBasicService {
|
|||||||
|
|
||||||
public abstract Task downloadMinecraft(String id);
|
public abstract Task downloadMinecraft(String id);
|
||||||
|
|
||||||
public abstract boolean downloadMinecraftJar(String id);
|
public abstract Task downloadMinecraftJar(MinecraftVersion mv, File f);
|
||||||
|
|
||||||
public abstract Task downloadMinecraftJarTo(MinecraftVersion mv, File f);
|
public abstract Task downloadMinecraftVersionJson(String id);
|
||||||
|
|
||||||
public abstract boolean downloadMinecraftVersionJson(String id);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the libraries that need to download.
|
* Get the libraries that need to download.
|
||||||
|
|||||||
+2
-5
@@ -36,11 +36,8 @@ public class AssetIndexDownloadInfo extends GameDownloadInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUrl(DownloadType dt, boolean allowSelf) {
|
public String getCustomizedURL(DownloadType dt) {
|
||||||
if (url != null && dt.getProvider().isAllowedToUseSelfURL())
|
return dt.getProvider().getIndexesDownloadURL() + id + ".json";
|
||||||
return url;
|
|
||||||
else
|
|
||||||
return dt.getProvider().getIndexesDownloadURL() + id + ".json";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
|
|||||||
+6
-2
@@ -55,9 +55,13 @@ public class GameDownloadInfo implements Cloneable {
|
|||||||
*/
|
*/
|
||||||
public String getUrl(DownloadType dt, boolean allowSelf) {
|
public String getUrl(DownloadType dt, boolean allowSelf) {
|
||||||
if (url != null && allowSelf)
|
if (url != null && allowSelf)
|
||||||
return url;
|
return dt.getProvider().getParsedDownloadURL(url);
|
||||||
else
|
else
|
||||||
return dt.getProvider().getVersionsDownloadURL() + id + "/" + id + ".jar";
|
return getCustomizedURL(dt);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected String getCustomizedURL(DownloadType dt) {
|
||||||
|
return dt.getProvider().getVersionsDownloadURL() + id + "/" + id + ".jar";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+29
-32
@@ -388,43 +388,40 @@
|
|||||||
<Layout>
|
<Layout>
|
||||||
<DimensionLayout dim="0">
|
<DimensionLayout dim="0">
|
||||||
<Group type="103" groupAlignment="0" attributes="0">
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
<Group type="103" alignment="0" groupAlignment="0" attributes="0">
|
<Group type="102" attributes="0">
|
||||||
<Group type="102" attributes="0">
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
<Group type="103" groupAlignment="0" attributes="0">
|
<Component id="txtWrapperLauncher" alignment="0" max="32767" attributes="0"/>
|
||||||
<Component id="txtWrapperLauncher" alignment="0" max="32767" attributes="0"/>
|
<Group type="102" alignment="0" attributes="0">
|
||||||
<Group type="102" alignment="0" attributes="0">
|
<Component id="lblPrecalledCommand1" min="-2" max="-2" attributes="0"/>
|
||||||
<Component id="lblPrecalledCommand1" min="-2" max="-2" attributes="0"/>
|
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
|
||||||
</Group>
|
|
||||||
</Group>
|
</Group>
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
|
||||||
</Group>
|
</Group>
|
||||||
<Component id="txtPrecalledCommand" alignment="0" max="32767" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
<Component id="txtServerIP" alignment="0" max="32767" attributes="0"/>
|
</Group>
|
||||||
<Group type="102" attributes="0">
|
<Component id="txtPrecalledCommand" alignment="0" max="32767" attributes="0"/>
|
||||||
<Group type="103" groupAlignment="0" attributes="0">
|
<Component id="txtServerIP" alignment="0" max="32767" attributes="0"/>
|
||||||
<Component id="lblPrecalledCommand" alignment="0" min="-2" max="-2" attributes="0"/>
|
<Group type="102" alignment="1" attributes="0">
|
||||||
<Component id="lblServerIP" alignment="0" min="-2" max="-2" attributes="0"/>
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
</Group>
|
<Component id="lblMinecraftArgs" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||||
<EmptySpace min="0" pref="716" max="32767" attributes="0"/>
|
<Component id="lblPermSize" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||||
|
<Component id="lblJavaArgs" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
<Group type="102" alignment="1" attributes="0">
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
<Group type="103" groupAlignment="0" attributes="0">
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
<Component id="lblMinecraftArgs" alignment="0" min="-2" max="-2" attributes="0"/>
|
<Component id="txtJavaArgs" pref="664" max="32767" attributes="0"/>
|
||||||
<Component id="lblPermSize" alignment="0" min="-2" max="-2" attributes="0"/>
|
<Component id="txtMinecraftArgs" max="32767" attributes="0"/>
|
||||||
<Component id="lblJavaArgs" alignment="0" min="-2" max="-2" attributes="0"/>
|
<Component id="txtPermSize" alignment="1" max="32767" attributes="0"/>
|
||||||
</Group>
|
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
|
||||||
<Group type="103" groupAlignment="0" attributes="0">
|
|
||||||
<Component id="txtJavaArgs" max="32767" attributes="0"/>
|
|
||||||
<Component id="txtMinecraftArgs" max="32767" attributes="0"/>
|
|
||||||
<Component id="txtPermSize" alignment="1" max="32767" attributes="0"/>
|
|
||||||
</Group>
|
|
||||||
</Group>
|
</Group>
|
||||||
</Group>
|
</Group>
|
||||||
<Group type="102" alignment="0" attributes="0">
|
<Group type="102" attributes="0">
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
<Component id="chkNoJVMArgs" min="-2" max="-2" attributes="0"/>
|
<Component id="lblPrecalledCommand" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||||
|
<Component id="lblServerIP" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||||
|
<Group type="102" alignment="0" attributes="0">
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
<Component id="chkNoJVMArgs" min="-2" max="-2" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
</Group>
|
||||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
</Group>
|
</Group>
|
||||||
|
|||||||
@@ -1376,10 +1376,12 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
|
|||||||
final Runnable onLoadingProfiles = this::loadProfiles;
|
final Runnable onLoadingProfiles = this::loadProfiles;
|
||||||
|
|
||||||
private void loadProfiles() {
|
private void loadProfiles() {
|
||||||
|
isLoading = true;
|
||||||
DefaultComboBoxModel model = new DefaultComboBoxModel();
|
DefaultComboBoxModel model = new DefaultComboBoxModel();
|
||||||
for (Profile s : Settings.getProfilesFiltered())
|
for (Profile s : Settings.getProfilesFiltered())
|
||||||
model.addElement(s.getName());
|
model.addElement(s.getName());
|
||||||
cboProfiles.setModel(model);
|
cboProfiles.setModel(model);
|
||||||
|
isLoading = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Consumer<IMinecraftService> onRefreshedVersions = t -> {
|
final Consumer<IMinecraftService> onRefreshedVersions = t -> {
|
||||||
@@ -1425,12 +1427,15 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
|
|||||||
t.selectedVersionChangedEvent.register(selectedVersionChangedEvent);
|
t.selectedVersionChangedEvent.register(selectedVersionChangedEvent);
|
||||||
|
|
||||||
txtGameDir.setText(t.getGameDir());
|
txtGameDir.setText(t.getGameDir());
|
||||||
|
|
||||||
|
isLoading = true;
|
||||||
DefaultComboBoxModel model = (DefaultComboBoxModel) cboProfiles.getModel();
|
DefaultComboBoxModel model = (DefaultComboBoxModel) cboProfiles.getModel();
|
||||||
for (int i = 0; i < model.getSize(); ++i)
|
for (int i = 0; i < model.getSize(); ++i)
|
||||||
if (model.getElementAt(i).equals(t.getName())) {
|
if (model.getElementAt(i).equals(t.getName())) {
|
||||||
model.setSelectedItem(t.getName());
|
model.setSelectedItem(t.getName());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
isLoading = false;
|
||||||
};
|
};
|
||||||
//</editor-fold>
|
//</editor-fold>
|
||||||
}
|
}
|
||||||
@@ -37,6 +37,7 @@ import org.jackhuang.hellominecraft.launcher.setting.Settings;
|
|||||||
import org.jackhuang.hellominecraft.launcher.core.mod.ModpackManager;
|
import org.jackhuang.hellominecraft.launcher.core.mod.ModpackManager;
|
||||||
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftService;
|
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftService;
|
||||||
import org.jackhuang.hellominecraft.launcher.ui.modpack.ModpackWizard;
|
import org.jackhuang.hellominecraft.launcher.ui.modpack.ModpackWizard;
|
||||||
|
import org.jackhuang.hellominecraft.launcher.util.HMCLMinecraftService;
|
||||||
import org.jackhuang.hellominecraft.util.ui.GraphicsUtils;
|
import org.jackhuang.hellominecraft.util.ui.GraphicsUtils;
|
||||||
import org.jackhuang.hellominecraft.util.Event;
|
import org.jackhuang.hellominecraft.util.Event;
|
||||||
import org.jackhuang.hellominecraft.lookandfeel.comp.ConstomButton;
|
import org.jackhuang.hellominecraft.lookandfeel.comp.ConstomButton;
|
||||||
@@ -382,7 +383,7 @@ public class MainPagePanel extends AnimatedPanel {
|
|||||||
if (fc.getSelectedFile() == null)
|
if (fc.getSelectedFile() == null)
|
||||||
return;
|
return;
|
||||||
String suggestedModpackId = JOptionPane.showInputDialog("Please enter your favourite game name", FileUtils.getBaseName(fc.getSelectedFile().getName()));
|
String suggestedModpackId = JOptionPane.showInputDialog("Please enter your favourite game name", FileUtils.getBaseName(fc.getSelectedFile().getName()));
|
||||||
TaskWindow.factory().append(ModpackManager.install(fc.getSelectedFile(), Settings.getLastProfile().service(), suggestedModpackId)).create();
|
TaskWindow.factory().append(ModpackManager.install(MainFrame.INSTANCE, fc.getSelectedFile(), Settings.getLastProfile().service(), suggestedModpackId)).create();
|
||||||
Settings.getLastProfile().service().version().refreshVersions();
|
Settings.getLastProfile().service().version().refreshVersions();
|
||||||
}//GEN-LAST:event_btnImportModpackActionPerformed
|
}//GEN-LAST:event_btnImportModpackActionPerformed
|
||||||
|
|
||||||
@@ -471,10 +472,12 @@ public class MainPagePanel extends AnimatedPanel {
|
|||||||
final Runnable onLoadingProfiles = this::loadProfiles;
|
final Runnable onLoadingProfiles = this::loadProfiles;
|
||||||
|
|
||||||
private void loadProfiles() {
|
private void loadProfiles() {
|
||||||
|
isLoading = true;
|
||||||
DefaultComboBoxModel model = new DefaultComboBoxModel();
|
DefaultComboBoxModel model = new DefaultComboBoxModel();
|
||||||
for (Profile s : Settings.getProfilesFiltered())
|
for (Profile s : Settings.getProfilesFiltered())
|
||||||
model.addElement(s.getName());
|
model.addElement(s.getName());
|
||||||
cboProfiles.setModel(model);
|
cboProfiles.setModel(model);
|
||||||
|
isLoading = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Consumer<IMinecraftService> onRefreshedVersions = t -> {
|
final Consumer<IMinecraftService> onRefreshedVersions = t -> {
|
||||||
@@ -489,7 +492,7 @@ public class MainPagePanel extends AnimatedPanel {
|
|||||||
cboVersions.removeAllItems();
|
cboVersions.removeAllItems();
|
||||||
String selVersion = Settings.getLastProfile().getSelectedVersion();
|
String selVersion = Settings.getLastProfile().getSelectedVersion();
|
||||||
if (Settings.getLastProfile().service().version().getVersions().isEmpty()) {
|
if (Settings.getLastProfile().service().version().getVersions().isEmpty()) {
|
||||||
if (!showedNoVersion) {
|
if (!showedNoVersion && ((HMCLMinecraftService) Settings.getLastProfile().service()).checkedModpack) {
|
||||||
showedNoVersion = true;
|
showedNoVersion = true;
|
||||||
SwingUtilities.invokeLater(() -> {
|
SwingUtilities.invokeLater(() -> {
|
||||||
if (MessageBox.Show(C.i18n("mainwindow.no_version"), MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION)
|
if (MessageBox.Show(C.i18n("mainwindow.no_version"), MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION)
|
||||||
@@ -528,11 +531,13 @@ public class MainPagePanel extends AnimatedPanel {
|
|||||||
t.selectedVersionChangedEvent.register(versionChanged);
|
t.selectedVersionChangedEvent.register(versionChanged);
|
||||||
t.launcher().launchingStateChanged.register(launchingStateChanged);
|
t.launcher().launchingStateChanged.register(launchingStateChanged);
|
||||||
|
|
||||||
|
isLoading = true;
|
||||||
DefaultComboBoxModel model = (DefaultComboBoxModel) cboProfiles.getModel();
|
DefaultComboBoxModel model = (DefaultComboBoxModel) cboProfiles.getModel();
|
||||||
for (int i = 0; i < model.getSize(); ++i)
|
for (int i = 0; i < model.getSize(); ++i)
|
||||||
if (model.getElementAt(i).equals(t.getName())) {
|
if (model.getElementAt(i).equals(t.getName())) {
|
||||||
model.setSelectedItem(t.getName());
|
model.setSelectedItem(t.getName());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
isLoading = false;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
+14
-11
@@ -21,6 +21,7 @@ import com.google.gson.JsonSyntaxException;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import javax.swing.SwingUtilities;
|
||||||
import org.jackhuang.hellominecraft.launcher.core.GameException;
|
import org.jackhuang.hellominecraft.launcher.core.GameException;
|
||||||
import org.jackhuang.hellominecraft.launcher.core.install.MinecraftInstallerService;
|
import org.jackhuang.hellominecraft.launcher.core.install.MinecraftInstallerService;
|
||||||
import org.jackhuang.hellominecraft.launcher.core.asset.MinecraftAssetService;
|
import org.jackhuang.hellominecraft.launcher.core.asset.MinecraftAssetService;
|
||||||
@@ -39,6 +40,7 @@ import org.jackhuang.hellominecraft.launcher.core.mod.MinecraftModService;
|
|||||||
import org.jackhuang.hellominecraft.launcher.core.mod.ModpackManager;
|
import org.jackhuang.hellominecraft.launcher.core.mod.ModpackManager;
|
||||||
import org.jackhuang.hellominecraft.launcher.setting.Profile;
|
import org.jackhuang.hellominecraft.launcher.setting.Profile;
|
||||||
import org.jackhuang.hellominecraft.launcher.setting.VersionSetting;
|
import org.jackhuang.hellominecraft.launcher.setting.VersionSetting;
|
||||||
|
import org.jackhuang.hellominecraft.launcher.ui.MainFrame;
|
||||||
import org.jackhuang.hellominecraft.util.C;
|
import org.jackhuang.hellominecraft.util.C;
|
||||||
import org.jackhuang.hellominecraft.util.logging.HMCLog;
|
import org.jackhuang.hellominecraft.util.logging.HMCLog;
|
||||||
import org.jackhuang.hellominecraft.util.system.FileUtils;
|
import org.jackhuang.hellominecraft.util.system.FileUtils;
|
||||||
@@ -66,18 +68,19 @@ public class HMCLMinecraftService extends IMinecraftService {
|
|||||||
this.mis = new MinecraftInstallerService(this);
|
this.mis = new MinecraftInstallerService(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean checkedModpack = false, checkingModpack = false;
|
||||||
|
|
||||||
private void checkModpack() {
|
private void checkModpack() {
|
||||||
int show = 0;
|
if (!checkingModpack) {
|
||||||
for (StackTraceElement e : Thread.currentThread().getStackTrace())
|
checkingModpack = true;
|
||||||
if ("checkModpack".equals(e.getMethodName()))
|
if (version().getVersionCount() == 0) {
|
||||||
++show;
|
File modpack = new File("modpack.zip");
|
||||||
if (show > 2)
|
if (modpack.exists())
|
||||||
return;
|
SwingUtilities.invokeLater(() -> {
|
||||||
if (version().getVersionCount() == 0) {
|
if (TaskWindow.execute(ModpackManager.install(MainFrame.INSTANCE, modpack, this, null)))
|
||||||
File modpack = new File("modpack.zip");
|
version().refreshVersions();
|
||||||
if (modpack.exists()) {
|
checkedModpack = true;
|
||||||
TaskWindow.factory().append(ModpackManager.install(modpack, this, null)).create();
|
});
|
||||||
version().refreshVersions();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+29
@@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* Hello Minecraft! Launcher.
|
||||||
|
* Copyright (C) 2013 huangyuhui <[email protected]>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see {http://www.gnu.org/licenses/}.
|
||||||
|
*/
|
||||||
|
package org.jackhuang.hellominecraft.util.tasks;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author huangyuhui
|
||||||
|
*/
|
||||||
|
public class NoShownTaskException extends RuntimeException {
|
||||||
|
|
||||||
|
public NoShownTaskException(String msg) {
|
||||||
|
super(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -24,7 +24,7 @@ import java.util.HashMap;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.concurrent.CountDownLatch;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
@@ -72,12 +72,12 @@ public class TaskList extends Thread {
|
|||||||
private class Invoker implements Runnable {
|
private class Invoker implements Runnable {
|
||||||
|
|
||||||
Task task;
|
Task task;
|
||||||
Set<Invoker> s;
|
CountDownLatch latch;
|
||||||
AtomicBoolean bool;
|
AtomicBoolean bool;
|
||||||
|
|
||||||
public Invoker(Task task, Set<Invoker> ss, AtomicBoolean bool) {
|
public Invoker(Task task, CountDownLatch latch, AtomicBoolean bool) {
|
||||||
this.task = task;
|
this.task = task;
|
||||||
s = ss;
|
this.latch = latch;
|
||||||
this.bool = bool;
|
this.bool = bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,7 +85,7 @@ public class TaskList extends Thread {
|
|||||||
public void run() {
|
public void run() {
|
||||||
if (!executeTask(task))
|
if (!executeTask(task))
|
||||||
bool.set(false);
|
bool.set(false);
|
||||||
s.remove(this);
|
latch.countDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -99,22 +99,18 @@ public class TaskList extends Thread {
|
|||||||
return true;
|
return true;
|
||||||
this.totTask += c.size();
|
this.totTask += c.size();
|
||||||
AtomicBoolean bool = new AtomicBoolean(true);
|
AtomicBoolean bool = new AtomicBoolean(true);
|
||||||
Set<Invoker> runningThread = Collections.synchronizedSet(new HashSet<Invoker>());
|
CountDownLatch counter = new CountDownLatch(c.size());
|
||||||
for (Task t2 : c) {
|
for (Task t2 : c) {
|
||||||
t2.setParallelExecuting(true);
|
t2.setParallelExecuting(true);
|
||||||
Invoker thread = new Invoker(t2, runningThread, bool);
|
Invoker thread = new Invoker(t2, counter, bool);
|
||||||
runningThread.add(thread);
|
|
||||||
invokers.add(thread);
|
invokers.add(thread);
|
||||||
if (!EXECUTOR_SERVICE.isShutdown() && !EXECUTOR_SERVICE.isTerminated())
|
if (!EXECUTOR_SERVICE.isShutdown() && !EXECUTOR_SERVICE.isTerminated())
|
||||||
futures.put(thread, EXECUTOR_SERVICE.submit(thread));
|
futures.put(thread, EXECUTOR_SERVICE.submit(thread));
|
||||||
}
|
}
|
||||||
while (!runningThread.isEmpty())
|
try {
|
||||||
try {
|
counter.await();
|
||||||
if (this.isInterrupted())
|
} catch (InterruptedException ignore) {
|
||||||
return false;
|
}
|
||||||
Thread.sleep(1);
|
|
||||||
} catch (InterruptedException ignore) {
|
|
||||||
}
|
|
||||||
return bool.get();
|
return bool.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -225,9 +225,11 @@ public class TaskWindow extends javax.swing.JDialog
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
SwingUtilities.invokeLater(this::dispose);
|
SwingUtilities.invokeLater(() -> {
|
||||||
suc = true;
|
dispose();
|
||||||
HMCLog.log("Tasks are finished.");
|
suc = true;
|
||||||
|
HMCLog.log("Tasks are finished.");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -271,7 +273,14 @@ public class TaskWindow extends javax.swing.JDialog
|
|||||||
SwingUtilities.invokeLater(() -> {
|
SwingUtilities.invokeLater(() -> {
|
||||||
if (taskList == null || task == null)
|
if (taskList == null || task == null)
|
||||||
return;
|
return;
|
||||||
failReasons.add(task.getInfo() + ": " + (null == task.getFailReason() ? "No exception" : (StrUtils.isBlank(task.getFailReason().getLocalizedMessage()) ? task.getFailReason().getClass().getSimpleName() : task.getFailReason().getLocalizedMessage())));
|
String msg = null;
|
||||||
|
if (task.getFailReason() != null && !(task.getFailReason() instanceof NoShownTaskException))
|
||||||
|
if (StrUtils.isBlank(task.getFailReason().getLocalizedMessage()))
|
||||||
|
msg = task.getFailReason().getClass().getSimpleName();
|
||||||
|
else
|
||||||
|
msg = task.getFailReason().getLocalizedMessage();
|
||||||
|
if (msg != null)
|
||||||
|
failReasons.add(task.getInfo() + ": " + msg);
|
||||||
pgsTotal.setMaximum(taskList.taskCount());
|
pgsTotal.setMaximum(taskList.taskCount());
|
||||||
pgsTotal.setValue(pgsTotal.getValue() + 1);
|
pgsTotal.setValue(pgsTotal.getValue() + 1);
|
||||||
int idx = tasks.indexOf(task);
|
int idx = tasks.indexOf(task);
|
||||||
|
|||||||
+1
-1
@@ -30,7 +30,7 @@ if (buildnumber == null)
|
|||||||
|
|
||||||
def versionroot = System.getenv("VERSION_ROOT")
|
def versionroot = System.getenv("VERSION_ROOT")
|
||||||
if (versionroot == null)
|
if (versionroot == null)
|
||||||
versionroot = "0.8.6"
|
versionroot = "0.8.7"
|
||||||
|
|
||||||
String mavenGroupId = 'HMCSM'
|
String mavenGroupId = 'HMCSM'
|
||||||
String mavenVersion = versionroot + '.' + buildnumber
|
String mavenVersion = versionroot + '.' + buildnumber
|
||||||
|
|||||||
Reference in new issue
Block a user