Compare commits

..
2 Commits
32 .. 34
8 changed files with 25 additions and 12 deletions

No files matched your search

@@ -56,7 +56,8 @@ public class MinecraftAssetService extends IMinecraftAssetService {
} }
public Task downloadAssets(final MinecraftVersion mv) { public Task downloadAssets(final MinecraftVersion mv) {
Utils.requireNonNull(mv); if (mv == null)
return null;
return new TaskInfo("Download Assets") { return new TaskInfo("Download Assets") {
Collection<Task> afters = new HashSet<>(); Collection<Task> afters = new HashSet<>();
@@ -55,7 +55,7 @@ public class MinecraftDownloadService extends IMinecraftDownloadService {
return downloadLibraries; return downloadLibraries;
MinecraftVersion v = mv.resolve(service.version()); MinecraftVersion v = mv.resolve(service.version());
for (IMinecraftLibrary l : v.getLibraries()) for (IMinecraftLibrary l : v.getLibraries())
if (l != null && l.allow()) { if (l != null && l.allow() && l.getDownloadInfo() != null) {
File ff = l.getFilePath(service.baseDirectory()); File ff = l.getFilePath(service.baseDirectory());
if (!ff.exists()) { if (!ff.exists()) {
String libURL = l.getDownloadInfo().getUrl(service.getDownloadType()); String libURL = l.getDownloadInfo().getUrl(service.getDownloadType());
@@ -89,6 +89,8 @@ public class MinecraftLibrary extends IMinecraftLibrary {
public String formatName() { public String formatName() {
String[] s = name.split(":"); 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]); 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) if (natives != null)
sb.append('-').append(getNative()); sb.append('-').append(getNative());
@@ -120,8 +122,11 @@ public class MinecraftLibrary extends IMinecraftLibrary {
downloads.artifact = info = new LibraryDownloadInfo(); downloads.artifact = info = new LibraryDownloadInfo();
else else
info = downloads.artifact; info = downloads.artifact;
if (StrUtils.isBlank(info.path)) if (StrUtils.isBlank(info.path)) {
info.path = formatName(); info.path = formatName();
if (info.path == null)
return null;
}
info.forgeURL = this.url; info.forgeURL = this.url;
return info; return info;
} }
@@ -46,7 +46,7 @@ public final class Profile {
} }
public Profile(String name) { public Profile(String name) {
this(name, IOUtils.currentDir().getPath()); this(name, new File(IOUtils.currentDir(), ".minecraft").getPath());
} }
public Profile(String name, String gameDir) { public Profile(String name, String gameDir) {
@@ -58,8 +58,6 @@ public final class Settings {
DownloadType.setSuggestedDownloadType(SETTINGS.getDownloadSource()); DownloadType.setSuggestedDownloadType(SETTINGS.getDownloadSource());
if (!getProfiles().containsKey(DEFAULT_PROFILE)) if (!getProfiles().containsKey(DEFAULT_PROFILE))
getProfiles().put(DEFAULT_PROFILE, new Profile(DEFAULT_PROFILE)); getProfiles().put(DEFAULT_PROFILE, new Profile(DEFAULT_PROFILE));
if (!getProfiles().containsKey(HOME_PROFILE))
getProfiles().put(HOME_PROFILE, new Profile(HOME_PROFILE, MCUtils.getLocation().getPath()));
for (Map.Entry<String, Profile> entry : getProfiles().entrySet()) { for (Map.Entry<String, Profile> entry : getProfiles().entrySet()) {
Profile e = entry.getValue(); Profile e = entry.getValue();
@@ -85,8 +83,11 @@ public final class Settings {
} catch (IOException | JsonSyntaxException e) { } catch (IOException | JsonSyntaxException e) {
HMCLog.warn("Something happened wrongly when load settings.", e); HMCLog.warn("Something happened wrongly when load settings.", e);
} }
else else {
HMCLog.log("No settings file here, may be first loading."); 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; return c;
} }
@@ -154,7 +155,13 @@ public final class Settings {
MessageBox.Show(C.i18n("settings.cannot_remove_default_config")); MessageBox.Show(C.i18n("settings.cannot_remove_default_config"));
return false; 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); 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 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) if (MessageBox.Show(C.i18n("ui.message.sure_remove", Settings.getLastProfile().getName()), MessageBox.YES_NO_OPTION) == MessageBox.NO_OPTION)
return; return;
if (Settings.delProfile(Settings.getLastProfile())) Settings.delProfile(Settings.getLastProfile());
loadProfiles();
}//GEN-LAST:event_btnRemoveProfileActionPerformed }//GEN-LAST:event_btnRemoveProfileActionPerformed
private void cboVersionsItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cboVersionsItemStateChanged 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("MessageBox", "");
put("AWTError", ""); put("AWTError", "");
put("JFileChooser", "Has your operating system been installed completely or is a ghost system? "); 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("couldn't create component peer", "Fucking computer!");
put("sun.awt.shell.Win32ShellFolder2", "crash.user_fault"); put("sun.awt.shell.Win32ShellFolder2", "crash.user_fault");
put("UnsatisfiedLinkError", "crash.user_fault"); put("UnsatisfiedLinkError", "crash.user_fault");
@@ -322,7 +322,8 @@ public class TaskWindow extends javax.swing.JDialog
boolean flag; boolean flag;
public TaskWindowFactory append(Task t) { public TaskWindowFactory append(Task t) {
ll.add(t); if (t != null)
ll.add(t);
return this; return this;
} }