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
|
||||
public String getVersionsListDownloadURL() {
|
||||
return "http://bmclapi2.bangbang93.com/versions/versions.json";
|
||||
return "http://bmclapi2.bangbang93.com/mc/game/version_manifest.json";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -66,13 +66,17 @@ public class BMCLAPIDownloadProvider extends IDownloadProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getParsedLibraryDownloadURL(String str) {
|
||||
return str == null ? null : str.replace("http://files.minecraftforge.net/maven", "http://bmclapi2.bangbang93.com/maven");
|
||||
public String getParsedDownloadURL(String str) {
|
||||
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
|
||||
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 {
|
||||
|
||||
@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/");
|
||||
}
|
||||
|
||||
|
||||
+9
-1
@@ -55,7 +55,15 @@ public abstract class IDownloadProvider {
|
||||
|
||||
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();
|
||||
}
|
||||
+54
-104
@@ -21,6 +21,7 @@ import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftDownloadServ
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
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.IMinecraftLibrary;
|
||||
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.func.Function;
|
||||
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.TaskInfo;
|
||||
|
||||
@@ -60,7 +59,7 @@ public class MinecraftDownloadService extends IMinecraftDownloadService {
|
||||
if (l.allow()) {
|
||||
File ff = l.getFilePath(service.baseDirectory());
|
||||
if (!ff.exists()) {
|
||||
String libURL = service.getDownloadType().getProvider().getParsedLibraryDownloadURL(l.getDownloadInfo().getUrl(service.getDownloadType()));
|
||||
String libURL = l.getDownloadInfo().getUrl(service.getDownloadType());
|
||||
if (libURL != null)
|
||||
downloadLibraries.add(new DownloadLibraryJob(l, libURL, ff));
|
||||
}
|
||||
@@ -71,58 +70,31 @@ public class MinecraftDownloadService extends IMinecraftDownloadService {
|
||||
@Override
|
||||
public Task downloadMinecraft(String id) {
|
||||
return new TaskInfo("Download Minecraft") {
|
||||
@Override
|
||||
public Collection<Task> getDependTasks() {
|
||||
return Arrays.asList(downloadMinecraftVersionJson(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
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 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");
|
||||
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())
|
||||
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");
|
||||
t.addTaskListener(new DoingDoneListener<Task>() {
|
||||
@Override
|
||||
public void onDone(Task k, Collection<Task> taskCollection) {
|
||||
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);
|
||||
afters.add(downloadMinecraftJar(mv, mvj));
|
||||
} catch (JsonSyntaxException ex) {
|
||||
HMCLog.err("Failed to parse minecraft version json.", ex);
|
||||
FileUtils.deleteDirectory(vpath);
|
||||
}
|
||||
}
|
||||
|
||||
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> {
|
||||
|
||||
String suffix;
|
||||
@@ -178,37 +122,43 @@ public class MinecraftDownloadService extends IMinecraftDownloadService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Task downloadMinecraftJarTo(MinecraftVersion mv, File mvt) {
|
||||
String jar = mv.jar == null ? mv.id : mv.jar;
|
||||
public Task downloadMinecraftJar(MinecraftVersion mv, File mvj) {
|
||||
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
|
||||
public boolean downloadMinecraftVersionJson(String id) {
|
||||
String vurl = service.getDownloadType().getProvider().getVersionsDownloadURL() + id + "/";
|
||||
File vpath = new File(service.baseDirectory(), "versions/" + id);
|
||||
File mvv = new File(vpath, id + ".json"), moved = null;
|
||||
if (mvv.exists()) {
|
||||
moved = new File(vpath, id + "-renamed.json");
|
||||
if (!mvv.renameTo(moved))
|
||||
HMCLog.warn("Failed to rename " + mvv + " to " + moved);
|
||||
}
|
||||
File mvt = new File(vpath, id + ".json");
|
||||
if (!vpath.exists() && !vpath.mkdirs())
|
||||
HMCLog.warn("Failed to make version folder " + vpath);
|
||||
if (TaskWindow.factory()
|
||||
.append(new FileDownloadTask(vurl + id + ".json", mvt).setTag(id + ".json"))
|
||||
.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 minecraft version json" + mvt);
|
||||
if (moved != null && moved.exists() && !moved.renameTo(mvt))
|
||||
HMCLog.warn("Failed to rename " + moved + " to " + mvt);
|
||||
return false;
|
||||
}
|
||||
public Task downloadMinecraftVersionJson(String id) {
|
||||
return new TaskInfo("Download Minecraft Json") {
|
||||
@Override
|
||||
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 mvt = new File(vpath, id + ".json");
|
||||
if (!vpath.exists() && !vpath.mkdirs())
|
||||
HMCLog.warn("Failed to make directories: " + vpath);
|
||||
if (mvt.exists() && !mvt.delete())
|
||||
HMCLog.warn("Failed to delete " + mvt);
|
||||
|
||||
afters.add(new FileDownloadTask(jsonURL, mvt).setTag(id + ".json"));
|
||||
}
|
||||
|
||||
Collection<Task> afters = new HashSet<>();
|
||||
|
||||
@Override
|
||||
public Collection<Task> getAfterTasks() {
|
||||
return afters;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
+1
-2
@@ -73,7 +73,7 @@ public class MojangDownloadProvider extends IDownloadProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getParsedLibraryDownloadURL(String str) {
|
||||
public String getParsedDownloadURL(String str) {
|
||||
if (str == null)
|
||||
return null;
|
||||
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
|
||||
return str;
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -49,7 +49,7 @@ public class RapidDataDownloadProvider extends MojangDownloadProvider {
|
||||
}
|
||||
|
||||
@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");
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -64,7 +64,7 @@ public final class MinecraftInstallerService extends IMinecraftInstallerService
|
||||
File filepath = IOUtils.tryGetCanonicalFile(IOUtils.currentDirWithSeparator() + "forge-installer.jar");
|
||||
if (v.installer != null)
|
||||
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))
|
||||
.create();
|
||||
}
|
||||
|
||||
+2
-2
@@ -51,7 +51,7 @@ public class MinecraftForgeVersionList extends InstallerVersionList {
|
||||
public void refreshList(String[] needed) throws Exception {
|
||||
if (root != null)
|
||||
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);
|
||||
|
||||
@@ -70,7 +70,7 @@ public class MinecraftForgeVersionList extends InstallerVersionList {
|
||||
if (!StrUtils.isBlank(v.branch))
|
||||
ver = ver + "-" + v.branch;
|
||||
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]) {
|
||||
case "installer":
|
||||
iv.installer = url;
|
||||
|
||||
+6
-4
@@ -31,6 +31,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.zip.ZipFile;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JOptionPane;
|
||||
import org.jackhuang.hellominecraft.util.C;
|
||||
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.ui.WebPage;
|
||||
import org.jackhuang.hellominecraft.util.MinecraftVersionRequest;
|
||||
import org.jackhuang.hellominecraft.util.tasks.NoShownTaskException;
|
||||
|
||||
/**
|
||||
* 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
|
||||
* 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() {
|
||||
Collection<Task> c = new ArrayList<>();
|
||||
|
||||
@@ -109,9 +111,9 @@ public final class ModpackManager {
|
||||
msgs[0] = C.i18n("modpack.task.install");
|
||||
msgs[1] = new WebPage(description);
|
||||
((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)
|
||||
return;
|
||||
throw new NoShownTaskException("Operation was canceled by user.");
|
||||
|
||||
File versions = new File(service.baseDirectory(), "versions");
|
||||
|
||||
@@ -166,7 +168,7 @@ public final class ModpackManager {
|
||||
if (mv.jar == null)
|
||||
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;
|
||||
FileUtils.writeStringToFile(json, C.GSON.toJson(mv));
|
||||
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.download.DownloadLibraryJob;
|
||||
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.launcher.core.download.MinecraftRemoteVersion;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -38,11 +36,9 @@ public abstract class IMinecraftDownloadService extends IMinecraftBasicService {
|
||||
|
||||
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 boolean downloadMinecraftVersionJson(String id);
|
||||
public abstract Task downloadMinecraftVersionJson(String id);
|
||||
|
||||
/**
|
||||
* Get the libraries that need to download.
|
||||
|
||||
+2
-5
@@ -36,11 +36,8 @@ public class AssetIndexDownloadInfo extends GameDownloadInfo {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUrl(DownloadType dt, boolean allowSelf) {
|
||||
if (url != null && dt.getProvider().isAllowedToUseSelfURL())
|
||||
return url;
|
||||
else
|
||||
return dt.getProvider().getIndexesDownloadURL() + id + ".json";
|
||||
public String getCustomizedURL(DownloadType dt) {
|
||||
return dt.getProvider().getIndexesDownloadURL() + id + ".json";
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
|
||||
+6
-2
@@ -55,9 +55,13 @@ public class GameDownloadInfo implements Cloneable {
|
||||
*/
|
||||
public String getUrl(DownloadType dt, boolean allowSelf) {
|
||||
if (url != null && allowSelf)
|
||||
return url;
|
||||
return dt.getProvider().getParsedDownloadURL(url);
|
||||
else
|
||||
return dt.getProvider().getVersionsDownloadURL() + id + "/" + id + ".jar";
|
||||
return getCustomizedURL(dt);
|
||||
}
|
||||
|
||||
protected String getCustomizedURL(DownloadType dt) {
|
||||
return dt.getProvider().getVersionsDownloadURL() + id + "/" + id + ".jar";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+29
-32
@@ -388,43 +388,40 @@
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="103" alignment="0" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="txtWrapperLauncher" alignment="0" max="32767" attributes="0"/>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="lblPrecalledCommand1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="txtWrapperLauncher" alignment="0" max="32767" attributes="0"/>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="lblPrecalledCommand1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="txtPrecalledCommand" alignment="0" max="32767" attributes="0"/>
|
||||
<Component id="txtServerIP" alignment="0" max="32767" attributes="0"/>
|
||||
<Group type="102" attributes="0">
|
||||
<Group type="103" groupAlignment="0" 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>
|
||||
<EmptySpace min="0" pref="716" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="txtPrecalledCommand" alignment="0" max="32767" attributes="0"/>
|
||||
<Component id="txtServerIP" alignment="0" max="32767" attributes="0"/>
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="lblMinecraftArgs" alignment="0" min="-2" max="-2" 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 type="102" alignment="1" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="lblMinecraftArgs" alignment="0" min="-2" max="-2" 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>
|
||||
<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>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="txtJavaArgs" pref="664" max="32767" attributes="0"/>
|
||||
<Component id="txtMinecraftArgs" max="32767" attributes="0"/>
|
||||
<Component id="txtPermSize" alignment="1" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="chkNoJVMArgs" min="-2" max="-2" attributes="0"/>
|
||||
<Group type="102" attributes="0">
|
||||
<Group type="103" groupAlignment="0" 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"/>
|
||||
</Group>
|
||||
</Group>
|
||||
|
||||
@@ -1376,10 +1376,12 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
|
||||
final Runnable onLoadingProfiles = this::loadProfiles;
|
||||
|
||||
private void loadProfiles() {
|
||||
isLoading = true;
|
||||
DefaultComboBoxModel model = new DefaultComboBoxModel();
|
||||
for (Profile s : Settings.getProfilesFiltered())
|
||||
model.addElement(s.getName());
|
||||
cboProfiles.setModel(model);
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
final Consumer<IMinecraftService> onRefreshedVersions = t -> {
|
||||
@@ -1425,12 +1427,15 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
|
||||
t.selectedVersionChangedEvent.register(selectedVersionChangedEvent);
|
||||
|
||||
txtGameDir.setText(t.getGameDir());
|
||||
|
||||
isLoading = true;
|
||||
DefaultComboBoxModel model = (DefaultComboBoxModel) cboProfiles.getModel();
|
||||
for (int i = 0; i < model.getSize(); ++i)
|
||||
if (model.getElementAt(i).equals(t.getName())) {
|
||||
model.setSelectedItem(t.getName());
|
||||
break;
|
||||
}
|
||||
isLoading = false;
|
||||
};
|
||||
//</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.service.IMinecraftService;
|
||||
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.Event;
|
||||
import org.jackhuang.hellominecraft.lookandfeel.comp.ConstomButton;
|
||||
@@ -382,7 +383,7 @@ public class MainPagePanel extends AnimatedPanel {
|
||||
if (fc.getSelectedFile() == null)
|
||||
return;
|
||||
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();
|
||||
}//GEN-LAST:event_btnImportModpackActionPerformed
|
||||
|
||||
@@ -471,10 +472,12 @@ public class MainPagePanel extends AnimatedPanel {
|
||||
final Runnable onLoadingProfiles = this::loadProfiles;
|
||||
|
||||
private void loadProfiles() {
|
||||
isLoading = true;
|
||||
DefaultComboBoxModel model = new DefaultComboBoxModel();
|
||||
for (Profile s : Settings.getProfilesFiltered())
|
||||
model.addElement(s.getName());
|
||||
cboProfiles.setModel(model);
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
final Consumer<IMinecraftService> onRefreshedVersions = t -> {
|
||||
@@ -489,7 +492,7 @@ public class MainPagePanel extends AnimatedPanel {
|
||||
cboVersions.removeAllItems();
|
||||
String selVersion = Settings.getLastProfile().getSelectedVersion();
|
||||
if (Settings.getLastProfile().service().version().getVersions().isEmpty()) {
|
||||
if (!showedNoVersion) {
|
||||
if (!showedNoVersion && ((HMCLMinecraftService) Settings.getLastProfile().service()).checkedModpack) {
|
||||
showedNoVersion = true;
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
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.launcher().launchingStateChanged.register(launchingStateChanged);
|
||||
|
||||
isLoading = true;
|
||||
DefaultComboBoxModel model = (DefaultComboBoxModel) cboProfiles.getModel();
|
||||
for (int i = 0; i < model.getSize(); ++i)
|
||||
if (model.getElementAt(i).equals(t.getName())) {
|
||||
model.setSelectedItem(t.getName());
|
||||
break;
|
||||
}
|
||||
isLoading = false;
|
||||
};
|
||||
}
|
||||
+14
-11
@@ -21,6 +21,7 @@ import com.google.gson.JsonSyntaxException;
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javax.swing.SwingUtilities;
|
||||
import org.jackhuang.hellominecraft.launcher.core.GameException;
|
||||
import org.jackhuang.hellominecraft.launcher.core.install.MinecraftInstallerService;
|
||||
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.setting.Profile;
|
||||
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.logging.HMCLog;
|
||||
import org.jackhuang.hellominecraft.util.system.FileUtils;
|
||||
@@ -66,18 +68,19 @@ public class HMCLMinecraftService extends IMinecraftService {
|
||||
this.mis = new MinecraftInstallerService(this);
|
||||
}
|
||||
|
||||
public boolean checkedModpack = false, checkingModpack = false;
|
||||
|
||||
private void checkModpack() {
|
||||
int show = 0;
|
||||
for (StackTraceElement e : Thread.currentThread().getStackTrace())
|
||||
if ("checkModpack".equals(e.getMethodName()))
|
||||
++show;
|
||||
if (show > 2)
|
||||
return;
|
||||
if (version().getVersionCount() == 0) {
|
||||
File modpack = new File("modpack.zip");
|
||||
if (modpack.exists()) {
|
||||
TaskWindow.factory().append(ModpackManager.install(modpack, this, null)).create();
|
||||
version().refreshVersions();
|
||||
if (!checkingModpack) {
|
||||
checkingModpack = true;
|
||||
if (version().getVersionCount() == 0) {
|
||||
File modpack = new File("modpack.zip");
|
||||
if (modpack.exists())
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
if (TaskWindow.execute(ModpackManager.install(MainFrame.INSTANCE, modpack, this, null)))
|
||||
version().refreshVersions();
|
||||
checkedModpack = true;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Hello Minecraft! Launcher.
|
||||
* Copyright (C) 2013 huangyuhui <huanghongxun2008@126.com>
|
||||
*
|
||||
* 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.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
@@ -72,12 +72,12 @@ public class TaskList extends Thread {
|
||||
private class Invoker implements Runnable {
|
||||
|
||||
Task task;
|
||||
Set<Invoker> s;
|
||||
CountDownLatch latch;
|
||||
AtomicBoolean bool;
|
||||
|
||||
public Invoker(Task task, Set<Invoker> ss, AtomicBoolean bool) {
|
||||
public Invoker(Task task, CountDownLatch latch, AtomicBoolean bool) {
|
||||
this.task = task;
|
||||
s = ss;
|
||||
this.latch = latch;
|
||||
this.bool = bool;
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ public class TaskList extends Thread {
|
||||
public void run() {
|
||||
if (!executeTask(task))
|
||||
bool.set(false);
|
||||
s.remove(this);
|
||||
latch.countDown();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -99,22 +99,18 @@ public class TaskList extends Thread {
|
||||
return true;
|
||||
this.totTask += c.size();
|
||||
AtomicBoolean bool = new AtomicBoolean(true);
|
||||
Set<Invoker> runningThread = Collections.synchronizedSet(new HashSet<Invoker>());
|
||||
CountDownLatch counter = new CountDownLatch(c.size());
|
||||
for (Task t2 : c) {
|
||||
t2.setParallelExecuting(true);
|
||||
Invoker thread = new Invoker(t2, runningThread, bool);
|
||||
runningThread.add(thread);
|
||||
Invoker thread = new Invoker(t2, counter, bool);
|
||||
invokers.add(thread);
|
||||
if (!EXECUTOR_SERVICE.isShutdown() && !EXECUTOR_SERVICE.isTerminated())
|
||||
futures.put(thread, EXECUTOR_SERVICE.submit(thread));
|
||||
}
|
||||
while (!runningThread.isEmpty())
|
||||
try {
|
||||
if (this.isInterrupted())
|
||||
return false;
|
||||
Thread.sleep(1);
|
||||
} catch (InterruptedException ignore) {
|
||||
}
|
||||
try {
|
||||
counter.await();
|
||||
} catch (InterruptedException ignore) {
|
||||
}
|
||||
return bool.get();
|
||||
}
|
||||
|
||||
|
||||
@@ -225,9 +225,11 @@ public class TaskWindow extends javax.swing.JDialog
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
SwingUtilities.invokeLater(this::dispose);
|
||||
suc = true;
|
||||
HMCLog.log("Tasks are finished.");
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
dispose();
|
||||
suc = true;
|
||||
HMCLog.log("Tasks are finished.");
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -271,7 +273,14 @@ public class TaskWindow extends javax.swing.JDialog
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
if (taskList == null || task == null)
|
||||
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.setValue(pgsTotal.getValue() + 1);
|
||||
int idx = tasks.indexOf(task);
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ if (buildnumber == null)
|
||||
|
||||
def versionroot = System.getenv("VERSION_ROOT")
|
||||
if (versionroot == null)
|
||||
versionroot = "0.8.6"
|
||||
versionroot = "0.8.7"
|
||||
|
||||
String mavenGroupId = 'HMCSM'
|
||||
String mavenVersion = versionroot + '.' + buildnumber
|
||||
|
||||
Reference in new issue
Block a user