Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cafcf458b8 | ||
|
|
e7d0624b96 | ||
|
|
156de2457d | ||
|
|
c839d045cc |
No files matched your search
+2
-2
@@ -32,6 +32,7 @@ import org.jackhuang.hellominecraft.util.system.IOUtils;
|
|||||||
import org.jackhuang.hellominecraft.util.StrUtils;
|
import org.jackhuang.hellominecraft.util.StrUtils;
|
||||||
import org.jackhuang.hellominecraft.launcher.core.download.IDownloadProvider;
|
import org.jackhuang.hellominecraft.launcher.core.download.IDownloadProvider;
|
||||||
import org.jackhuang.hellominecraft.launcher.core.version.MinecraftVersion;
|
import org.jackhuang.hellominecraft.launcher.core.version.MinecraftVersion;
|
||||||
|
import org.jackhuang.hellominecraft.util.Utils;
|
||||||
import org.jackhuang.hellominecraft.util.VersionNumber;
|
import org.jackhuang.hellominecraft.util.VersionNumber;
|
||||||
import org.jackhuang.hellominecraft.util.tasks.TaskInfo;
|
import org.jackhuang.hellominecraft.util.tasks.TaskInfo;
|
||||||
|
|
||||||
@@ -47,8 +48,7 @@ public class AssetsMojangLoader extends IAssetsHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Task getList(final MinecraftVersion mv, final IMinecraftAssetService mp) {
|
public Task getList(final MinecraftVersion mv, final IMinecraftAssetService mp) {
|
||||||
if (mv == null)
|
Utils.requireNonNull(mv);
|
||||||
throw new IllegalArgumentException("AssetsMojangLoader: null argument: MinecraftVersion");
|
|
||||||
String assetsId = mv.getAssetsIndex().getId();
|
String assetsId = mv.getAssetsIndex().getId();
|
||||||
File assets = mp.getAssets();
|
File assets = mp.getAssets();
|
||||||
HMCLog.log("Gathering asset index: " + assetsId);
|
HMCLog.log("Gathering asset index: " + assetsId);
|
||||||
|
|||||||
+2
@@ -30,6 +30,7 @@ import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftService;
|
|||||||
import org.jackhuang.hellominecraft.launcher.core.version.AssetIndexDownloadInfo;
|
import org.jackhuang.hellominecraft.launcher.core.version.AssetIndexDownloadInfo;
|
||||||
import org.jackhuang.hellominecraft.launcher.core.version.MinecraftVersion;
|
import org.jackhuang.hellominecraft.launcher.core.version.MinecraftVersion;
|
||||||
import org.jackhuang.hellominecraft.util.MessageBox;
|
import org.jackhuang.hellominecraft.util.MessageBox;
|
||||||
|
import org.jackhuang.hellominecraft.util.Utils;
|
||||||
import org.jackhuang.hellominecraft.util.func.Function;
|
import org.jackhuang.hellominecraft.util.func.Function;
|
||||||
import org.jackhuang.hellominecraft.util.logging.HMCLog;
|
import org.jackhuang.hellominecraft.util.logging.HMCLog;
|
||||||
import org.jackhuang.hellominecraft.util.tasks.Task;
|
import org.jackhuang.hellominecraft.util.tasks.Task;
|
||||||
@@ -55,6 +56,7 @@ public class MinecraftAssetService extends IMinecraftAssetService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Task downloadAssets(final MinecraftVersion mv) {
|
public Task downloadAssets(final MinecraftVersion mv) {
|
||||||
|
Utils.requireNonNull(mv);
|
||||||
return new TaskInfo("Download Assets") {
|
return new TaskInfo("Download Assets") {
|
||||||
Collection<Task> afters = new HashSet<>();
|
Collection<Task> afters = new HashSet<>();
|
||||||
|
|
||||||
|
|||||||
+8
-9
@@ -54,16 +54,15 @@ public class MinecraftDownloadService extends IMinecraftDownloadService {
|
|||||||
if (mv == null)
|
if (mv == null)
|
||||||
return downloadLibraries;
|
return downloadLibraries;
|
||||||
MinecraftVersion v = mv.resolve(service.version());
|
MinecraftVersion v = mv.resolve(service.version());
|
||||||
if (v.libraries != null)
|
for (IMinecraftLibrary l : v.getLibraries())
|
||||||
for (IMinecraftLibrary l : v.libraries)
|
if (l != null && 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 = 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));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return downloadLibraries;
|
return downloadLibraries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
@@ -168,4 +168,8 @@ public class MinecraftVersion implements Cloneable, Comparable<MinecraftVersion>
|
|||||||
i.id = id;
|
i.id = id;
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Set<IMinecraftLibrary> getLibraries() {
|
||||||
|
return libraries == null ? new HashSet() : new HashSet(libraries);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -46,8 +46,12 @@ public final class Profile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Profile(String name) {
|
public Profile(String name) {
|
||||||
|
this(name, new File(IOUtils.currentDir(), ".minecraft").getPath());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Profile(String name, String gameDir) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
gameDir = MCUtils.getInitGameDir().getPath();
|
this.gameDir = gameDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Profile(String name, Profile v) {
|
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.C;
|
||||||
import org.jackhuang.hellominecraft.util.logging.HMCLog;
|
import org.jackhuang.hellominecraft.util.logging.HMCLog;
|
||||||
import org.jackhuang.hellominecraft.launcher.Main;
|
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.launcher.core.download.DownloadType;
|
||||||
import org.jackhuang.hellominecraft.util.CollectionUtils;
|
import org.jackhuang.hellominecraft.util.CollectionUtils;
|
||||||
import org.jackhuang.hellominecraft.util.EventHandler;
|
import org.jackhuang.hellominecraft.util.EventHandler;
|
||||||
@@ -40,6 +41,7 @@ import org.jackhuang.hellominecraft.util.UpdateChecker;
|
|||||||
public final class Settings {
|
public final class Settings {
|
||||||
|
|
||||||
public static final String DEFAULT_PROFILE = "Default";
|
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");
|
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);
|
SETTINGS.downloadTypeChangedEvent.register(DownloadType::setSuggestedDownloadType);
|
||||||
DownloadType.setSuggestedDownloadType(SETTINGS.getDownloadSource());
|
DownloadType.setSuggestedDownloadType(SETTINGS.getDownloadSource());
|
||||||
if (!getProfiles().containsKey(DEFAULT_PROFILE))
|
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()) {
|
for (Map.Entry<String, Profile> entry : getProfiles().entrySet()) {
|
||||||
Profile e = entry.getValue();
|
Profile e = entry.getValue();
|
||||||
@@ -81,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,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
|
||||||
|
|||||||
@@ -93,6 +93,7 @@ public class ZipEngine {
|
|||||||
if (file.isDirectory()) {
|
if (file.isDirectory()) {
|
||||||
pathName = file.getPath().substring(basePath.length() + 1)
|
pathName = file.getPath().substring(basePath.length() + 1)
|
||||||
+ "/";
|
+ "/";
|
||||||
|
pathName = pathName.replace('\\', '/');
|
||||||
if (pathNameCallback != null)
|
if (pathNameCallback != null)
|
||||||
pathName = pathNameCallback.apply(pathName, true);
|
pathName = pathNameCallback.apply(pathName, true);
|
||||||
if (pathName == null)
|
if (pathName == null)
|
||||||
@@ -100,9 +101,10 @@ public class ZipEngine {
|
|||||||
zos.putNextEntry(new ZipEntry(pathName));
|
zos.putNextEntry(new ZipEntry(pathName));
|
||||||
putDirectoryImpl(file, basePath, pathNameCallback);
|
putDirectoryImpl(file, basePath, pathNameCallback);
|
||||||
} else {
|
} else {
|
||||||
if (".DS_Store".equals(file.getName())) // For mac computers.
|
if (".DS_Store".equals(file.getName())) // For Mac computers.
|
||||||
continue;
|
continue;
|
||||||
pathName = file.getPath().substring(basePath.length() + 1);
|
pathName = file.getPath().substring(basePath.length() + 1);
|
||||||
|
pathName = pathName.replace('\\', '/');
|
||||||
if (pathNameCallback != null)
|
if (pathNameCallback != null)
|
||||||
pathName = pathNameCallback.apply(pathName, false);
|
pathName = pathNameCallback.apply(pathName, false);
|
||||||
if (pathName == null)
|
if (pathName == null)
|
||||||
|
|||||||
Reference in new issue
Block a user