Add: Common folder to save libraries and assets
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* 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.launcher.api.event.version;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.EventObject;
|
||||
import org.jackhuang.hellominecraft.util.Wrapper;
|
||||
|
||||
/**
|
||||
* This event gets fired when we getting minecraft library path.
|
||||
* <br>
|
||||
* This event is fired on the {@link org.jackhuang.hellominecraft.api.HMCLAPI#EVENT_BUS}
|
||||
* @param source {@link org.jackhuang.hellominecraft.launcher.core.version.MinecraftLibrary}
|
||||
* @param {@code Wrapper<File>} modify this thing to change to your wanted mc lib.
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public class MinecraftLibraryPathEvent extends EventObject {
|
||||
|
||||
String location;
|
||||
Wrapper<File> file;
|
||||
|
||||
public MinecraftLibraryPathEvent(Object source, String location, Wrapper<File> value) {
|
||||
super(source);
|
||||
this.location = location;
|
||||
this.file = value;
|
||||
}
|
||||
|
||||
public String getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public Wrapper<File> getFile() {
|
||||
return file;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -50,9 +50,9 @@ public class AssetsMojangLoader extends IAssetsHandler {
|
||||
public Task getList(final MinecraftVersion mv, final IMinecraftAssetService mp) {
|
||||
Objects.requireNonNull(mv);
|
||||
String assetsId = mv.getAssetsIndex().getId();
|
||||
File assets = mp.getAssets();
|
||||
File assets = mp.getAssets(assetsId);
|
||||
HMCLog.log("Gathering asset index: " + assetsId);
|
||||
File f = IOUtils.tryGetCanonicalFile(new File(assets, "indexes/" + assetsId + ".json"));
|
||||
File f = mp.getIndexFile(assetsId);
|
||||
return new TaskInfo("Gather asset index") {
|
||||
@Override
|
||||
public Collection<Task> getDependTasks() {
|
||||
@@ -72,7 +72,7 @@ public class AssetsMojangLoader extends IAssetsHandler {
|
||||
AssetsIndex o = C.GSON.fromJson(result, AssetsIndex.class);
|
||||
assetsDownloadURLs = new ArrayList<>();
|
||||
assetsLocalNames = new ArrayList<>();
|
||||
contents = new ArrayList<>();
|
||||
assetsObjects = new ArrayList<>();
|
||||
HashSet<String> loadedHashes = new HashSet<>();
|
||||
int pgs = 0;
|
||||
if (o != null && o.getFileMap() != null)
|
||||
@@ -80,13 +80,9 @@ public class AssetsMojangLoader extends IAssetsHandler {
|
||||
if (loadedHashes.contains(e.getValue().getHash()))
|
||||
continue;
|
||||
loadedHashes.add(e.getValue().getHash());
|
||||
Contents c = new Contents();
|
||||
c.eTag = e.getValue().getHash();
|
||||
c.key = c.eTag.substring(0, 2) + "/" + e.getValue().getHash();
|
||||
c.size = e.getValue().getSize();
|
||||
contents.add(c);
|
||||
assetsDownloadURLs.add(c.key);
|
||||
assetsLocalNames.add(new File(assets, "objects" + File.separator + c.key.replace("/", File.separator)));
|
||||
assetsObjects.add(e.getValue());
|
||||
assetsDownloadURLs.add(e.getValue().getLocation());
|
||||
assetsLocalNames.add(mp.getAssetObject(assetsId, e.getValue()));
|
||||
if (ppl != null)
|
||||
ppl.setProgress(this, ++pgs, o.getFileMap().size());
|
||||
}
|
||||
|
||||
@@ -34,7 +34,9 @@ public class AssetsObject {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
public AssetsObject() {
|
||||
public AssetsObject(String hash, long size) {
|
||||
this.hash = hash;
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
public String getHash() {
|
||||
@@ -44,6 +46,10 @@ public class AssetsObject {
|
||||
public long getSize() {
|
||||
return this.size;
|
||||
}
|
||||
|
||||
public String getLocation() {
|
||||
return hash.substring(0, 2) + "/" + hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
/*
|
||||
* 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.launcher.core.asset;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public class Contents {
|
||||
|
||||
public String key, eTag, lastModified, storageClass;
|
||||
|
||||
public Contents() {
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public String geteTag() {
|
||||
return eTag;
|
||||
}
|
||||
|
||||
public void seteTag(String eTag) {
|
||||
this.eTag = eTag;
|
||||
}
|
||||
|
||||
public String getLastModified() {
|
||||
return lastModified;
|
||||
}
|
||||
|
||||
public void setLastModified(String lastModified) {
|
||||
this.lastModified = lastModified;
|
||||
}
|
||||
|
||||
public String getStorageClass() {
|
||||
return storageClass;
|
||||
}
|
||||
|
||||
public void setStorageClass(String storageClass) {
|
||||
this.storageClass = storageClass;
|
||||
}
|
||||
|
||||
public long getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public void setSize(long size) {
|
||||
this.size = size;
|
||||
}
|
||||
public long size;
|
||||
|
||||
}
|
||||
@@ -45,7 +45,7 @@ public abstract class IAssetsHandler {
|
||||
protected ArrayList<String> assetsDownloadURLs;
|
||||
protected ArrayList<File> assetsLocalNames;
|
||||
protected final String name;
|
||||
protected List<Contents> contents;
|
||||
protected List<AssetsObject> assetsObjects;
|
||||
|
||||
public IAssetsHandler(String name) {
|
||||
this.name = name;
|
||||
@@ -98,7 +98,7 @@ public abstract class IAssetsHandler {
|
||||
|
||||
@Override
|
||||
public void executeTask(boolean areDependTasksSucceeded) {
|
||||
if (assetsDownloadURLs == null || assetsLocalNames == null || contents == null)
|
||||
if (assetsDownloadURLs == null || assetsLocalNames == null || assetsObjects == null)
|
||||
throw new IllegalStateException(C.i18n("assets.not_refreshed"));
|
||||
int max = assetsDownloadURLs.size();
|
||||
al = new ArrayList<>();
|
||||
@@ -117,7 +117,7 @@ public abstract class IAssetsHandler {
|
||||
FileInputStream fis = FileUtils.openInputStream(location);
|
||||
String sha = DigestUtils.sha1Hex(IOUtils.toByteArray(fis));
|
||||
IOUtils.closeQuietly(fis);
|
||||
if (contents.get(i).geteTag().equals(sha)) {
|
||||
if (assetsObjects.get(i).getHash().equals(sha)) {
|
||||
++hasDownloaded;
|
||||
HMCLog.log("File " + assetsLocalNames.get(i) + " has been downloaded successfully, skipped downloading.");
|
||||
if (ppl != null)
|
||||
@@ -130,7 +130,7 @@ public abstract class IAssetsHandler {
|
||||
need = !location.exists();
|
||||
}
|
||||
if (need)
|
||||
al.add(new FileDownloadTask(url, location).setTag(contents.get(i).geteTag()));
|
||||
al.add(new FileDownloadTask(url, location).setTag(assetsObjects.get(i).getHash()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ public class MinecraftAssetService extends IMinecraftAssetService {
|
||||
|
||||
@Override
|
||||
public Task downloadMinecraftAssetsIndex(AssetIndexDownloadInfo assetIndex) {
|
||||
File assetsLocation = getAssets();
|
||||
File assetsLocation = getAssets(assetIndex.getId());
|
||||
if (!FileUtils.makeDirectory(assetsLocation))
|
||||
HMCLog.warn("Failed to make directories: " + assetsLocation);
|
||||
File assetsIndex = getIndexFile(assetIndex.getId());
|
||||
@@ -100,7 +100,7 @@ public class MinecraftAssetService extends IMinecraftAssetService {
|
||||
|
||||
@Override
|
||||
public boolean downloadMinecraftAssetsIndexAsync(AssetIndexDownloadInfo assetIndex) {
|
||||
File assetsDir = getAssets();
|
||||
File assetsDir = getAssets(assetIndex.getId());
|
||||
if (!FileUtils.makeDirectory(assetsDir))
|
||||
HMCLog.warn("Failed to make directories: " + assetsDir);
|
||||
File assetsIndex = getIndexFile(assetIndex.getId());
|
||||
@@ -111,8 +111,8 @@ public class MinecraftAssetService extends IMinecraftAssetService {
|
||||
HMCLog.warn("Failed to rename " + assetsIndex + " to " + renamed);
|
||||
}
|
||||
if (TaskWindow.factory()
|
||||
.append(new FileDownloadTask(assetIndex.getUrl(service.getDownloadType()), IOUtils.tryGetCanonicalFile(assetsIndex), assetIndex.sha1).setTag(assetIndex.getId() + ".json"))
|
||||
.execute()) {
|
||||
.append(new FileDownloadTask(assetIndex.getUrl(service.getDownloadType()), IOUtils.tryGetCanonicalFile(assetsIndex), assetIndex.sha1).setTag(assetIndex.getId() + ".json"))
|
||||
.execute()) {
|
||||
if (renamed != null && !renamed.delete())
|
||||
HMCLog.warn("Failed to delete " + renamed + ", maybe you should do it.");
|
||||
return true;
|
||||
@@ -123,30 +123,31 @@ public class MinecraftAssetService extends IMinecraftAssetService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getAssets() {
|
||||
public File getAssets(String assetId) {
|
||||
return new File(service.baseDirectory(), "assets");
|
||||
}
|
||||
|
||||
private File getIndexFile(String assetVersion) {
|
||||
return new File(getAssets(), "indexes/" + assetVersion + ".json");
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getAssetObject(String assetVersion, String name) throws IOException {
|
||||
try {
|
||||
AssetsIndex index = (AssetsIndex) C.GSON.fromJson(FileUtils.read(getIndexFile(assetVersion), "UTF-8"), AssetsIndex.class);
|
||||
public File getIndexFile(String assetId) {
|
||||
return new File(getAssets(assetId), "indexes/" + assetId + ".json");
|
||||
}
|
||||
|
||||
String hash = ((AssetsObject) index.getFileMap().get(name)).getHash();
|
||||
return new File(getAssets(), "objects/" + hash.substring(0, 2) + "/" + hash);
|
||||
@Override
|
||||
public File getAssetObject(String assetId, String name) throws IOException {
|
||||
try {
|
||||
AssetsIndex index = (AssetsIndex) C.GSON.fromJson(FileUtils.read(getIndexFile(assetId), "UTF-8"), AssetsIndex.class);
|
||||
return getAssetObject(assetId, (AssetsObject) index.getFileMap().get(name));
|
||||
} catch (JsonSyntaxException e) {
|
||||
throw new IOException("Assets file format malformed.", e);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkAssetsExistance(AssetIndexDownloadInfo assetIndex) {
|
||||
File indexFile = getIndexFile(assetIndex.getId());
|
||||
protected boolean checkAssetsExistance(AssetIndexDownloadInfo assetIndex) {
|
||||
String assetId = assetIndex.getId();
|
||||
File indexFile = getIndexFile(assetId);
|
||||
File assetDir = getAssets(assetId);
|
||||
|
||||
if (!getAssets().exists() || !indexFile.isFile())
|
||||
if (!getAssets(assetId).exists() || !indexFile.isFile())
|
||||
return false;
|
||||
|
||||
try {
|
||||
@@ -156,7 +157,7 @@ public class MinecraftAssetService extends IMinecraftAssetService {
|
||||
if (index == null)
|
||||
return false;
|
||||
for (Map.Entry<String, AssetsObject> entry : index.getFileMap().entrySet())
|
||||
if (!new File(getAssets(), "objects/" + ((AssetsObject) entry.getValue()).getHash().substring(0, 2) + "/" + ((AssetsObject) entry.getValue()).getHash()).exists())
|
||||
if (!assetObjectPath(assetDir, (AssetsObject) entry.getValue()).exists())
|
||||
return false;
|
||||
return true;
|
||||
} catch (IOException | JsonSyntaxException e) {
|
||||
@@ -164,8 +165,8 @@ public class MinecraftAssetService extends IMinecraftAssetService {
|
||||
}
|
||||
}
|
||||
|
||||
private File reconstructAssets(AssetIndexDownloadInfo assetIndex) {
|
||||
File assetsDir = getAssets();
|
||||
protected File reconstructAssets(AssetIndexDownloadInfo assetIndex) {
|
||||
File assetsDir = getAssets(assetIndex.getId());
|
||||
String assetVersion = assetIndex.getId();
|
||||
File indexFile = getIndexFile(assetVersion);
|
||||
File virtualRoot = new File(new File(assetsDir, "virtual"), assetVersion);
|
||||
@@ -187,7 +188,7 @@ public class MinecraftAssetService extends IMinecraftAssetService {
|
||||
int tot = index.getFileMap().entrySet().size();
|
||||
for (Map.Entry<String, AssetsObject> entry : index.getFileMap().entrySet()) {
|
||||
File target = new File(virtualRoot, (String) entry.getKey());
|
||||
File original = new File(assetsDir, "objects/" + ((AssetsObject) entry.getValue()).getHash().substring(0, 2) + "/" + ((AssetsObject) entry.getValue()).getHash());
|
||||
File original = assetObjectPath(assetsDir, (AssetsObject) entry.getValue());
|
||||
if (original.exists()) {
|
||||
cnt++;
|
||||
if (!target.isFile())
|
||||
@@ -205,6 +206,15 @@ public class MinecraftAssetService extends IMinecraftAssetService {
|
||||
return virtualRoot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getAssetObject(String assetId, AssetsObject object) {
|
||||
return assetObjectPath(getAssets(assetId), object);
|
||||
}
|
||||
|
||||
public File assetObjectPath(File assetDir, AssetsObject object) {
|
||||
return new File(assetDir, "objects/" + object.getLocation());
|
||||
}
|
||||
|
||||
public final IAssetProvider ASSET_PROVIDER_IMPL = (t, allow) -> {
|
||||
if (allow && !checkAssetsExistance(t.getAssetsIndex()))
|
||||
if (MessageBox.show(C.i18n("assets.no_assets"), MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION)
|
||||
|
||||
@@ -85,7 +85,7 @@ public class MinecraftLoader extends AbstractMinecraftLoader {
|
||||
t = t.replace("${version_type}", options.getType());
|
||||
t = t.replace("${game_directory}", service.version().getRunDirectory(version.id).getAbsolutePath());
|
||||
t = t.replace("${game_assets}", game_assets);
|
||||
t = t.replace("${assets_root}", service.asset().getAssets().getAbsolutePath());
|
||||
t = t.replace("${assets_root}", service.asset().getAssets(version.getAssetsIndex().getId()).getAbsolutePath());
|
||||
t = t.replace("${auth_access_token}", lr.getAccessToken());
|
||||
t = t.replace("${user_type}", lr.getUserType());
|
||||
t = t.replace("${assets_index_name}", version.getAssetsIndex().getId());
|
||||
|
||||
@@ -20,6 +20,7 @@ package org.jackhuang.hellominecraft.launcher.core.service;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import org.jackhuang.hellominecraft.launcher.core.GameException;
|
||||
import org.jackhuang.hellominecraft.launcher.core.asset.AssetsObject;
|
||||
import org.jackhuang.hellominecraft.launcher.core.version.AssetIndexDownloadInfo;
|
||||
import org.jackhuang.hellominecraft.util.task.Task;
|
||||
|
||||
@@ -35,20 +36,24 @@ public abstract class IMinecraftAssetService extends IMinecraftBasicService {
|
||||
|
||||
public abstract Task downloadAssets(String mcVersion) throws GameException;
|
||||
|
||||
public abstract File getAssets();
|
||||
public abstract File getAssets(String assetId);
|
||||
|
||||
public abstract File getIndexFile(String assetId);
|
||||
|
||||
/**
|
||||
* Redownload the Asset index json of the given version.
|
||||
*
|
||||
* @param a the given version name
|
||||
* @param mcVersion the given version name
|
||||
*
|
||||
* @return Is the action successful?
|
||||
*/
|
||||
public abstract boolean refreshAssetsIndex(String a) throws GameException;
|
||||
public abstract boolean refreshAssetsIndex(String mcVersion) throws GameException;
|
||||
|
||||
public abstract boolean downloadMinecraftAssetsIndexAsync(AssetIndexDownloadInfo assetsId);
|
||||
public abstract boolean downloadMinecraftAssetsIndexAsync(AssetIndexDownloadInfo assetId);
|
||||
|
||||
public abstract Task downloadMinecraftAssetsIndex(AssetIndexDownloadInfo assetsId);
|
||||
public abstract Task downloadMinecraftAssetsIndex(AssetIndexDownloadInfo assetId);
|
||||
|
||||
public abstract File getAssetObject(String assetVersion, String name) throws IOException;
|
||||
|
||||
public abstract File getAssetObject(String assetId, AssetsObject assetsObject);
|
||||
}
|
||||
|
||||
@@ -40,10 +40,6 @@ public class AssetIndexDownloadInfo extends GameDownloadInfo {
|
||||
return dt.getProvider().getIndexesDownloadURL() + id + ".json";
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public int getTotalSize() {
|
||||
return totalSize;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public class GameDownloadInfo implements Cloneable {
|
||||
/**
|
||||
* Ready for AssetIndexDownloadInfo, and GameDownloadInfo also need this.
|
||||
*/
|
||||
public String id = null;
|
||||
protected String id;
|
||||
|
||||
/**
|
||||
* Get the game download url.
|
||||
@@ -68,6 +68,10 @@ public class GameDownloadInfo implements Cloneable {
|
||||
return dt.getProvider().getVersionsDownloadURL() + id + "/" + id + ".jar";
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() {
|
||||
try {
|
||||
|
||||
@@ -21,9 +21,12 @@ import com.google.gson.annotations.SerializedName;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import org.jackhuang.hellominecraft.api.HMCLAPI;
|
||||
import org.jackhuang.hellominecraft.launcher.api.event.version.MinecraftLibraryPathEvent;
|
||||
import org.jackhuang.hellominecraft.util.sys.OS;
|
||||
import org.jackhuang.hellominecraft.util.sys.Platform;
|
||||
import org.jackhuang.hellominecraft.util.StrUtils;
|
||||
import org.jackhuang.hellominecraft.util.Wrapper;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -104,7 +107,9 @@ public class MinecraftLibrary extends IMinecraftLibrary {
|
||||
LibraryDownloadInfo info = getDownloadInfo();
|
||||
if (info == null)
|
||||
return null;
|
||||
return new File(gameDir, "libraries/" + info.path);
|
||||
MinecraftLibraryPathEvent event = new MinecraftLibraryPathEvent(this, "libraries/" + info.path, new Wrapper<>(new File(gameDir, "libraries/" + info.path)));
|
||||
HMCLAPI.EVENT_BUS.fireChannel(event);
|
||||
return event.getFile().getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -31,6 +31,7 @@ import org.jackhuang.hellominecraft.api.HMCLAPI;
|
||||
import org.jackhuang.hellominecraft.launcher.api.event.config.AuthenticatorChangedEvent;
|
||||
import org.jackhuang.hellominecraft.launcher.api.event.config.DownloadTypeChangedEvent;
|
||||
import org.jackhuang.hellominecraft.launcher.api.event.config.ThemeChangedEvent;
|
||||
import org.jackhuang.hellominecraft.launcher.core.MCUtils;
|
||||
import org.jackhuang.hellominecraft.util.sys.JdkVersion;
|
||||
import org.jackhuang.hellominecraft.util.sys.OS;
|
||||
|
||||
@@ -44,6 +45,8 @@ public final class Config implements Cloneable {
|
||||
private String last;
|
||||
@SerializedName("bgpath")
|
||||
private String bgpath;
|
||||
@SerializedName("commonpath")
|
||||
private String commonpath;
|
||||
@SerializedName("clientToken")
|
||||
private final String clientToken;
|
||||
@SerializedName("proxyHost")
|
||||
@@ -152,6 +155,15 @@ public final class Config implements Cloneable {
|
||||
Settings.save();
|
||||
}
|
||||
|
||||
public String getCommonpath() {
|
||||
return commonpath;
|
||||
}
|
||||
|
||||
public void setCommonpath(String commonpath) {
|
||||
this.commonpath = commonpath;
|
||||
Settings.save();
|
||||
}
|
||||
|
||||
public String getClientToken() {
|
||||
return clientToken;
|
||||
}
|
||||
@@ -210,6 +222,7 @@ public final class Config implements Cloneable {
|
||||
theme = 4;
|
||||
decorated = OS.os() == OS.LINUX;
|
||||
auth = new HashMap<>();
|
||||
commonpath = MCUtils.getWorkingDirectory("hmcl").getAbsolutePath();
|
||||
}
|
||||
|
||||
public DownloadType getDownloadSource() {
|
||||
|
||||
@@ -87,7 +87,7 @@ public final class GameSettingsPanel extends RepaintPage implements DropTargetLi
|
||||
|
||||
public GameSettingsPanel() {
|
||||
HMCLAPI.EVENT_BUS.channel(RefreshedVersionsEvent.class).register(t -> {
|
||||
if (Settings.getLastProfile().service() == t.getValue())
|
||||
if (Settings.getLastProfile().service() == t.getValue() && t.getValue().version().getVersions().isEmpty())
|
||||
if (!showedNoVersion && Settings.getLastProfile().service().checkingModpack) {
|
||||
showedNoVersion = true;
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<Component id="lblProxy" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<Component id="lblProxyHost" min="-2" max="-2" attributes="0"/>
|
||||
@@ -38,35 +38,9 @@
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="txtProxyPassword" min="-2" pref="80" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="lblDownloadSource" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="lblTheme" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="lblBackground" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="lblLang" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="cboLang" max="32767" attributes="0"/>
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<Component id="txtBackgroundPath" pref="664" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="btnSelBackgroundPath" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="cboDownloadSource" alignment="1" max="32767" attributes="0"/>
|
||||
<Component id="cboTheme" alignment="1" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<Group type="102" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="btnCheckUpdate" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="btnMCBBS" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="lblAbout" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="lblModpack" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="lblRestart" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="chkDecorated" min="-2" max="-2" attributes="0"/>
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="chkEnableShadow" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
@@ -74,10 +48,42 @@
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="chkEnableAnimation" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="chkDecorated" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="lblAbout" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="btnCheckUpdate" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="btnMCBBS" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="lblModpack" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="lblRestart" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="lblDownloadSource" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="lblTheme" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="lblBackground" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="lblLang" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="lblCommonPath" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="txtCommonPath" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="btnSetCommonPath" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="cboLang" max="32767" attributes="0"/>
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<Component id="txtBackgroundPath" pref="585" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="btnSelBackgroundPath" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="cboDownloadSource" alignment="1" max="32767" attributes="0"/>
|
||||
<Component id="cboTheme" alignment="1" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
@@ -86,6 +92,12 @@
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="lblCommonPath" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="txtCommonPath" alignment="3" min="-2" pref="26" max="-2" attributes="0"/>
|
||||
<Component id="btnSetCommonPath" alignment="3" min="-2" pref="26" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="lblBackground" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
@@ -127,7 +139,7 @@
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="chkDecorated" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace pref="6" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="btnCheckUpdate" alignment="3" min="-2" pref="26" max="-2" attributes="0"/>
|
||||
<Component id="btnMCBBS" alignment="3" max="32767" attributes="0"/>
|
||||
@@ -138,7 +150,7 @@
|
||||
<Component id="lblModpack" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="lblAbout" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
@@ -367,5 +379,29 @@
|
||||
<EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="chkEnableAnimationItemStateChanged"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="lblCommonPath">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/jackhuang/hellominecraft/lang/I18N.properties" key="launcher.common_location" replaceFormat="C.i18n("{key}")"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="txtCommonPath">
|
||||
<Properties>
|
||||
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/jackhuang/hellominecraft/lang/I18N.properties" key="launcher.commpath_tooltip" replaceFormat="C.i18n("{key}")"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="btnSetCommonPath">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/jackhuang/hellominecraft/lang/I18N.properties" key="ui.button.explore" replaceFormat="C.i18n("{key}")"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnSetCommonPathActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
||||
|
||||
@@ -64,6 +64,7 @@ public class LauncherSettingsPanel extends RepaintPage {
|
||||
cboLang.setSelectedIndex(id);
|
||||
|
||||
txtBackgroundPath.setText(Settings.getInstance().getBgpath());
|
||||
txtCommonPath.setText(Settings.getInstance().getCommonpath());
|
||||
txtProxyHost.setText(Settings.getInstance().getProxyHost());
|
||||
txtProxyPort.setText(Settings.getInstance().getProxyPort());
|
||||
txtProxyUsername.setText(Settings.getInstance().getProxyUserName());
|
||||
@@ -118,6 +119,9 @@ public class LauncherSettingsPanel extends RepaintPage {
|
||||
btnMCBBS = new javax.swing.JButton();
|
||||
chkEnableBlur = new javax.swing.JCheckBox();
|
||||
chkEnableAnimation = new javax.swing.JCheckBox();
|
||||
lblCommonPath = new javax.swing.JLabel();
|
||||
txtCommonPath = new javax.swing.JTextField();
|
||||
btnSetCommonPath = new javax.swing.JButton();
|
||||
|
||||
cboDownloadSource.addItemListener(new java.awt.event.ItemListener() {
|
||||
public void itemStateChanged(java.awt.event.ItemEvent evt) {
|
||||
@@ -252,6 +256,17 @@ public class LauncherSettingsPanel extends RepaintPage {
|
||||
}
|
||||
});
|
||||
|
||||
lblCommonPath.setText(C.i18n("launcher.common_location")); // NOI18N
|
||||
|
||||
txtCommonPath.setToolTipText(C.i18n("launcher.commpath_tooltip")); // NOI18N
|
||||
|
||||
btnSetCommonPath.setText(C.i18n("ui.button.explore")); // NOI18N
|
||||
btnSetCommonPath.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
btnSetCommonPathActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
@@ -259,7 +274,7 @@ public class LauncherSettingsPanel extends RepaintPage {
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addComponent(lblProxy)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(lblProxyHost)
|
||||
@@ -279,42 +294,52 @@ public class LauncherSettingsPanel extends RepaintPage {
|
||||
.addComponent(txtProxyPassword, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(lblDownloadSource)
|
||||
.addComponent(lblTheme)
|
||||
.addComponent(lblBackground)
|
||||
.addComponent(lblLang))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(cboLang, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addComponent(txtBackgroundPath, javax.swing.GroupLayout.DEFAULT_SIZE, 664, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(btnSelBackgroundPath))
|
||||
.addComponent(cboDownloadSource, javax.swing.GroupLayout.Alignment.TRAILING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(cboTheme, javax.swing.GroupLayout.Alignment.TRAILING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(btnCheckUpdate)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(btnMCBBS))
|
||||
.addComponent(lblAbout, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(lblModpack, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(lblRestart)
|
||||
.addComponent(chkDecorated)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(chkEnableShadow)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(chkEnableBlur)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(chkEnableAnimation))
|
||||
.addComponent(chkDecorated))
|
||||
.addGap(0, 0, Short.MAX_VALUE)))
|
||||
.addComponent(lblAbout, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(btnCheckUpdate)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(btnMCBBS))
|
||||
.addComponent(lblModpack, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(lblRestart))
|
||||
.addGap(0, 0, Short.MAX_VALUE))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(lblDownloadSource)
|
||||
.addComponent(lblTheme)
|
||||
.addComponent(lblBackground)
|
||||
.addComponent(lblLang)
|
||||
.addComponent(lblCommonPath))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(txtCommonPath)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(btnSetCommonPath))
|
||||
.addComponent(cboLang, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addComponent(txtBackgroundPath, javax.swing.GroupLayout.DEFAULT_SIZE, 585, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(btnSelBackgroundPath))
|
||||
.addComponent(cboDownloadSource, javax.swing.GroupLayout.Alignment.TRAILING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(cboTheme, javax.swing.GroupLayout.Alignment.TRAILING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
|
||||
.addContainerGap())
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(lblCommonPath)
|
||||
.addComponent(txtCommonPath, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(btnSetCommonPath, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(lblBackground)
|
||||
.addComponent(btnSelBackgroundPath, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
@@ -349,7 +374,7 @@ public class LauncherSettingsPanel extends RepaintPage {
|
||||
.addComponent(chkEnableAnimation))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(chkDecorated)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 6, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(btnCheckUpdate, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(btnMCBBS, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
@@ -447,10 +472,29 @@ public class LauncherSettingsPanel extends RepaintPage {
|
||||
Settings.getInstance().setEnableAnimation(chkEnableAnimation.isSelected());
|
||||
}//GEN-LAST:event_chkEnableAnimationItemStateChanged
|
||||
|
||||
private void btnSetCommonPathActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSetCommonPathActionPerformed
|
||||
JSystemFileChooser fc = new JSystemFileChooser();
|
||||
fc.setFileSelectionMode(JSystemFileChooser.DIRECTORIES_ONLY);
|
||||
fc.setDialogTitle(C.i18n("launcher.choose_commonpath"));
|
||||
fc.setMultiSelectionEnabled(false);
|
||||
fc.showOpenDialog(this);
|
||||
if (fc.getSelectedFile() == null)
|
||||
return;
|
||||
try {
|
||||
String path = fc.getSelectedFile().getCanonicalPath();
|
||||
txtCommonPath.setText(path);
|
||||
Settings.getInstance().setCommonpath(path);
|
||||
} catch (IOException e) {
|
||||
HMCLog.warn("Failed to set common path.", e);
|
||||
MessageBox.show(C.i18n("ui.label.failed_set") + e.getMessage());
|
||||
}
|
||||
}//GEN-LAST:event_btnSetCommonPathActionPerformed
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton btnCheckUpdate;
|
||||
private javax.swing.JButton btnMCBBS;
|
||||
private javax.swing.JButton btnSelBackgroundPath;
|
||||
private javax.swing.JButton btnSetCommonPath;
|
||||
private javax.swing.JComboBox cboDownloadSource;
|
||||
private javax.swing.JComboBox cboLang;
|
||||
private javax.swing.JComboBox cboTheme;
|
||||
@@ -460,6 +504,7 @@ public class LauncherSettingsPanel extends RepaintPage {
|
||||
private javax.swing.JCheckBox chkEnableShadow;
|
||||
private javax.swing.JLabel lblAbout;
|
||||
private javax.swing.JLabel lblBackground;
|
||||
private javax.swing.JLabel lblCommonPath;
|
||||
private javax.swing.JLabel lblDownloadSource;
|
||||
private javax.swing.JLabel lblLang;
|
||||
private javax.swing.JLabel lblModpack;
|
||||
@@ -471,6 +516,7 @@ public class LauncherSettingsPanel extends RepaintPage {
|
||||
private javax.swing.JLabel lblRestart;
|
||||
private javax.swing.JLabel lblTheme;
|
||||
private javax.swing.JTextField txtBackgroundPath;
|
||||
private javax.swing.JTextField txtCommonPath;
|
||||
private javax.swing.JTextField txtProxyHost;
|
||||
private javax.swing.JTextField txtProxyPassword;
|
||||
private javax.swing.JTextField txtProxyPort;
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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.launcher.util;
|
||||
|
||||
import java.io.File;
|
||||
import org.jackhuang.hellominecraft.launcher.core.asset.MinecraftAssetService;
|
||||
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftService;
|
||||
import org.jackhuang.hellominecraft.launcher.setting.Settings;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author huang
|
||||
*/
|
||||
public class HMCLAssetService extends MinecraftAssetService {
|
||||
|
||||
public HMCLAssetService(IMinecraftService service) {
|
||||
super(service);
|
||||
}
|
||||
|
||||
private boolean useSelf(String assetId) {
|
||||
return new File(service.baseDirectory(), "assets/indexes/" + assetId + ",json").exists();
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getAssets(String assetId) {
|
||||
if (useSelf(assetId))
|
||||
return new File(service.baseDirectory(), "assets");
|
||||
else
|
||||
return new File(Settings.getInstance().getCommonpath(), "assets");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -18,8 +18,11 @@
|
||||
package org.jackhuang.hellominecraft.launcher.util;
|
||||
|
||||
import java.io.File;
|
||||
import org.jackhuang.hellominecraft.api.HMCLAPI;
|
||||
import org.jackhuang.hellominecraft.launcher.api.event.version.MinecraftLibraryPathEvent;
|
||||
import org.jackhuang.hellominecraft.launcher.core.version.GameDirType;
|
||||
import org.jackhuang.hellominecraft.launcher.core.version.MinecraftVersionManager;
|
||||
import org.jackhuang.hellominecraft.launcher.setting.Settings;
|
||||
import org.jackhuang.hellominecraft.launcher.setting.VersionSetting;
|
||||
|
||||
/**
|
||||
@@ -30,6 +33,11 @@ public class HMCLGameProvider extends MinecraftVersionManager {
|
||||
|
||||
public HMCLGameProvider(HMCLMinecraftService p) {
|
||||
super(p);
|
||||
|
||||
HMCLAPI.EVENT_BUS.channel(MinecraftLibraryPathEvent.class).register(t -> {
|
||||
if (!t.getFile().getValue().exists())
|
||||
t.getFile().setValue(new File(Settings.getInstance().getCommonpath(), t.getLocation()));
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -75,7 +75,7 @@ public class HMCLMinecraftService extends IMinecraftService {
|
||||
HMCLAPI.EVENT_BUS.channel(LoadedOneVersionEvent.class).register(e -> loadVersionSetting(e.getValue()));
|
||||
this.mms = new MinecraftModService(this);
|
||||
this.mds = new MinecraftDownloadService(this);
|
||||
this.mas = new MinecraftAssetService(this);
|
||||
this.mas = new HMCLAssetService(this);
|
||||
this.mis = new MinecraftInstallerService(this);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user