Compare commits

...
2 Commits
Author SHA1 Message Date
huangyuhui 5dc812072f Fixed NullPointerException when only hidden version here 2016-03-01 12:40:25 +08:00
huangyuhui 3ba75d2de3 Fixed #39 2016-03-01 12:37:12 +08:00
7 changed files with 34 additions and 8 deletions

No files matched your search

+1 -1
View File
@@ -34,7 +34,7 @@ if (buildnumber == null)
def versionroot = System.getenv("VERSION_ROOT")
if (versionroot == null)
versionroot = "2.4.0"
versionroot = "2.4.1"
String mavenGroupId = 'HMCL'
String mavenVersion = versionroot + '.' + buildnumber
@@ -76,11 +76,33 @@ public class MinecraftAssetService extends IMinecraftAssetService {
MinecraftVersion mv = service.version().getVersionById(id);
if (mv == null)
return false;
return downloadMinecraftAssetsIndex(mv.getAssetsIndex());
return downloadMinecraftAssetsIndexAsync(mv.getAssetsIndex());
}
@Override
public boolean downloadMinecraftAssetsIndex(AssetIndexDownloadInfo assets) {
File assetsLocation = getAssets();
if (!assetsLocation.exists() && !assetsLocation.mkdirs())
HMCLog.warn("Failed to make directories: " + assetsLocation);
File assetsIndex = new File(assetsLocation, "indexes/" + assets.getId() + ".json");
File renamed = null;
if (assetsIndex.exists()) {
renamed = new File(assetsLocation, "indexes/" + assets.getId() + "-renamed.json");
if (assetsIndex.renameTo(renamed))
HMCLog.warn("Failed to rename " + assetsIndex + " to " + renamed);
}
if (new FileDownloadTask(assets.getUrl(service.getDownloadType()), IOUtils.tryGetCanonicalFile(assetsIndex), assets.sha1).setTag(assets.getId() + ".json").run()) {
if (renamed != null && !renamed.delete())
HMCLog.warn("Failed to delete " + renamed + ", maybe you should do it.");
return true;
}
if (renamed != null && !renamed.renameTo(assetsIndex))
HMCLog.warn("Failed to rename " + renamed + " to " + assetsIndex);
return false;
}
@Override
public boolean downloadMinecraftAssetsIndexAsync(AssetIndexDownloadInfo assets) {
File assetsLocation = getAssets();
if (!assetsLocation.exists() && !assetsLocation.mkdirs())
HMCLog.warn("Failed to make directories: " + assetsLocation);
@@ -45,6 +45,8 @@ public abstract class IMinecraftAssetService extends IMinecraftBasicService {
*/
public abstract boolean refreshAssetsIndex(String a);
public abstract boolean downloadMinecraftAssetsIndexAsync(AssetIndexDownloadInfo assetsId);
public abstract boolean downloadMinecraftAssetsIndex(AssetIndexDownloadInfo assetsId);
public abstract File getAssetObject(String assetVersion, String name) throws IOException;
@@ -23,6 +23,7 @@ import java.io.File;
import org.jackhuang.hellominecraft.launcher.api.PluginManager;
import org.jackhuang.hellominecraft.launcher.core.MCUtils;
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftService;
import org.jackhuang.hellominecraft.launcher.core.version.MinecraftVersion;
import org.jackhuang.hellominecraft.util.system.IOUtils;
import org.jackhuang.hellominecraft.util.StrUtils;
import org.jackhuang.hellominecraft.util.EventHandler;
@@ -87,8 +88,9 @@ public final class Profile {
public String getSelectedVersion() {
String v = selectedMinecraftVersion;
if (StrUtils.isBlank(v) || service().version().getVersionById(v) == null || service().version().getVersionById(v).hidden) {
if (service().version().getVersionCount() > 0)
v = service().version().getOneVersion(t -> !t.hidden).id;
MinecraftVersion mv = service().version().getOneVersion(t -> !t.hidden);
if (mv != null)
v = mv.id;
if (StrUtils.isNotBlank(v))
setSelectedMinecraftVersion(v);
}
@@ -49,6 +49,7 @@ public class CrashReporter implements Thread.UncaughtExceptionHandler {
put("AWTError", "");
put("JFileChooser", "Has your operating system been installed completely or is a ghost system? ");
put("JceSecurityManager", "Has your operating system been installed completely or is a ghost system? ");
put("couldn't create component peer", "Fucking computer!");
put("sun.awt.shell.Win32ShellFolder2", "crash.user_fault");
put("UnsatisfiedLinkError", "crash.user_fault");
put("java.awt.HeadlessException", "crash.headless");
@@ -176,7 +176,7 @@ public class TaskList extends Thread {
while (!in.isEmpty())
synchronized (in) {
Invoker it = in.iterator().next();
if (!it.task.abort())
if (!it.task.abort() && futures.get(it) != null)
futures.get(it).cancel(true);
in.remove(it);
}
@@ -118,8 +118,7 @@ public class FileDownloadTask extends Task implements PreviousResult<File>, Prev
this.url = IOUtils.parseURL(p.getResult());
for (int repeat = 0; repeat < 6; repeat++) {
if (repeat > 0) {
HMCLog.warn("Failed to download, repeat: " + repeat);
if (repeat > 0)
if (failedCallbackReturnsNewURL != null) {
URL tmp = IOUtils.parseURL(failedCallbackReturnsNewURL.apply(repeat));
if (tmp != null) {
@@ -127,7 +126,7 @@ public class FileDownloadTask extends Task implements PreviousResult<File>, Prev
HMCLog.warn("Switch to: " + url);
}
}
}
HMCLog.log("Downloading: " + url + ", to: " + filePath);
if (!shouldContinue)
break;
try {