Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2f3c8285c8 | ||
|
|
cfa7b4832a |
No files matched your search
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -135,6 +135,8 @@ public class MinecraftAssetService extends IMinecraftAssetService {
|
||||
public File getAssetObject(String assetId, String name) throws IOException {
|
||||
try {
|
||||
AssetsIndex index = (AssetsIndex) C.GSON.fromJson(FileUtils.read(getIndexFile(assetId), "UTF-8"), AssetsIndex.class);
|
||||
if (index == null || index.getFileMap() == null || index.getFileMap().get(name) == null)
|
||||
throw new IOException("Assets file format malformed.");
|
||||
return getAssetObject(assetId, (AssetsObject) index.getFileMap().get(name));
|
||||
} catch (JsonSyntaxException e) {
|
||||
throw new IOException("Assets file format malformed.", e);
|
||||
|
||||
@@ -59,7 +59,12 @@ public final class OfflineAuthenticator extends AbstractAuthenticator {
|
||||
public UserProfileProvider login(LoginInfo info) throws AuthenticationException {
|
||||
if (StrUtils.isBlank(info.username))
|
||||
throw new AuthenticationException(C.i18n("login.no_Player007"));
|
||||
String uuid = getUUIDFromUserName(info.username);
|
||||
String uuid;
|
||||
try {
|
||||
uuid = getUUIDFromUserName(info.username);
|
||||
} catch(IllegalArgumentException e) {
|
||||
throw new AuthenticationException("Could not find md5 digest algorithm, please reinstall Java or even your OS.", e);
|
||||
}
|
||||
if (uuidMap != null && uuidMap.containsKey(info.username) && uuidMap.get(info.username) instanceof String)
|
||||
uuid = (String) uuidMap.get(info.username);
|
||||
else {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import java.awt.BorderLayout;
|
||||
import java.awt.Component;
|
||||
import java.awt.Frame;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.GraphicsDevice;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.awt.Window;
|
||||
|
||||
@@ -182,10 +183,14 @@ public class TranslucentPopupFactory extends PopupFactory {
|
||||
boolean isComboBoxPopup = (contents instanceof BasicComboPopup);
|
||||
|
||||
if (WindowTranslucencyHelper.isTranslucencySupported()) {
|
||||
//每像素透明
|
||||
WindowTranslucencyHelper.setWindowOpaque(w, false);
|
||||
//内容组件半透明
|
||||
w.setOpacity(isTooltip ? 1.0f : isComboBoxPopup ? 0.95f : 0.95f);//0.85f : 0.95f);//0.8f : 0.95f);
|
||||
try {
|
||||
//每像素透明
|
||||
WindowTranslucencyHelper.setWindowOpaque(w, false);
|
||||
//内容组件半透明
|
||||
w.setOpacity(isTooltip ? 1.0f : isComboBoxPopup ? 0.95f : 0.95f);//0.85f : 0.95f);//0.8f : 0.95f);
|
||||
} catch(Exception e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
// component.getContentPane().add(contents, BorderLayout.CENTER);
|
||||
|
||||
@@ -27,7 +27,9 @@ public class WindowTranslucencyHelper {
|
||||
* @return true, if is translucency supported
|
||||
*/
|
||||
public static boolean isTranslucencySupported() {
|
||||
return GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency.TRANSLUCENT);
|
||||
GraphicsDevice device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
|
||||
return device.isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency.TRANSLUCENT) &&
|
||||
device.isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSLUCENT);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ apply plugin: 'maven'
|
||||
|
||||
dependencies {
|
||||
compile 'com.google.code.gson:gson:2.2.4' // Apache License 2.0
|
||||
compile "org.jetbrains.kotlin:kotlin-stdlib:1.1.2"
|
||||
//compile "org.jetbrains.kotlin:kotlin-stdlib:1.1.2"
|
||||
}
|
||||
|
||||
task sourcesJar(type: Jar, dependsOn: classes, description: 'Creates a jar from the source files.') {
|
||||
|
||||
Reference in new issue
Block a user