mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-01-12 14:14:52 +08:00
Fixed #153
This commit is contained in:
parent
cfa7b4832a
commit
2f3c8285c8
@ -87,6 +87,24 @@ public final class Config implements Cloneable {
|
||||
@SerializedName("fontSize")
|
||||
private int fontSize;
|
||||
|
||||
public Config() {
|
||||
clientToken = UUID.randomUUID().toString();
|
||||
logintype = downloadtype = 0;
|
||||
enableAnimation = enableBlur = true;
|
||||
if (OS.os() == OS.WINDOWS)
|
||||
enableShadow = true;
|
||||
theme = LAFTheme.BLUE.id;
|
||||
decorated = OS.os() == OS.LINUX;
|
||||
auth = new HashMap<>();
|
||||
Font font = Font.decode("Consolas");
|
||||
if (font == null)
|
||||
font = Font.decode("Monospace");
|
||||
if (font != null)
|
||||
fontFamily = font.getFamily();
|
||||
fontSize = 12;
|
||||
commonpath = MCUtils.getLocation().getPath();
|
||||
}
|
||||
|
||||
public List<JdkVersion> getJava() {
|
||||
return java == null ? java = new ArrayList<>() : java;
|
||||
}
|
||||
@ -222,24 +240,6 @@ public final class Config implements Cloneable {
|
||||
Settings.save();
|
||||
}
|
||||
|
||||
public Config() {
|
||||
clientToken = UUID.randomUUID().toString();
|
||||
logintype = downloadtype = 0;
|
||||
enableAnimation = enableBlur = true;
|
||||
if (OS.os() == OS.WINDOWS)
|
||||
enableShadow = true;
|
||||
theme = LAFTheme.BLUE.id;
|
||||
decorated = OS.os() == OS.LINUX;
|
||||
auth = new HashMap<>();
|
||||
Font font = Font.decode("Consolas");
|
||||
if (font == null)
|
||||
font = Font.decode("Monospace");
|
||||
if (font != null)
|
||||
fontFamily = font.getFamily();
|
||||
fontSize = 12;
|
||||
commonpath = MCUtils.getLocation().getPath();
|
||||
}
|
||||
|
||||
public DownloadType getDownloadSource() {
|
||||
if (downloadtype >= DownloadType.values().length || downloadtype < 0) {
|
||||
downloadtype = 0;
|
||||
|
@ -33,7 +33,7 @@ public class HMCLAssetService extends MinecraftAssetService {
|
||||
}
|
||||
|
||||
private boolean useSelf(String assetId) {
|
||||
return new File(service.baseDirectory(), "assets/indexes/" + assetId + ".json").exists() || ((HMCLMinecraftService) service).p.isNoCommon();
|
||||
return new File(service.baseDirectory(), "assets/indexes/" + assetId + ".json").exists() || ((HMCLMinecraftService) service).getProfile().isNoCommon();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -29,7 +29,7 @@ import org.jackhuang.hmcl.setting.VersionSetting;
|
||||
*
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public class HMCLGameProvider extends MinecraftVersionManager {
|
||||
public class HMCLGameProvider extends MinecraftVersionManager<HMCLMinecraftService> {
|
||||
|
||||
public HMCLGameProvider(HMCLMinecraftService p) {
|
||||
super(p);
|
||||
@ -37,9 +37,9 @@ public class HMCLGameProvider extends MinecraftVersionManager {
|
||||
|
||||
@Override
|
||||
public File getLibraryFile(MinecraftVersion version, IMinecraftLibrary lib) {
|
||||
VersionSetting vs = ((HMCLMinecraftService) service).getVersionSetting(version.id);
|
||||
VersionSetting vs = service.getProfile().getVersionSetting(version.id);
|
||||
File self = super.getLibraryFile(version, lib);
|
||||
if (self.exists() || (vs != null && ((HMCLMinecraftService) service).p.isNoCommon()))
|
||||
if (self.exists() || (vs != null && service.getProfile().isNoCommon()))
|
||||
return self;
|
||||
else
|
||||
return lib.getFilePath(new File(Settings.getInstance().getCommonpath()));
|
||||
@ -47,7 +47,7 @@ public class HMCLGameProvider extends MinecraftVersionManager {
|
||||
|
||||
@Override
|
||||
public File getRunDirectory(String id) {
|
||||
VersionSetting vs = ((HMCLMinecraftService) service).getVersionSetting(id);
|
||||
VersionSetting vs = service.getProfile().getVersionSetting(id);
|
||||
if (vs == null)
|
||||
return super.getRunDirectory(id);
|
||||
else
|
||||
|
@ -18,12 +18,8 @@
|
||||
package org.jackhuang.hmcl.util;
|
||||
|
||||
import org.jackhuang.hmcl.core.service.IMinecraftService;
|
||||
import org.jackhuang.hmcl.core.service.IMinecraftAssetService;
|
||||
import org.jackhuang.hmcl.core.service.IMinecraftLoader;
|
||||
import org.jackhuang.hmcl.core.service.IMinecraftDownloadService;
|
||||
import org.jackhuang.hmcl.core.service.IMinecraftProvider;
|
||||
import org.jackhuang.hmcl.core.service.IMinecraftModService;
|
||||
import org.jackhuang.hmcl.core.service.IMinecraftInstallerService;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
@ -35,7 +31,6 @@ import org.jackhuang.hmcl.api.event.version.RefreshedVersionsEvent;
|
||||
import org.jackhuang.hmcl.api.event.version.RefreshingVersionsEvent;
|
||||
import org.jackhuang.hmcl.core.GameException;
|
||||
import org.jackhuang.hmcl.core.install.MinecraftInstallerService;
|
||||
import org.jackhuang.hmcl.core.asset.MinecraftAssetService;
|
||||
import org.jackhuang.hmcl.api.auth.UserProfileProvider;
|
||||
import org.jackhuang.hmcl.core.download.MinecraftDownloadService;
|
||||
import org.jackhuang.hmcl.api.game.LaunchOptions;
|
||||
@ -55,7 +50,7 @@ import org.jackhuang.hmcl.util.task.TaskWindow;
|
||||
*/
|
||||
public class HMCLMinecraftService extends IMinecraftService {
|
||||
|
||||
Profile p;
|
||||
private Profile p;
|
||||
final Map<String, VersionSetting> versionSettings = new HashMap<>();
|
||||
|
||||
public HMCLMinecraftService(Profile p) {
|
||||
@ -143,10 +138,10 @@ public class HMCLMinecraftService extends IMinecraftService {
|
||||
return p.getGameDir();
|
||||
}
|
||||
|
||||
protected IMinecraftProvider provider;
|
||||
protected HMCLGameProvider provider;
|
||||
|
||||
@Override
|
||||
public IMinecraftProvider version() {
|
||||
public HMCLGameProvider version() {
|
||||
return provider;
|
||||
}
|
||||
|
||||
@ -160,21 +155,21 @@ public class HMCLMinecraftService extends IMinecraftService {
|
||||
protected MinecraftDownloadService mds;
|
||||
|
||||
@Override
|
||||
public IMinecraftDownloadService download() {
|
||||
public MinecraftDownloadService download() {
|
||||
return mds;
|
||||
}
|
||||
|
||||
final MinecraftAssetService mas;
|
||||
final HMCLAssetService mas;
|
||||
|
||||
@Override
|
||||
public IMinecraftAssetService asset() {
|
||||
public HMCLAssetService asset() {
|
||||
return mas;
|
||||
}
|
||||
|
||||
protected MinecraftInstallerService mis;
|
||||
|
||||
@Override
|
||||
public IMinecraftInstallerService install() {
|
||||
public MinecraftInstallerService install() {
|
||||
return mis;
|
||||
}
|
||||
|
||||
|
@ -33,11 +33,11 @@ import org.jackhuang.hmcl.api.game.IMinecraftLibrary;
|
||||
* org.jackhuang.hmcl.core.version.MinecraftVersionManager
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public abstract class IMinecraftProvider {
|
||||
public abstract class IMinecraftProvider<T extends IMinecraftService> {
|
||||
|
||||
protected IMinecraftService service;
|
||||
protected T service;
|
||||
|
||||
public IMinecraftProvider(IMinecraftService service) {
|
||||
public IMinecraftProvider(T service) {
|
||||
this.service = service;
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ public class MinecraftClassicVersion extends MinecraftVersion {
|
||||
}
|
||||
|
||||
@Override
|
||||
public MinecraftVersion resolve(IMinecraftProvider manager, Set<String> resolvedSoFar) {
|
||||
public MinecraftVersion resolve(IMinecraftProvider<?> manager, Set<String> resolvedSoFar) {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -122,11 +122,11 @@ public class MinecraftVersion implements Cloneable, Comparable<MinecraftVersion>
|
||||
}
|
||||
}
|
||||
|
||||
public MinecraftVersion resolve(IMinecraftProvider provider) throws GameException {
|
||||
public MinecraftVersion resolve(IMinecraftProvider<?> provider) throws GameException {
|
||||
return resolve(provider, new HashSet<>());
|
||||
}
|
||||
|
||||
protected MinecraftVersion resolve(IMinecraftProvider provider, Set<String> resolvedSoFar) throws GameException {
|
||||
protected MinecraftVersion resolve(IMinecraftProvider<?> provider, Set<String> resolvedSoFar) throws GameException {
|
||||
if (inheritsFrom == null)
|
||||
return this;
|
||||
if (!resolvedSoFar.add(id))
|
||||
|
@ -50,7 +50,7 @@ import org.jackhuang.hmcl.util.ui.SwingUtils;
|
||||
*
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public class MinecraftVersionManager extends IMinecraftProvider {
|
||||
public class MinecraftVersionManager<T extends IMinecraftService> extends IMinecraftProvider<T> {
|
||||
|
||||
final Map<String, MinecraftVersion> versions = new TreeMap<>();
|
||||
|
||||
@ -58,7 +58,7 @@ public class MinecraftVersionManager extends IMinecraftProvider {
|
||||
*
|
||||
* @param p
|
||||
*/
|
||||
public MinecraftVersionManager(IMinecraftService p) {
|
||||
public MinecraftVersionManager(T p) {
|
||||
super(p);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user