diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/setting/Config.java b/HMCL/src/main/java/org/jackhuang/hmcl/setting/Config.java index a8a85f3de..3037a7621 100755 --- a/HMCL/src/main/java/org/jackhuang/hmcl/setting/Config.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/setting/Config.java @@ -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 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; diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/util/HMCLAssetService.java b/HMCL/src/main/java/org/jackhuang/hmcl/util/HMCLAssetService.java index 333e93b06..08245ae5c 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/util/HMCLAssetService.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/util/HMCLAssetService.java @@ -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 diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/util/HMCLGameProvider.java b/HMCL/src/main/java/org/jackhuang/hmcl/util/HMCLGameProvider.java index 6dbaa16a9..b94e72668 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/util/HMCLGameProvider.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/util/HMCLGameProvider.java @@ -29,7 +29,7 @@ import org.jackhuang.hmcl.setting.VersionSetting; * * @author huangyuhui */ -public class HMCLGameProvider extends MinecraftVersionManager { +public class HMCLGameProvider extends MinecraftVersionManager { 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 diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/util/HMCLMinecraftService.java b/HMCL/src/main/java/org/jackhuang/hmcl/util/HMCLMinecraftService.java index b88694887..9780f6ec5 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/util/HMCLMinecraftService.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/util/HMCLMinecraftService.java @@ -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 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; } diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/core/service/IMinecraftProvider.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/core/service/IMinecraftProvider.java index 929e25e6d..1f16c1a08 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/core/service/IMinecraftProvider.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/core/service/IMinecraftProvider.java @@ -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 { - protected IMinecraftService service; + protected T service; - public IMinecraftProvider(IMinecraftService service) { + public IMinecraftProvider(T service) { this.service = service; } diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/core/version/MinecraftClassicVersion.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/core/version/MinecraftClassicVersion.java index 74ce888c5..9d7df9cc2 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/core/version/MinecraftClassicVersion.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/core/version/MinecraftClassicVersion.java @@ -48,7 +48,7 @@ public class MinecraftClassicVersion extends MinecraftVersion { } @Override - public MinecraftVersion resolve(IMinecraftProvider manager, Set resolvedSoFar) { + public MinecraftVersion resolve(IMinecraftProvider manager, Set resolvedSoFar) { return this; } diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/core/version/MinecraftVersion.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/core/version/MinecraftVersion.java index 98d0d9775..5bd23d43a 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/core/version/MinecraftVersion.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/core/version/MinecraftVersion.java @@ -122,11 +122,11 @@ public class MinecraftVersion implements Cloneable, Comparable } } - 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 resolvedSoFar) throws GameException { + protected MinecraftVersion resolve(IMinecraftProvider provider, Set resolvedSoFar) throws GameException { if (inheritsFrom == null) return this; if (!resolvedSoFar.add(id)) diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/core/version/MinecraftVersionManager.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/core/version/MinecraftVersionManager.java index e90dac523..f2f4493ca 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/core/version/MinecraftVersionManager.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/core/version/MinecraftVersionManager.java @@ -50,7 +50,7 @@ import org.jackhuang.hmcl.util.ui.SwingUtils; * * @author huangyuhui */ -public class MinecraftVersionManager extends IMinecraftProvider { +public class MinecraftVersionManager extends IMinecraftProvider { final Map versions = new TreeMap<>(); @@ -58,7 +58,7 @@ public class MinecraftVersionManager extends IMinecraftProvider { * * @param p */ - public MinecraftVersionManager(IMinecraftService p) { + public MinecraftVersionManager(T p) { super(p); }