Compare commits

...
4 Commits
30 ... 34
9 changed files with 35 additions and 12 deletions

No files matched your search

@@ -56,7 +56,8 @@ public class MinecraftAssetService extends IMinecraftAssetService {
}
public Task downloadAssets(final MinecraftVersion mv) {
Utils.requireNonNull(mv);
if (mv == null)
return null;
return new TaskInfo("Download Assets") {
Collection<Task> afters = new HashSet<>();
@@ -55,7 +55,7 @@ public class MinecraftDownloadService extends IMinecraftDownloadService {
return downloadLibraries;
MinecraftVersion v = mv.resolve(service.version());
for (IMinecraftLibrary l : v.getLibraries())
if (l != null && l.allow()) {
if (l != null && l.allow() && l.getDownloadInfo() != null) {
File ff = l.getFilePath(service.baseDirectory());
if (!ff.exists()) {
String libURL = l.getDownloadInfo().getUrl(service.getDownloadType());
@@ -89,6 +89,8 @@ public class MinecraftLibrary extends IMinecraftLibrary {
public String formatName() {
String[] s = name.split(":");
if (s.length < 3)
return null;
StringBuilder sb = new StringBuilder(s[0].replace('.', '/')).append('/').append(s[1]).append('/').append(s[2]).append('/').append(s[1]).append('-').append(s[2]);
if (natives != null)
sb.append('-').append(getNative());
@@ -120,8 +122,11 @@ public class MinecraftLibrary extends IMinecraftLibrary {
downloads.artifact = info = new LibraryDownloadInfo();
else
info = downloads.artifact;
if (StrUtils.isBlank(info.path))
if (StrUtils.isBlank(info.path)) {
info.path = formatName();
if (info.path == null)
return null;
}
info.forgeURL = this.url;
return info;
}
@@ -46,8 +46,12 @@ public final class Profile {
}
public Profile(String name) {
this(name, new File(IOUtils.currentDir(), ".minecraft").getPath());
}
public Profile(String name, String gameDir) {
this.name = name;
gameDir = MCUtils.getInitGameDir().getPath();
this.gameDir = gameDir;
}
public Profile(String name, Profile v) {
@@ -25,6 +25,7 @@ import java.util.Map;
import org.jackhuang.hellominecraft.util.C;
import org.jackhuang.hellominecraft.util.logging.HMCLog;
import org.jackhuang.hellominecraft.launcher.Main;
import org.jackhuang.hellominecraft.launcher.core.MCUtils;
import org.jackhuang.hellominecraft.launcher.core.download.DownloadType;
import org.jackhuang.hellominecraft.util.CollectionUtils;
import org.jackhuang.hellominecraft.util.EventHandler;
@@ -40,6 +41,7 @@ import org.jackhuang.hellominecraft.util.UpdateChecker;
public final class Settings {
public static final String DEFAULT_PROFILE = "Default";
public static final String HOME_PROFILE = "Home";
public static final File SETTINGS_FILE = new File(IOUtils.currentDir(), "hmcl.json");
@@ -55,7 +57,7 @@ public final class Settings {
SETTINGS.downloadTypeChangedEvent.register(DownloadType::setSuggestedDownloadType);
DownloadType.setSuggestedDownloadType(SETTINGS.getDownloadSource());
if (!getProfiles().containsKey(DEFAULT_PROFILE))
getProfiles().put(DEFAULT_PROFILE, new Profile());
getProfiles().put(DEFAULT_PROFILE, new Profile(DEFAULT_PROFILE));
for (Map.Entry<String, Profile> entry : getProfiles().entrySet()) {
Profile e = entry.getValue();
@@ -81,8 +83,11 @@ public final class Settings {
} catch (IOException | JsonSyntaxException e) {
HMCLog.warn("Something happened wrongly when load settings.", e);
}
else
else {
HMCLog.log("No settings file here, may be first loading.");
if (!c.getConfigurations().containsKey(HOME_PROFILE))
c.getConfigurations().put(HOME_PROFILE, new Profile(HOME_PROFILE, MCUtils.getLocation().getPath()));
}
return c;
}
@@ -150,7 +155,13 @@ public final class Settings {
MessageBox.Show(C.i18n("settings.cannot_remove_default_config"));
return false;
}
return getProfiles().remove(ver) != null;
boolean notify = false;
if (getLastProfile().getName().equals(ver))
notify = true;
boolean flag = getProfiles().remove(ver) != null;
if (notify && flag)
onProfileChanged();
return flag;
}
public static final EventHandler<Profile> profileChangedEvent = new EventHandler(null);
@@ -949,8 +949,7 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
private void btnRemoveProfileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRemoveProfileActionPerformed
if (MessageBox.Show(C.i18n("ui.message.sure_remove", Settings.getLastProfile().getName()), MessageBox.YES_NO_OPTION) == MessageBox.NO_OPTION)
return;
if (Settings.delProfile(Settings.getLastProfile()))
loadProfiles();
Settings.delProfile(Settings.getLastProfile());
}//GEN-LAST:event_btnRemoveProfileActionPerformed
private void cboVersionsItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cboVersionsItemStateChanged
@@ -48,7 +48,7 @@ public class CrashReporter implements Thread.UncaughtExceptionHandler {
put("MessageBox", "");
put("AWTError", "");
put("JFileChooser", "Has your operating system been installed completely or is a ghost system? ");
put("JceSecurity", "Has your operating system been installed completely or is a ghost system? ");
put("Jce", "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");
@@ -93,6 +93,7 @@ public class ZipEngine {
if (file.isDirectory()) {
pathName = file.getPath().substring(basePath.length() + 1)
+ "/";
pathName = pathName.replace('\\', '/');
if (pathNameCallback != null)
pathName = pathNameCallback.apply(pathName, true);
if (pathName == null)
@@ -100,9 +101,10 @@ public class ZipEngine {
zos.putNextEntry(new ZipEntry(pathName));
putDirectoryImpl(file, basePath, pathNameCallback);
} else {
if (".DS_Store".equals(file.getName())) // For mac computers.
if (".DS_Store".equals(file.getName())) // For Mac computers.
continue;
pathName = file.getPath().substring(basePath.length() + 1);
pathName = pathName.replace('\\', '/');
if (pathNameCallback != null)
pathName = pathNameCallback.apply(pathName, false);
if (pathName == null)
@@ -322,7 +322,8 @@ public class TaskWindow extends javax.swing.JDialog
boolean flag;
public TaskWindowFactory append(Task t) {
ll.add(t);
if (t != null)
ll.add(t);
return this;
}