Reconstruct the codes.
This commit is contained in:
@@ -64,7 +64,7 @@ public abstract class AbstractMinecraftLoader implements IMinecraftLoader {
|
||||
|
||||
String str = v.getJavaDir();
|
||||
JdkVersion jv = new JdkVersion(str);
|
||||
if(Settings.getInstance().getJava().contains(jv))
|
||||
if (Settings.getInstance().getJava().contains(jv))
|
||||
jv = Settings.getInstance().getJava().get(Settings.getInstance().getJava().indexOf(jv));
|
||||
else try {
|
||||
jv = JdkVersion.getJavaVersionFromExecutable(str);
|
||||
@@ -153,11 +153,9 @@ public abstract class AbstractMinecraftLoader implements IMinecraftLoader {
|
||||
res.add(args.length > 1 ? args[1] : "25565");
|
||||
}
|
||||
|
||||
if (v.isFullscreen())
|
||||
res.add("--fullscreen");
|
||||
if (v.isFullscreen()) res.add("--fullscreen");
|
||||
|
||||
if (v.isDebug() && !v.isCanceledWrapper())
|
||||
res.add("-debug");
|
||||
if (v.isDebug() && !v.isCanceledWrapper()) res.add("-debug");
|
||||
|
||||
if (StrUtils.isNotBlank(v.getMinecraftArgs()))
|
||||
res.addAll(Arrays.asList(v.getMinecraftArgs().split(" ")));
|
||||
@@ -172,6 +170,7 @@ public abstract class AbstractMinecraftLoader implements IMinecraftLoader {
|
||||
* <li>main class</li>
|
||||
* <li>minecraft arguments</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param list the command list you shoud edit.
|
||||
*/
|
||||
protected abstract void makeSelf(List<String> list);
|
||||
|
||||
@@ -57,17 +57,12 @@ public class DefaultGameLauncher extends GameLauncher {
|
||||
return flag;
|
||||
});
|
||||
decompressNativesEvent.register((sender, value) -> {
|
||||
//boolean flag = true;
|
||||
for (int i = 0; i < value.decompressFiles.length; i++)
|
||||
try {
|
||||
Compressor.unzip(value.decompressFiles[i], value.decompressTo, value.extractRules[i]);
|
||||
} catch (IOException ex) {
|
||||
HMCLog.err("Unable to decompress library file: " + value.decompressFiles[i] + " to " + value.decompressTo, ex);
|
||||
//flag = false;
|
||||
}
|
||||
/*if(!flag)
|
||||
if(MessageBox.Show(C.i18n("launch.not_finished_decompressing_natives"), MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION)
|
||||
flag = true;*/
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -104,8 +104,14 @@ public class GameLauncher {
|
||||
File file = provider.getDecompressNativesToLocation();
|
||||
if (file != null) FileUtils.cleanDirectoryQuietly(file);
|
||||
|
||||
if(!downloadLibrariesEvent.execute(provider.getDownloadLibraries(downloadType))) { failEvent.execute(C.i18n("launch.failed")); return null; }
|
||||
if(!decompressNativesEvent.execute(provider.getDecompressLibraries())) { failEvent.execute(C.i18n("launch.failed")); return null; }
|
||||
if (!downloadLibrariesEvent.execute(provider.getDownloadLibraries(downloadType))) {
|
||||
failEvent.execute(C.i18n("launch.failed"));
|
||||
return null;
|
||||
}
|
||||
if (!decompressNativesEvent.execute(provider.getDecompressLibraries())) {
|
||||
failEvent.execute(C.i18n("launch.failed"));
|
||||
return null;
|
||||
}
|
||||
successEvent.execute(loader.makeLaunchingCommand());
|
||||
return loader;
|
||||
}
|
||||
@@ -185,6 +191,7 @@ public class GameLauncher {
|
||||
}
|
||||
|
||||
public static class DecompressLibraryJob {
|
||||
|
||||
File[] decompressFiles;
|
||||
String[][] extractRules;
|
||||
File decompressTo;
|
||||
|
||||
@@ -23,5 +23,6 @@ import java.util.List;
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public interface IMinecraftLoader {
|
||||
|
||||
List<String> makeLaunchingCommand();
|
||||
}
|
||||
|
||||
@@ -29,46 +29,64 @@ import org.jackhuang.hellominecraft.launcher.version.MinecraftVersion;
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public abstract class IMinecraftProvider {
|
||||
|
||||
Profile profile;
|
||||
|
||||
public IMinecraftProvider(Profile profile) {
|
||||
this.profile = profile;
|
||||
}
|
||||
|
||||
|
||||
public abstract File getRunDirectory(String id);
|
||||
|
||||
public abstract List<GameLauncher.DownloadLibraryJob> getDownloadLibraries(DownloadType type);
|
||||
|
||||
public abstract void openSelf(String version);
|
||||
|
||||
public abstract void open(String version, String folder);
|
||||
|
||||
public abstract File getAssets();
|
||||
|
||||
public abstract File getResourcePacks();
|
||||
|
||||
public abstract GameLauncher.DecompressLibraryJob getDecompressLibraries();
|
||||
|
||||
public abstract File getDecompressNativesToLocation();
|
||||
|
||||
public abstract File getMinecraftJar();
|
||||
|
||||
public abstract File getBaseFolder();
|
||||
|
||||
/**
|
||||
* Launch
|
||||
*
|
||||
* @param p player informations, including username & auth_token
|
||||
* @param type according to the class name 233
|
||||
* @return what you want
|
||||
* @throws IllegalStateException circular denpendency versions
|
||||
*/
|
||||
public abstract IMinecraftLoader provideMinecraftLoader(UserProfileProvider p, DownloadType type) throws IllegalStateException;
|
||||
|
||||
|
||||
// Versions
|
||||
public abstract boolean renameVersion(String from, String to);
|
||||
|
||||
public abstract boolean removeVersionFromDisk(String a);
|
||||
|
||||
public abstract boolean refreshJson(String a);
|
||||
|
||||
public abstract boolean refreshAssetsIndex(String a);
|
||||
|
||||
|
||||
public abstract MinecraftVersion getOneVersion();
|
||||
|
||||
public abstract Collection<MinecraftVersion> getVersions();
|
||||
|
||||
public abstract MinecraftVersion getVersionById(String id);
|
||||
|
||||
public abstract int getVersionCount();
|
||||
|
||||
public abstract void refreshVersions();
|
||||
|
||||
|
||||
public abstract boolean install(String version, DownloadType type);
|
||||
|
||||
|
||||
public abstract void onLaunch();
|
||||
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public class LaunchScriptFinisher implements Event<List<String>> {
|
||||
boolean flag = false;
|
||||
try {
|
||||
String s = JOptionPane.showInputDialog(C.i18n("mainwindow.enter_script_name"));
|
||||
if(s != null) MessageBox.Show(C.i18n("mainwindow.make_launch_succeed") + " " + ((GameLauncher)sender).makeLauncher(s, str).getAbsolutePath());
|
||||
if (s != null) MessageBox.Show(C.i18n("mainwindow.make_launch_succeed") + " " + ((GameLauncher) sender).makeLauncher(s, str).getAbsolutePath());
|
||||
flag = true;
|
||||
} catch (IOException ex) {
|
||||
MessageBox.Show(C.i18n("mainwindow.make_launch_script_failed"));
|
||||
|
||||
@@ -28,28 +28,27 @@ public final class MinecraftCrashAdvicer {
|
||||
public static String getAdvice(String trace) {
|
||||
return getAdvice(trace, false);
|
||||
}
|
||||
|
||||
|
||||
public static String getAdvice(String trace, boolean selfCrash) {
|
||||
trace = trace.toLowerCase();
|
||||
if(trace.contains("pixel format not accelerated")) {
|
||||
if (trace.contains("pixel format not accelerated"))
|
||||
return C.i18n("crash.advice.LWJGLException");
|
||||
} else if (trace.contains("unsupportedclassversionrrror")) {
|
||||
else if (trace.contains("unsupportedclassversionrrror"))
|
||||
return C.i18n("crash.advice.UnsupportedClassVersionError");
|
||||
} else if (trace.contains("concurrentmodificationexception")) {
|
||||
else if (trace.contains("concurrentmodificationexception"))
|
||||
return C.i18n("crash.advice.ConcurrentModificationException");
|
||||
} else if (trace.contains("securityexception")) {
|
||||
else if (trace.contains("securityexception"))
|
||||
return C.i18n("crash.advice.SecurityException");
|
||||
} else if (trace.contains("nosuchfieldexception") || trace.contains("nosuchfielderror")) {
|
||||
else if (trace.contains("nosuchfieldexception") || trace.contains("nosuchfielderror"))
|
||||
return C.i18n("crash.advice.NoSuchFieldError");
|
||||
} else if (trace.contains("outofmemory") || trace.contains("out of memory")) {
|
||||
else if (trace.contains("outofmemory") || trace.contains("out of memory"))
|
||||
return C.i18n("crash.advice.OutOfMemoryError");
|
||||
} else if (trace.contains("noclassdeffounderror") || trace.contains("classnotfoundexception")) {
|
||||
else if (trace.contains("noclassdeffounderror") || trace.contains("classnotfoundexception"))
|
||||
return C.i18n("crash.advice.ClassNotFoundException");
|
||||
} else if (trace.contains("no lwjgl in java.library.path")) {
|
||||
else if (trace.contains("no lwjgl in java.library.path"))
|
||||
return C.i18n("crash.advice.no_lwjgl");
|
||||
} else if (trace.contains("opengl") || trace.contains("openal")) {
|
||||
else if (trace.contains("opengl") || trace.contains("openal"))
|
||||
return C.i18n("crash.advice.OpenGL");
|
||||
}
|
||||
return C.i18n(selfCrash ? "crash.advice.no" : "crash.advice.otherwise");
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ import org.jackhuang.hellominecraft.utils.system.OS;
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public final class Config {
|
||||
|
||||
@SerializedName("last")
|
||||
private String last;
|
||||
@SerializedName("bgpath")
|
||||
@@ -119,7 +120,7 @@ public final class Config {
|
||||
}
|
||||
|
||||
public TreeMap<String, Profile> getConfigurations() {
|
||||
if(configurations == null)
|
||||
if (configurations == null)
|
||||
configurations = new TreeMap<>();
|
||||
return configurations;
|
||||
}
|
||||
@@ -141,7 +142,7 @@ public final class Config {
|
||||
this.yggdrasil = yggdrasil;
|
||||
Settings.save();
|
||||
}
|
||||
|
||||
|
||||
@SerializedName("logintype")
|
||||
private int logintype;
|
||||
@SerializedName("downloadtype")
|
||||
@@ -152,22 +153,21 @@ public final class Config {
|
||||
private boolean checkUpdate;
|
||||
@SerializedName("yggdrasil")
|
||||
private Map yggdrasil;
|
||||
|
||||
public Config()
|
||||
{
|
||||
|
||||
public Config() {
|
||||
clientToken = UUID.randomUUID().toString();
|
||||
username = "";
|
||||
logintype = downloadtype = 0;
|
||||
checkUpdate = true;
|
||||
configurations = new TreeMap<>();
|
||||
Profile profile = new Profile();
|
||||
configurations.put(profile.getName(), profile);
|
||||
configurations = new TreeMap<>();
|
||||
Profile profile = new Profile();
|
||||
configurations.put(profile.getName(), profile);
|
||||
enableShadow = OS.os() == OS.WINDOWS;
|
||||
theme = 0;
|
||||
}
|
||||
|
||||
public DownloadType getDownloadSource() {
|
||||
if(downloadtype >= DownloadType.values().length || downloadtype < 0) return null;
|
||||
if (downloadtype >= DownloadType.values().length || downloadtype < 0) return null;
|
||||
return DownloadType.values()[downloadtype];
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ package org.jackhuang.hellominecraft.launcher.settings;
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public enum LauncherVisibility {
|
||||
|
||||
CLOSE,
|
||||
HIDE,
|
||||
KEEP
|
||||
|
||||
@@ -53,32 +53,30 @@ public final class Profile {
|
||||
protected transient IMinecraftProvider minecraftProvider;
|
||||
|
||||
public Profile() {
|
||||
this("Default");
|
||||
this("Default");
|
||||
}
|
||||
|
||||
public Profile(String name) {
|
||||
this.name = name;
|
||||
gameDir = MCUtils.getInitGameDir().getPath();
|
||||
debug = fullscreen = canceledWrapper = false;
|
||||
javaDir = IOUtils.getJavaDir();
|
||||
launcherVisibility = gameDirType = 0;
|
||||
this.name = name;
|
||||
gameDir = MCUtils.getInitGameDir().getPath();
|
||||
debug = fullscreen = canceledWrapper = false;
|
||||
javaDir = IOUtils.getJavaDir();
|
||||
launcherVisibility = gameDirType = 0;
|
||||
minecraftArgs = serverIp = "";
|
||||
}
|
||||
|
||||
public Profile(Profile v) {
|
||||
this();
|
||||
if (v == null) {
|
||||
return;
|
||||
}
|
||||
name = v.name;
|
||||
gameDir = v.gameDir;
|
||||
maxMemory = v.maxMemory;
|
||||
width = v.width;
|
||||
height = v.height;
|
||||
fullscreen = v.fullscreen;
|
||||
javaArgs = v.javaArgs;
|
||||
javaDir = v.javaDir;
|
||||
debug = v.debug;
|
||||
this();
|
||||
if (v == null) return;
|
||||
name = v.name;
|
||||
gameDir = v.gameDir;
|
||||
maxMemory = v.maxMemory;
|
||||
width = v.width;
|
||||
height = v.height;
|
||||
fullscreen = v.fullscreen;
|
||||
javaArgs = v.javaArgs;
|
||||
javaDir = v.javaDir;
|
||||
debug = v.debug;
|
||||
minecraftArgs = v.minecraftArgs;
|
||||
permSize = v.permSize;
|
||||
gameDirType = v.gameDirType;
|
||||
@@ -90,167 +88,162 @@ public final class Profile {
|
||||
}
|
||||
|
||||
public IMinecraftProvider getMinecraftProvider() {
|
||||
if(minecraftProvider == null) minecraftProvider = new MinecraftVersionManager(this);
|
||||
if (minecraftProvider == null) minecraftProvider = new MinecraftVersionManager(this);
|
||||
return minecraftProvider;
|
||||
}
|
||||
|
||||
public MinecraftVersion getSelectedMinecraftVersion() {
|
||||
if (StrUtils.isBlank(selectedMinecraftVersion)) {
|
||||
MinecraftVersion v = getMinecraftProvider().getOneVersion();
|
||||
if (v == null) {
|
||||
return null;
|
||||
}
|
||||
selectedMinecraftVersion = v.id;
|
||||
return v;
|
||||
}
|
||||
MinecraftVersion v = getMinecraftProvider().getVersionById(selectedMinecraftVersion);
|
||||
if(v == null) v = getMinecraftProvider().getOneVersion();
|
||||
if(v != null) setSelectedMinecraftVersion(v.id);
|
||||
return v;
|
||||
if (StrUtils.isBlank(selectedMinecraftVersion)) {
|
||||
MinecraftVersion v = getMinecraftProvider().getOneVersion();
|
||||
if (v == null) return null;
|
||||
selectedMinecraftVersion = v.id;
|
||||
return v;
|
||||
}
|
||||
MinecraftVersion v = getMinecraftProvider().getVersionById(selectedMinecraftVersion);
|
||||
if (v == null) v = getMinecraftProvider().getOneVersion();
|
||||
if (v != null) setSelectedMinecraftVersion(v.id);
|
||||
return v;
|
||||
}
|
||||
|
||||
public String getGameDir() {
|
||||
if (StrUtils.isBlank(gameDir)) {
|
||||
gameDir = MCUtils.getInitGameDir().getPath();
|
||||
}
|
||||
return IOUtils.addSeparator(gameDir);
|
||||
if (StrUtils.isBlank(gameDir)) gameDir = MCUtils.getInitGameDir().getPath();
|
||||
return IOUtils.addSeparator(gameDir);
|
||||
}
|
||||
|
||||
|
||||
public String getCanonicalGameDir() {
|
||||
return IOUtils.tryGetCanonicalFolderPath(getGameDirFile());
|
||||
return IOUtils.tryGetCanonicalFolderPath(getGameDirFile());
|
||||
}
|
||||
|
||||
|
||||
public File getCanonicalGameDirFile() {
|
||||
return IOUtils.tryGetCanonicalFile(getGameDirFile());
|
||||
return IOUtils.tryGetCanonicalFile(getGameDirFile());
|
||||
}
|
||||
|
||||
public File getGameDirFile() {
|
||||
return new File(getGameDir());
|
||||
return new File(getGameDir());
|
||||
}
|
||||
|
||||
public Profile setGameDir(String gameDir) {
|
||||
this.gameDir = gameDir;
|
||||
this.gameDir = gameDir;
|
||||
Settings.save();
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getJavaDir() {
|
||||
if (StrUtils.isBlank(javaDir)) {
|
||||
javaDir = IOUtils.getJavaDir();
|
||||
}
|
||||
return javaDir;
|
||||
if (StrUtils.isBlank(javaDir))
|
||||
javaDir = IOUtils.getJavaDir();
|
||||
return javaDir;
|
||||
}
|
||||
|
||||
public File getJavaDirFile() {
|
||||
return new File(getJavaDir());
|
||||
return new File(getJavaDir());
|
||||
}
|
||||
|
||||
public void setJavaDir(String javaDir) {
|
||||
this.javaDir = javaDir;
|
||||
this.javaDir = javaDir;
|
||||
Settings.save();
|
||||
}
|
||||
|
||||
public File getFolder(String folder) {
|
||||
return new File(getGameDir(), folder);
|
||||
return new File(getGameDir(), folder);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void setSelectedMinecraftVersion(String selectedMinecraftVersion) {
|
||||
this.selectedMinecraftVersion = selectedMinecraftVersion;
|
||||
this.selectedMinecraftVersion = selectedMinecraftVersion;
|
||||
}
|
||||
|
||||
public String getJavaArgs() {
|
||||
if(StrUtils.isBlank(javaArgs)) return "";
|
||||
return javaArgs;
|
||||
if (StrUtils.isBlank(javaArgs)) return "";
|
||||
return javaArgs;
|
||||
}
|
||||
|
||||
public void setJavaArgs(String javaArgs) {
|
||||
this.javaArgs = javaArgs;
|
||||
this.javaArgs = javaArgs;
|
||||
Settings.save();
|
||||
}
|
||||
|
||||
|
||||
public boolean hasJavaArgs() {
|
||||
return StrUtils.isNotBlank(getJavaArgs().trim());
|
||||
}
|
||||
|
||||
public String getMaxMemory() {
|
||||
if(StrUtils.isBlank(maxMemory)) return String.valueOf(Utils.getSuggestedMemorySize());
|
||||
return maxMemory;
|
||||
if (StrUtils.isBlank(maxMemory)) return String.valueOf(Utils.getSuggestedMemorySize());
|
||||
return maxMemory;
|
||||
}
|
||||
|
||||
public void setMaxMemory(String maxMemory) {
|
||||
this.maxMemory = maxMemory;
|
||||
this.maxMemory = maxMemory;
|
||||
Settings.save();
|
||||
}
|
||||
|
||||
public String getWidth() {
|
||||
if(StrUtils.isBlank(width)) return "854";
|
||||
return width;
|
||||
if (StrUtils.isBlank(width)) return "854";
|
||||
return width;
|
||||
}
|
||||
|
||||
public void setWidth(String width) {
|
||||
this.width = width;
|
||||
this.width = width;
|
||||
}
|
||||
|
||||
public String getHeight() {
|
||||
if(StrUtils.isBlank(height)) return "480";
|
||||
return height;
|
||||
if (StrUtils.isBlank(height)) return "480";
|
||||
return height;
|
||||
}
|
||||
|
||||
public void setHeight(String height) {
|
||||
this.height = height;
|
||||
this.height = height;
|
||||
Settings.save();
|
||||
}
|
||||
|
||||
public String getUserProperties() {
|
||||
if(userProperties == null) return "";
|
||||
return userProperties;
|
||||
if (userProperties == null) return "";
|
||||
return userProperties;
|
||||
}
|
||||
|
||||
public void setUserProperties(String userProperties) {
|
||||
this.userProperties = userProperties;
|
||||
this.userProperties = userProperties;
|
||||
}
|
||||
|
||||
public boolean isFullscreen() {
|
||||
return fullscreen;
|
||||
return fullscreen;
|
||||
}
|
||||
|
||||
public void setFullscreen(boolean fullscreen) {
|
||||
this.fullscreen = fullscreen;
|
||||
this.fullscreen = fullscreen;
|
||||
Settings.save();
|
||||
}
|
||||
|
||||
public boolean isDebug() {
|
||||
return debug;
|
||||
return debug;
|
||||
}
|
||||
|
||||
public void setDebug(boolean debug) {
|
||||
this.debug = debug;
|
||||
this.debug = debug;
|
||||
Settings.save();
|
||||
}
|
||||
|
||||
public LauncherVisibility getLauncherVisibility() {
|
||||
return LauncherVisibility.values()[launcherVisibility];
|
||||
return LauncherVisibility.values()[launcherVisibility];
|
||||
}
|
||||
|
||||
public void setLauncherVisibility(LauncherVisibility launcherVisibility) {
|
||||
this.launcherVisibility = launcherVisibility.ordinal();
|
||||
this.launcherVisibility = launcherVisibility.ordinal();
|
||||
Settings.save();
|
||||
}
|
||||
|
||||
public GameDirType getGameDirType() {
|
||||
return GameDirType.values()[gameDirType];
|
||||
return GameDirType.values()[gameDirType];
|
||||
}
|
||||
|
||||
public void setGameDirType(GameDirType gameDirType) {
|
||||
this.gameDirType = gameDirType.ordinal();
|
||||
this.gameDirType = gameDirType.ordinal();
|
||||
Settings.save();
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ import org.jackhuang.hellominecraft.utils.VersionNumber;
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public final class Settings {
|
||||
|
||||
|
||||
public static final String DEFAULT_PROFILE = "Default";
|
||||
|
||||
public static final File settingsFile = new File(IOUtils.currentDir(), "hmcl.json");
|
||||
@@ -60,10 +60,9 @@ public final class Settings {
|
||||
settings = initSettings();
|
||||
if (!getVersions().containsKey(DEFAULT_PROFILE))
|
||||
getVersions().put(DEFAULT_PROFILE, new Profile());
|
||||
|
||||
for(Profile e : getVersions().values()) {
|
||||
|
||||
for (Profile e : getVersions().values())
|
||||
e.checkFormat();
|
||||
}
|
||||
|
||||
UPDATE_CHECKER = new UpdateChecker(new VersionNumber(Main.firstVer, Main.secondVer, Main.thirdVer),
|
||||
"hmcl", settings.isCheckUpdate(), () -> Main.invokeUpdate());
|
||||
|
||||
@@ -84,8 +84,8 @@ public final class MCUtils {
|
||||
String ver = new String(tmp, i, j - i, "ASCII");
|
||||
r.version = ver;
|
||||
|
||||
r.type = file.getEntry("META-INF/MANIFEST.MF") == null ?
|
||||
MinecraftVersionRequest.Modified : MinecraftVersionRequest.OK;
|
||||
r.type = file.getEntry("META-INF/MANIFEST.MF") == null
|
||||
? MinecraftVersionRequest.Modified : MinecraftVersionRequest.OK;
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -134,8 +134,8 @@ public final class MCUtils {
|
||||
k++;
|
||||
r.version = new String(tmp, k, i - k + 1);
|
||||
}
|
||||
r.type = file.getEntry("META-INF/MANIFEST.MF") == null ?
|
||||
MinecraftVersionRequest.Modified : MinecraftVersionRequest.OK;
|
||||
r.type = file.getEntry("META-INF/MANIFEST.MF") == null
|
||||
? MinecraftVersionRequest.Modified : MinecraftVersionRequest.OK;
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -295,11 +295,12 @@ public final class MCUtils {
|
||||
String result = NetUtils.doGet(sourceType.getProvider().getVersionsListDownloadURL());
|
||||
return MinecraftRemoteVersions.fromJson(result);
|
||||
}
|
||||
|
||||
|
||||
public static String profile = "{\"selectedProfile\": \"(Default)\",\"profiles\": {\"(Default)\": {\"name\": \"(Default)\"}},\"clientToken\": \"88888888-8888-8888-8888-888888888888\"}";
|
||||
|
||||
public static void tryWriteProfile(File gameDir) throws IOException {
|
||||
File file = new File(gameDir, "launcher_profiles.json");
|
||||
if(!file.exists())
|
||||
if (!file.exists())
|
||||
FileUtils.writeStringToFile(file, profile);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,20 +30,20 @@ public class AssetsIndex {
|
||||
public static final String DEFAULT_ASSET_NAME = "legacy";
|
||||
private Map<String, AssetsObject> objects;
|
||||
private boolean virtual;
|
||||
|
||||
|
||||
public AssetsIndex() {
|
||||
this.objects = new LinkedHashMap();
|
||||
this.objects = new LinkedHashMap();
|
||||
}
|
||||
|
||||
public Map<String, AssetsObject> getFileMap() {
|
||||
return this.objects;
|
||||
return this.objects;
|
||||
}
|
||||
|
||||
public Set<AssetsObject> getUniqueObjects() {
|
||||
return new HashSet(this.objects.values());
|
||||
return new HashSet(this.objects.values());
|
||||
}
|
||||
|
||||
public boolean isVirtual() {
|
||||
return this.virtual;
|
||||
return this.virtual;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,21 +54,16 @@ public class AssetsLoader extends Thread {
|
||||
for (int i = 0; i < contents.getLength(); i++) {
|
||||
Node result = contents.item(i);
|
||||
if (result.getNodeType() == Node.ELEMENT_NODE) {
|
||||
if (result.getNodeName().equalsIgnoreCase("Key")) {
|
||||
if (result.getNodeName().equalsIgnoreCase("Key"))
|
||||
ret.key = result.getTextContent();
|
||||
}
|
||||
if (result.getNodeName().equalsIgnoreCase("ETag")) {
|
||||
if (result.getNodeName().equalsIgnoreCase("ETag"))
|
||||
ret.eTag = result.getTextContent();
|
||||
}
|
||||
if (result.getNodeName().equalsIgnoreCase("LastModified")) {
|
||||
if (result.getNodeName().equalsIgnoreCase("LastModified"))
|
||||
ret.lastModified = result.getTextContent();
|
||||
}
|
||||
if (result.getNodeName().equalsIgnoreCase("Size")) {
|
||||
if (result.getNodeName().equalsIgnoreCase("Size"))
|
||||
ret.size = MathUtils.parseInt(result.getTextContent(), 0);
|
||||
}
|
||||
if (result.getNodeName().equalsIgnoreCase("StorageClass")) {
|
||||
if (result.getNodeName().equalsIgnoreCase("StorageClass"))
|
||||
ret.storageClass = result.getTextContent();
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
@@ -90,7 +85,7 @@ public class AssetsLoader extends Thread {
|
||||
Node result = nodes.item(i);
|
||||
if (result.getNodeType() == Node.ELEMENT_NODE && result.getNodeName().equals("Contents")) {
|
||||
Contents c = modifyContents(result.getChildNodes());
|
||||
if(c.key != null)
|
||||
if (c.key != null)
|
||||
al.add(c);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,4 +27,4 @@ public interface AssetsLoaderListener {
|
||||
void OnDone(ArrayList<Contents> loader);
|
||||
|
||||
void OnFailed(Exception e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ public class AssetsMojangLoader extends IAssetsHandler {
|
||||
return;
|
||||
}
|
||||
AssetsIndex o;
|
||||
try {
|
||||
try {
|
||||
o = C.gson.fromJson(result, AssetsIndex.class);
|
||||
} catch (Exception e) {
|
||||
HMCLog.err("Failed to parse index json, please redownload it!", e);
|
||||
|
||||
@@ -61,11 +61,11 @@ public class AssetsMojangOldLoader extends IAssetsHandler {
|
||||
@Override
|
||||
public boolean isVersionAllowed(String formattedVersion) {
|
||||
VersionNumber r = VersionNumber.check(formattedVersion);
|
||||
if(r == null) return false;
|
||||
return VersionNumber.check("1.7.2").compareTo(r) >= 0 &&
|
||||
VersionNumber.check("1.6.0").compareTo(r) <= 0;
|
||||
if (r == null) return false;
|
||||
return VersionNumber.check("1.7.2").compareTo(r) >= 0
|
||||
&& VersionNumber.check("1.6.0").compareTo(r) <= 0;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Task getDownloadTask(IDownloadProvider sourceType) {
|
||||
return new AssetsTask(URL);
|
||||
|
||||
@@ -21,6 +21,7 @@ package org.jackhuang.hellominecraft.launcher.utils.assets;
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public class AssetsObject {
|
||||
|
||||
private String hash;
|
||||
private long size;
|
||||
|
||||
@@ -28,26 +29,26 @@ public class AssetsObject {
|
||||
}
|
||||
|
||||
public String getHash() {
|
||||
return this.hash;
|
||||
return this.hash;
|
||||
}
|
||||
|
||||
public long getSize() {
|
||||
return this.size;
|
||||
return this.size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
AssetsObject that = (AssetsObject) o;
|
||||
if (this.size != that.size) return false;
|
||||
return this.hash.equals(that.hash);
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
AssetsObject that = (AssetsObject) o;
|
||||
if (this.size != that.size) return false;
|
||||
return this.hash.equals(that.hash);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = this.hash.hashCode();
|
||||
result = 31 * result + (int) (this.size ^ this.size >>> 32);
|
||||
return result;
|
||||
int result = this.hash.hashCode();
|
||||
result = 31 * result + (int) (this.size ^ this.size >>> 32);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@ package org.jackhuang.hellominecraft.launcher.utils.assets;
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public class Contents {
|
||||
|
||||
|
||||
public String key, eTag, lastModified, storageClass;
|
||||
public long size;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -62,7 +62,6 @@ public abstract class IAssetsHandler {
|
||||
|
||||
static {
|
||||
assetsHandlers.add(new AssetsMojangLoader(C.i18n("assets.list.1_7_3_after")));
|
||||
//assetsHandlers.add(new AssetsMojangOldLoader(C.i18n("assets.list.1_6")));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -30,28 +30,26 @@ public abstract class IAuthenticator {
|
||||
public static final YggdrasilAuthenticator yggdrasilLogin;
|
||||
public static final OfflineAuthenticator offlineLogin;
|
||||
public static final SkinmeAuthenticator skinmeLogin;
|
||||
//public static final BestLogin bestLogin;
|
||||
|
||||
public static final List<IAuthenticator> logins;
|
||||
|
||||
static {
|
||||
String clientToken = Settings.getInstance().getClientToken();
|
||||
logins = new ArrayList<>();
|
||||
logins.add(offlineLogin = new OfflineAuthenticator(clientToken));
|
||||
logins.add(yggdrasilLogin = new YggdrasilAuthenticator(clientToken));
|
||||
logins.add(skinmeLogin = new SkinmeAuthenticator(clientToken));
|
||||
//logins.add(bestLogin = new BestLogin(clientToken));
|
||||
yggdrasilLogin.onLoadSettings(Settings.getInstance().getYggdrasilConfig());
|
||||
String clientToken = Settings.getInstance().getClientToken();
|
||||
logins = new ArrayList<>();
|
||||
logins.add(offlineLogin = new OfflineAuthenticator(clientToken));
|
||||
logins.add(yggdrasilLogin = new YggdrasilAuthenticator(clientToken));
|
||||
logins.add(skinmeLogin = new SkinmeAuthenticator(clientToken));
|
||||
yggdrasilLogin.onLoadSettings(Settings.getInstance().getYggdrasilConfig());
|
||||
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(() ->
|
||||
Settings.getInstance().setYggdrasilConfig(yggdrasilLogin.onSaveSettings())
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(()
|
||||
-> Settings.getInstance().setYggdrasilConfig(yggdrasilLogin.onSaveSettings())
|
||||
));
|
||||
}
|
||||
|
||||
protected String clientToken;
|
||||
|
||||
public IAuthenticator(String clientToken) {
|
||||
this.clientToken = clientToken;
|
||||
this.clientToken = clientToken;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -74,11 +72,11 @@ public abstract class IAuthenticator {
|
||||
* @return Will I hide password box?
|
||||
*/
|
||||
public boolean isHidePasswordBox() {
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isLoggedIn() {
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setRememberMe(boolean is) {
|
||||
|
||||
@@ -21,6 +21,7 @@ package org.jackhuang.hellominecraft.launcher.utils.auth;
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public final class LoginInfo {
|
||||
|
||||
public String username, password;
|
||||
|
||||
public LoginInfo(String username, String password) {
|
||||
|
||||
@@ -109,14 +109,14 @@ public final class UserProfileProvider {
|
||||
public void setUserType(String userType) {
|
||||
this.userType = userType;
|
||||
}
|
||||
|
||||
|
||||
private String username = "";
|
||||
private String userId = "";
|
||||
private String session = "";
|
||||
private String accessToken = "";
|
||||
private boolean success = false;
|
||||
private String error = "";
|
||||
private String userProperties = "{}";
|
||||
private String userProperties = "{}";
|
||||
private String userPropertyMap = "{}";
|
||||
private String otherInfo = "";
|
||||
private String clientIdentifier = "";
|
||||
|
||||
@@ -23,17 +23,17 @@ import org.jackhuang.hellominecraft.launcher.utils.installers.InstallerVersionLi
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public class BMCLAPIDownloadProvider implements IDownloadProvider {
|
||||
|
||||
|
||||
@Override
|
||||
public InstallerVersionList getForgeInstaller() {
|
||||
return org.jackhuang.hellominecraft.launcher.utils.installers.forge.bmcl.ForgeBMCLVersionList.getInstance();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public InstallerVersionList getLiteLoaderInstaller() {
|
||||
return org.jackhuang.hellominecraft.launcher.utils.installers.liteloader.LiteLoaderVersionList.getInstance();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public InstallerVersionList getOptiFineInstaller() {
|
||||
return org.jackhuang.hellominecraft.launcher.utils.installers.optifine.bmcl.OptiFineBMCLVersionList.getInstance();
|
||||
@@ -41,9 +41,9 @@ public class BMCLAPIDownloadProvider implements IDownloadProvider {
|
||||
|
||||
@Override
|
||||
public InstallerVersionList getInstallerByType(String type) {
|
||||
if(type.equalsIgnoreCase("forge")) return getForgeInstaller();
|
||||
if(type.equalsIgnoreCase("liteloader")) return getLiteLoaderInstaller();
|
||||
if(type.equalsIgnoreCase("optifine")) return getOptiFineInstaller();
|
||||
if (type.equalsIgnoreCase("forge")) return getForgeInstaller();
|
||||
if (type.equalsIgnoreCase("liteloader")) return getLiteLoaderInstaller();
|
||||
if (type.equalsIgnoreCase("optifine")) return getOptiFineInstaller();
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -64,17 +64,17 @@ public class BMCLAPIDownloadProvider implements IDownloadProvider {
|
||||
|
||||
@Override
|
||||
public String getVersionsListDownloadURL() {
|
||||
return "http://bmclapi2.bangbang93.com/versions/versions.json";
|
||||
return "http://bmclapi2.bangbang93.com/versions/versions.json";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAssetsDownloadURL() {
|
||||
return "http://bmclapi2.bangbang93.com/assets/";
|
||||
return "http://bmclapi2.bangbang93.com/assets/";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAllowedToUseSelfURL() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -23,12 +23,13 @@ import org.jackhuang.hellominecraft.C;
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public enum DownloadType {
|
||||
|
||||
Mojang(C.i18n("download.mojang"), new MojangDownloadProvider()),
|
||||
BMCL(C.i18n("download.BMCL"), new BMCLAPIDownloadProvider());
|
||||
|
||||
|
||||
private final String name;
|
||||
private final IDownloadProvider provider;
|
||||
|
||||
|
||||
DownloadType(String a, IDownloadProvider provider) {
|
||||
name = a;
|
||||
this.provider = provider;
|
||||
@@ -37,7 +38,7 @@ public enum DownloadType {
|
||||
public IDownloadProvider getProvider() {
|
||||
return provider;
|
||||
}
|
||||
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@@ -23,14 +23,24 @@ import org.jackhuang.hellominecraft.launcher.utils.installers.InstallerVersionLi
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public interface IDownloadProvider {
|
||||
|
||||
InstallerVersionList getInstallerByType(String type);
|
||||
|
||||
InstallerVersionList getForgeInstaller();
|
||||
|
||||
InstallerVersionList getLiteLoaderInstaller();
|
||||
|
||||
InstallerVersionList getOptiFineInstaller();
|
||||
|
||||
String getLibraryDownloadURL();
|
||||
|
||||
String getVersionsDownloadURL();
|
||||
|
||||
String getIndexesDownloadURL();
|
||||
|
||||
String getVersionsListDownloadURL();
|
||||
|
||||
String getAssetsDownloadURL();
|
||||
|
||||
boolean isAllowedToUseSelfURL();
|
||||
}
|
||||
|
||||
@@ -41,9 +41,9 @@ public class MojangDownloadProvider implements IDownloadProvider {
|
||||
|
||||
@Override
|
||||
public InstallerVersionList getInstallerByType(String type) {
|
||||
if(type.equalsIgnoreCase("forge")) return getForgeInstaller();
|
||||
if(type.equalsIgnoreCase("liteloader")) return getLiteLoaderInstaller();
|
||||
if(type.equalsIgnoreCase("optifine")) return getOptiFineInstaller();
|
||||
if (type.equalsIgnoreCase("forge")) return getForgeInstaller();
|
||||
if (type.equalsIgnoreCase("liteloader")) return getLiteLoaderInstaller();
|
||||
if (type.equalsIgnoreCase("optifine")) return getOptiFineInstaller();
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -76,5 +76,5 @@ public class MojangDownloadProvider implements IDownloadProvider {
|
||||
public boolean isAllowedToUseSelfURL() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.jackhuang.hellominecraft.launcher.utils.installers.forge.Install;
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public class InstallProfile {
|
||||
|
||||
@SerializedName("install")
|
||||
public Install install;
|
||||
@SerializedName("versionInfo")
|
||||
|
||||
@@ -25,33 +25,40 @@ import org.jackhuang.hellominecraft.utils.functions.Consumer;
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public abstract class InstallerVersionList implements Consumer<String[]> {
|
||||
|
||||
/**
|
||||
* Refresh installer versions list from the downloaded content.
|
||||
*
|
||||
* @param versions Minecraft versions you need to refresh
|
||||
* @throws java.lang.Exception
|
||||
*/
|
||||
public abstract void refreshList(String[] versions) throws Exception;
|
||||
|
||||
public abstract String getName();
|
||||
|
||||
public abstract List<InstallerVersion> getVersions(String mcVersion);
|
||||
|
||||
|
||||
public static class InstallerVersion implements Comparable<InstallerVersion> {
|
||||
public String selfVersion, mcVersion;
|
||||
public String installer, universal;
|
||||
|
||||
public String selfVersion, mcVersion;
|
||||
public String installer, universal;
|
||||
public String changelog;
|
||||
|
||||
public InstallerVersion(String selfVersion, String mcVersion) {
|
||||
this.selfVersion = selfVersion;
|
||||
this.mcVersion = mcVersion;
|
||||
}
|
||||
public InstallerVersion(String selfVersion, String mcVersion) {
|
||||
this.selfVersion = selfVersion;
|
||||
this.mcVersion = mcVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(InstallerVersion o) {
|
||||
return selfVersion.compareTo(o.selfVersion);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class InstallerVersionComparator implements Comparator<InstallerVersion> {
|
||||
|
||||
public static final InstallerVersionComparator INSTANCE = new InstallerVersionComparator();
|
||||
|
||||
@Override
|
||||
public int compare(InstallerVersion o1, InstallerVersion o2) {
|
||||
return o2.compareTo(o1);
|
||||
|
||||
@@ -48,8 +48,8 @@ public class ForgeInstaller extends Task {
|
||||
public IMinecraftProvider mp;
|
||||
|
||||
public ForgeInstaller(IMinecraftProvider mp, File forgeInstaller) {
|
||||
this.gameDir = mp.getBaseFolder();
|
||||
this.forgeInstaller = forgeInstaller;
|
||||
this.gameDir = mp.getBaseFolder();
|
||||
this.forgeInstaller = forgeInstaller;
|
||||
this.mp = mp;
|
||||
}
|
||||
|
||||
@@ -64,17 +64,15 @@ public class ForgeInstaller extends Task {
|
||||
InstallProfile profile = gson.fromJson(content, InstallProfile.class);
|
||||
|
||||
File from = new File(gameDir, "versions" + File.separator + profile.install.minecraft);
|
||||
if(!from.exists()) {
|
||||
if(MessageBox.Show(C.i18n("install.no_version_if_intall")) == MessageBox.YES_OPTION) {
|
||||
if(!mp.install(profile.install.minecraft, Settings.getInstance().getDownloadSource())) {
|
||||
if (!from.exists()) {
|
||||
if (MessageBox.Show(C.i18n("install.no_version_if_intall")) == MessageBox.YES_OPTION) {
|
||||
if (!mp.install(profile.install.minecraft, Settings.getInstance().getDownloadSource()))
|
||||
setFailReason(new RuntimeException(C.i18n("install.no_version")));
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
setFailReason(new RuntimeException(C.i18n("install.no_version")));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
File to = new File(gameDir, "versions" + File.separator + profile.install.target);
|
||||
to.mkdirs();
|
||||
|
||||
@@ -100,7 +98,7 @@ public class ForgeInstaller extends Task {
|
||||
bos.close();
|
||||
}
|
||||
return true;
|
||||
} catch(IOException | JsonSyntaxException e) {
|
||||
} catch (IOException | JsonSyntaxException e) {
|
||||
setFailReason(e);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -26,12 +26,12 @@ import org.jackhuang.hellominecraft.launcher.utils.installers.PackMinecraftInsta
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public class ForgeOldInstaller {
|
||||
|
||||
|
||||
public static void install(String destMinecraftJar, String srcMinecraftJar, String forgeUniversal) throws IOException {
|
||||
ArrayList<String> al = new ArrayList<>();
|
||||
al.add(srcMinecraftJar);
|
||||
al.add(forgeUniversal);
|
||||
new PackMinecraftInstaller(al, new File(destMinecraftJar)).install();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ package org.jackhuang.hellominecraft.launcher.utils.installers.forge;
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public class Install {
|
||||
|
||||
public String profileName;
|
||||
public String target;
|
||||
public String path;
|
||||
|
||||
@@ -49,21 +49,21 @@ public class ForgeBMCLVersionList extends InstallerVersionList {
|
||||
|
||||
@Override
|
||||
public void refreshList(String[] neededVersions) throws Exception {
|
||||
if(versionMap == null) {
|
||||
if (versionMap == null) {
|
||||
versionMap = new HashMap<>();
|
||||
versions = new ArrayList<>();
|
||||
}
|
||||
|
||||
|
||||
for (String x : neededVersions) {
|
||||
if(versionMap.containsKey(x)) continue;
|
||||
if (versionMap.containsKey(x)) continue;
|
||||
String s = NetUtils.doGet("http://bmclapi2.bangbang93.com/forge/minecraft/" + x);
|
||||
|
||||
if (s == null) {
|
||||
if (s == null)
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
root = C.gson.fromJson(s, new TypeToken<ArrayList<ForgeVersion>>(){}.getType());
|
||||
root = C.gson.fromJson(s, new TypeToken<ArrayList<ForgeVersion>>() {
|
||||
}.getType());
|
||||
for (ForgeVersion v : root) {
|
||||
InstallerVersion iv = new InstallerVersion(v.version, StrUtils.formatVersion(v.minecraft));
|
||||
|
||||
@@ -74,7 +74,7 @@ public class ForgeBMCLVersionList extends InstallerVersionList {
|
||||
al.add(iv);
|
||||
versions.add(iv);
|
||||
}
|
||||
} catch(JsonSyntaxException e) {
|
||||
} catch (JsonSyntaxException e) {
|
||||
HMCLog.warn("Failed to parse BMCLAPI2 response.", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ package org.jackhuang.hellominecraft.launcher.utils.installers.forge.bmcl;
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public class ForgeVersion {
|
||||
|
||||
public String time, minecraft, version, _id, __v;
|
||||
public Downloads downloads;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ package org.jackhuang.hellominecraft.launcher.utils.installers.forge.vanilla;
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public class MinecraftForgeVersion {
|
||||
|
||||
public String branch, mcversion, jobver, version;
|
||||
public int build;
|
||||
public double modified;
|
||||
|
||||
@@ -32,71 +32,75 @@ import org.jackhuang.hellominecraft.utils.NetUtils;
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public class MinecraftForgeVersionList extends InstallerVersionList {
|
||||
|
||||
private static MinecraftForgeVersionList instance;
|
||||
|
||||
public static MinecraftForgeVersionList getInstance() {
|
||||
if(instance == null)
|
||||
instance = new MinecraftForgeVersionList();
|
||||
return instance;
|
||||
if (instance == null)
|
||||
instance = new MinecraftForgeVersionList();
|
||||
return instance;
|
||||
}
|
||||
|
||||
public MinecraftForgeVersionRoot root;
|
||||
public Map<String, List<InstallerVersion>> versionMap;
|
||||
public List<InstallerVersion> versions;
|
||||
|
||||
|
||||
@Override
|
||||
public void refreshList(String[] needed) throws Exception {
|
||||
String s = NetUtils.doGet(C.URL_FORGE_LIST);
|
||||
if(root!=null) return;
|
||||
|
||||
root = C.gson.fromJson(s, MinecraftForgeVersionRoot.class);
|
||||
|
||||
versionMap = new HashMap<String, List<InstallerVersion>>();
|
||||
versions = new ArrayList<InstallerVersion>();
|
||||
|
||||
for(Map.Entry<String, int[]> arr : root.mcversion.entrySet()) {
|
||||
String mcver = StrUtils.formatVersion(arr.getKey());
|
||||
ArrayList<InstallerVersion> al = new ArrayList<InstallerVersion>();
|
||||
for(int num : arr.getValue()) {
|
||||
MinecraftForgeVersion v = root.number.get(num);
|
||||
InstallerVersion iv = new InstallerVersion(v.version, StrUtils.formatVersion(v.mcversion));
|
||||
for(String[] f : v.files) {
|
||||
if (root != null) return;
|
||||
|
||||
String ver = v.mcversion + "-" + v.version;
|
||||
if(!StrUtils.isBlank(v.branch)) {
|
||||
ver = ver + "-" + v.branch;
|
||||
}
|
||||
String filename = root.artifact + "-" + ver + "-" + f[1] + "." + f[0];
|
||||
String url = root.webpath + "/" + ver + "/" + filename;
|
||||
if(f[1].equals("installer")) {
|
||||
iv.installer = url;
|
||||
} else if(f[1].equals("universal")) {
|
||||
iv.universal = url;
|
||||
} else if(f[1].equals("changelog")) {
|
||||
iv.changelog = url;
|
||||
}
|
||||
}
|
||||
if(StrUtils.isBlank(iv.installer) || StrUtils.isBlank(iv.universal)) {
|
||||
continue;
|
||||
}
|
||||
root = C.gson.fromJson(s, MinecraftForgeVersionRoot.class);
|
||||
|
||||
versionMap = new HashMap<>();
|
||||
versions = new ArrayList<>();
|
||||
|
||||
for (Map.Entry<String, int[]> arr : root.mcversion.entrySet()) {
|
||||
String mcver = StrUtils.formatVersion(arr.getKey());
|
||||
ArrayList<InstallerVersion> al = new ArrayList<>();
|
||||
for (int num : arr.getValue()) {
|
||||
MinecraftForgeVersion v = root.number.get(num);
|
||||
InstallerVersion iv = new InstallerVersion(v.version, StrUtils.formatVersion(v.mcversion));
|
||||
for (String[] f : v.files) {
|
||||
|
||||
String ver = v.mcversion + "-" + v.version;
|
||||
if (!StrUtils.isBlank(v.branch))
|
||||
ver = ver + "-" + v.branch;
|
||||
String filename = root.artifact + "-" + ver + "-" + f[1] + "." + f[0];
|
||||
String url = root.webpath + "/" + ver + "/" + filename;
|
||||
switch (f[1]) {
|
||||
case "installer":
|
||||
iv.installer = url;
|
||||
break;
|
||||
case "universal":
|
||||
iv.universal = url;
|
||||
break;
|
||||
case "changelog":
|
||||
iv.changelog = url;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (StrUtils.isBlank(iv.installer) || StrUtils.isBlank(iv.universal))
|
||||
continue;
|
||||
Collections.sort(al, new InstallerVersionNewerComparator());
|
||||
al.add(iv);
|
||||
al.add(iv);
|
||||
versions.add(iv);
|
||||
}
|
||||
|
||||
versionMap.put(StrUtils.formatVersion(mcver), al);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
versionMap.put(StrUtils.formatVersion(mcver), al);
|
||||
}
|
||||
|
||||
Collections.sort(versions, new InstallerVersionComparator());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<InstallerVersion> getVersions(String mcVersion) {
|
||||
if (versions == null || versionMap == null) return null;
|
||||
if(StrUtils.isBlank(mcVersion)) return versions;
|
||||
List c = versionMap.get(mcVersion);
|
||||
if(c == null) return versions;
|
||||
if (StrUtils.isBlank(mcVersion)) return versions;
|
||||
List c = versionMap.get(mcVersion);
|
||||
if (c == null) return versions;
|
||||
Collections.sort(c, InstallerVersionComparator.INSTANCE);
|
||||
return c;
|
||||
return c;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.util.Map;
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public class MinecraftForgeVersionRoot {
|
||||
|
||||
public String artifact, webpath, adfly, homepage, name;
|
||||
public Map<String, int[]> branches, mcversion;
|
||||
public Map<String, Integer> promos;
|
||||
|
||||
@@ -51,25 +51,25 @@ public class LiteLoaderInstaller extends Task implements PreviousResultRegistrat
|
||||
|
||||
@Override
|
||||
public boolean executeTask() {
|
||||
if(profile == null || profile.getSelectedMinecraftVersion() == null) {
|
||||
if (profile == null || profile.getSelectedMinecraftVersion() == null) {
|
||||
setFailReason(new RuntimeException(C.i18n("install.no_version")));
|
||||
return false;
|
||||
}
|
||||
if(pre.size() != 1 && installer == null) throw new IllegalStateException("No registered previous task.");
|
||||
if(installer == null)
|
||||
if (pre.size() != 1 && installer == null) throw new IllegalStateException("No registered previous task.");
|
||||
if (installer == null)
|
||||
installer = pre.get(pre.size() - 1).getResult();
|
||||
try {
|
||||
MinecraftVersion mv = (MinecraftVersion) profile.getSelectedMinecraftVersion().clone();
|
||||
mv.inheritsFrom = mv.id;
|
||||
mv.jar = mv.jar == null ? mv.id : mv.jar;
|
||||
mv.libraries = new ArrayList(Arrays.asList(version.libraries));
|
||||
|
||||
|
||||
mv.libraries.add(0, new MinecraftLibrary("com.mumfrey:liteloader:" + version.selfVersion));
|
||||
FileUtils.copyFile(installer, new File(profile.getCanonicalGameDir(), "libraries/com/mumfrey/liteloader/" + version.selfVersion + "/liteloader-" + version.selfVersion + ".jar"));
|
||||
|
||||
mv.id += "-LiteLoader" + version.selfVersion;
|
||||
|
||||
if(!mv.mainClass.startsWith("net.minecraft.launchwrapper.")) {
|
||||
if (!mv.mainClass.startsWith("net.minecraft.launchwrapper.")) {
|
||||
mv.mainClass = "net.minecraft.launchwrapper.Launch";
|
||||
mv.minecraftArguments += " --tweakClass " + version.tweakClass;
|
||||
}
|
||||
@@ -78,7 +78,7 @@ public class LiteLoaderInstaller extends Task implements PreviousResultRegistrat
|
||||
File json = new File(folder, mv.id + ".json");
|
||||
HMCLog.log("Creating new version profile..." + mv.id + ".json");
|
||||
FileUtils.write(json, C.gsonPrettyPrinting.toJson(mv));
|
||||
|
||||
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
setFailReason(e);
|
||||
@@ -90,8 +90,9 @@ public class LiteLoaderInstaller extends Task implements PreviousResultRegistrat
|
||||
public String getInfo() {
|
||||
return C.i18n("install.liteloader.install");
|
||||
}
|
||||
|
||||
|
||||
ArrayList<PreviousResult<File>> pre = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public Task registerPreviousResult(PreviousResult pr) {
|
||||
pre.add(pr);
|
||||
|
||||
@@ -23,5 +23,6 @@ import java.util.Map;
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public class LiteLoaderMCVersions {
|
||||
|
||||
public Map<String, Map<String, LiteLoaderVersion>> artefacts;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.jackhuang.hellominecraft.launcher.version.MinecraftLibrary;
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public class LiteLoaderVersion {
|
||||
|
||||
public String tweakClass, file, version, md5, timestamp;
|
||||
public MinecraftLibrary[] libraries;
|
||||
}
|
||||
|
||||
@@ -35,12 +35,13 @@ import org.jackhuang.hellominecraft.utils.StrUtils;
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public class LiteLoaderVersionList extends InstallerVersionList {
|
||||
|
||||
private static LiteLoaderVersionList instance;
|
||||
|
||||
public static LiteLoaderVersionList getInstance() {
|
||||
if(instance == null) {
|
||||
instance = new LiteLoaderVersionList();
|
||||
}
|
||||
return instance;
|
||||
if (instance == null)
|
||||
instance = new LiteLoaderVersionList();
|
||||
return instance;
|
||||
}
|
||||
|
||||
public LiteLoaderVersionsRoot root;
|
||||
@@ -50,56 +51,57 @@ public class LiteLoaderVersionList extends InstallerVersionList {
|
||||
@Override
|
||||
public void refreshList(String[] needed) throws Exception {
|
||||
String s = NetUtils.doGet(C.URL_LITELOADER_LIST);
|
||||
if(root != null) return;
|
||||
|
||||
root = C.gson.fromJson(s, LiteLoaderVersionsRoot.class);
|
||||
|
||||
versionMap = new HashMap<>();
|
||||
versions = new ArrayList<>();
|
||||
|
||||
for(Map.Entry<String, LiteLoaderMCVersions> arr : root.versions.entrySet()) {
|
||||
ArrayList<InstallerVersion> al = new ArrayList<>();
|
||||
if (root != null) return;
|
||||
|
||||
root = C.gson.fromJson(s, LiteLoaderVersionsRoot.class);
|
||||
|
||||
versionMap = new HashMap<>();
|
||||
versions = new ArrayList<>();
|
||||
|
||||
for (Map.Entry<String, LiteLoaderMCVersions> arr : root.versions.entrySet()) {
|
||||
ArrayList<InstallerVersion> al = new ArrayList<>();
|
||||
LiteLoaderMCVersions mcv = arr.getValue();
|
||||
for(Map.Entry<String, LiteLoaderVersion> entry : mcv.artefacts.get("com.mumfrey:liteloader").entrySet()) {
|
||||
if("latest".equals(entry.getKey())) continue;
|
||||
for (Map.Entry<String, LiteLoaderVersion> entry : mcv.artefacts.get("com.mumfrey:liteloader").entrySet()) {
|
||||
if ("latest".equals(entry.getKey())) continue;
|
||||
LiteLoaderVersion v = entry.getValue();
|
||||
LiteLoaderInstallerVersion iv = new LiteLoaderInstallerVersion(v.version, StrUtils.formatVersion(arr.getKey()));
|
||||
iv.universal = "http://dl.liteloader.com/versions/com/mumfrey/liteloader/" + arr.getKey() + "/" + v.file;
|
||||
iv.tweakClass = v.tweakClass;
|
||||
iv.libraries = Arrays.copyOf(v.libraries, v.libraries.length);
|
||||
LiteLoaderInstallerVersion iv = new LiteLoaderInstallerVersion(v.version, StrUtils.formatVersion(arr.getKey()));
|
||||
iv.universal = "http://dl.liteloader.com/versions/com/mumfrey/liteloader/" + arr.getKey() + "/" + v.file;
|
||||
iv.tweakClass = v.tweakClass;
|
||||
iv.libraries = Arrays.copyOf(v.libraries, v.libraries.length);
|
||||
iv.installer = "http://dl.liteloader.com/redist/" + iv.mcVersion + "/liteloader-installer-" + iv.selfVersion.replace("_", "-") + ".jar";
|
||||
al.add(iv);
|
||||
al.add(iv);
|
||||
versions.add(iv);
|
||||
}
|
||||
}
|
||||
Collections.sort(al, new InstallerVersionNewerComparator());
|
||||
versionMap.put(StrUtils.formatVersion(arr.getKey()), al);
|
||||
}
|
||||
|
||||
versionMap.put(StrUtils.formatVersion(arr.getKey()), al);
|
||||
}
|
||||
|
||||
Collections.sort(versions, InstallerVersionComparator.INSTANCE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<InstallerVersion> getVersions(String mcVersion) {
|
||||
if (versions == null || versionMap == null) return null;
|
||||
if(StrUtils.isBlank(mcVersion)) return versions;
|
||||
List c = versionMap.get(mcVersion);
|
||||
if(c == null) return versions;
|
||||
if (StrUtils.isBlank(mcVersion)) return versions;
|
||||
List c = versionMap.get(mcVersion);
|
||||
if (c == null) return versions;
|
||||
Collections.sort(c, InstallerVersionComparator.INSTANCE);
|
||||
return c;
|
||||
return c;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "LiteLoader - LiteLoader Official Site(By: Mumfrey)";
|
||||
}
|
||||
|
||||
public static class LiteLoaderInstallerVersion extends InstallerVersion {
|
||||
public MinecraftLibrary[] libraries;
|
||||
public String tweakClass;
|
||||
|
||||
public LiteLoaderInstallerVersion(String selfVersion, String mcVersion) {
|
||||
super(selfVersion, mcVersion);
|
||||
}
|
||||
public static class LiteLoaderInstallerVersion extends InstallerVersion {
|
||||
|
||||
public MinecraftLibrary[] libraries;
|
||||
public String tweakClass;
|
||||
|
||||
public LiteLoaderInstallerVersion(String selfVersion, String mcVersion) {
|
||||
super(selfVersion, mcVersion);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -21,5 +21,6 @@ package org.jackhuang.hellominecraft.launcher.utils.installers.liteloader;
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public class LiteLoaderVersionsMeta {
|
||||
|
||||
public String description, authors, url;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.util.Map;
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public class LiteLoaderVersionsRoot {
|
||||
|
||||
public Map<String, LiteLoaderMCVersions> versions;
|
||||
public LiteLoaderVersionsMeta meta;
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ public class OptiFineBMCLVersionList extends InstallerVersionList {
|
||||
if (s == null) return;
|
||||
root = C.gson.fromJson(s, new TypeToken<ArrayList<OptiFineVersion>>() {
|
||||
}.getType());
|
||||
for(OptiFineVersion v : root) {
|
||||
for (OptiFineVersion v : root) {
|
||||
v.mirror = v.mirror.replace("http://optifine.net/http://optifine.net/", "http://optifine.net/");
|
||||
|
||||
if (StrUtils.isBlank(v.mcver)) {
|
||||
|
||||
@@ -28,8 +28,9 @@ import org.jackhuang.hellominecraft.utils.NetUtils;
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public class OptiFineDownloadFormatter extends Task implements PreviousResult<String> {
|
||||
|
||||
String url, result;
|
||||
|
||||
|
||||
public OptiFineDownloadFormatter(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
@@ -40,7 +41,7 @@ public class OptiFineDownloadFormatter extends Task implements PreviousResult<St
|
||||
String content = NetUtils.doGet(url);
|
||||
Pattern p = Pattern.compile("\"downloadx\\?f=OptiFine(.*)\"");
|
||||
Matcher m = p.matcher(content);
|
||||
while(m.find()) result = m.group(1);
|
||||
while (m.find()) result = m.group(1);
|
||||
result = "http://optifine.net/downloadx?f=OptiFine" + result;
|
||||
return true;
|
||||
} catch (Exception ex) {
|
||||
|
||||
@@ -44,13 +44,14 @@ import org.xml.sax.SAXException;
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public class OptiFineVersionList extends InstallerVersionList {
|
||||
private static OptiFineVersionList instance;
|
||||
public static OptiFineVersionList getInstance() {
|
||||
if(null == instance)
|
||||
instance = new OptiFineVersionList();
|
||||
return instance;
|
||||
}
|
||||
|
||||
private static OptiFineVersionList instance;
|
||||
|
||||
public static OptiFineVersionList getInstance() {
|
||||
if (null == instance)
|
||||
instance = new OptiFineVersionList();
|
||||
return instance;
|
||||
}
|
||||
|
||||
public ArrayList<OptiFineVersion> root = new ArrayList();
|
||||
public Map<String, List<InstallerVersion>> versionMap;
|
||||
@@ -59,51 +60,46 @@ public class OptiFineVersionList extends InstallerVersionList {
|
||||
@Override
|
||||
public void refreshList(String[] sss) throws Exception {
|
||||
String content = NetUtils.doGet("http://optifine.net/downloads");
|
||||
if(versions != null) return;
|
||||
versionMap = new HashMap<>();
|
||||
versions = new ArrayList<>();
|
||||
|
||||
if (versions != null) return;
|
||||
versionMap = new HashMap<>();
|
||||
versions = new ArrayList<>();
|
||||
|
||||
content = content.replace(" ", " ").replace(">", ">").replace("<", "<");
|
||||
|
||||
|
||||
try {
|
||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder db = factory.newDocumentBuilder();
|
||||
Document doc = db.parse(new StringBufferInputStream(content));
|
||||
Element r = doc.getDocumentElement();
|
||||
NodeList tables = r.getElementsByTagName("table");
|
||||
for(int i = 0; i < tables.getLength(); i++) {
|
||||
Element e = (Element)tables.item(i);
|
||||
if("downloadTable".equals(e.getAttribute("class"))) {
|
||||
for (int i = 0; i < tables.getLength(); i++) {
|
||||
Element e = (Element) tables.item(i);
|
||||
if ("downloadTable".equals(e.getAttribute("class"))) {
|
||||
NodeList tr = e.getElementsByTagName("tr");
|
||||
for(int k = 0; k < tr.getLength(); k++) {
|
||||
NodeList downloadLine = ((Element)tr.item(k)).getElementsByTagName("td");
|
||||
for (int k = 0; k < tr.getLength(); k++) {
|
||||
NodeList downloadLine = ((Element) tr.item(k)).getElementsByTagName("td");
|
||||
OptiFineVersion v = new OptiFineVersion();
|
||||
for(int j = 0; j < downloadLine.getLength(); j++) {
|
||||
Element td = (Element)downloadLine.item(j);
|
||||
if(StrUtils.startsWith(td.getAttribute("class"), "downloadLineMirror")) {
|
||||
v.mirror = ((Element)td.getElementsByTagName("a").item(0)).getAttribute("href");
|
||||
}
|
||||
if(StrUtils.startsWith(td.getAttribute("class"), "downloadLineDownload")) {
|
||||
v.dl = ((Element)td.getElementsByTagName("a").item(0)).getAttribute("href");
|
||||
}
|
||||
if(StrUtils.startsWith(td.getAttribute("class"), "downloadLineDate")) {
|
||||
for (int j = 0; j < downloadLine.getLength(); j++) {
|
||||
Element td = (Element) downloadLine.item(j);
|
||||
if (StrUtils.startsWith(td.getAttribute("class"), "downloadLineMirror"))
|
||||
v.mirror = ((Element) td.getElementsByTagName("a").item(0)).getAttribute("href");
|
||||
if (StrUtils.startsWith(td.getAttribute("class"), "downloadLineDownload"))
|
||||
v.dl = ((Element) td.getElementsByTagName("a").item(0)).getAttribute("href");
|
||||
if (StrUtils.startsWith(td.getAttribute("class"), "downloadLineDate"))
|
||||
v.date = td.getTextContent();
|
||||
}
|
||||
if(StrUtils.startsWith(td.getAttribute("class"), "downloadLineFile")) {
|
||||
if (StrUtils.startsWith(td.getAttribute("class"), "downloadLineFile"))
|
||||
v.ver = td.getTextContent();
|
||||
}
|
||||
}
|
||||
if(StrUtils.isBlank(v.mcver)) {
|
||||
if (StrUtils.isBlank(v.mcver)) {
|
||||
Pattern p = Pattern.compile("OptiFine (.*?) ");
|
||||
Matcher m = p.matcher(v.ver);
|
||||
while(m.find()) v.mcver = StrUtils.formatVersion(m.group(1));
|
||||
while (m.find()) v.mcver = StrUtils.formatVersion(m.group(1));
|
||||
}
|
||||
InstallerVersion iv = new InstallerVersion(v.ver, StrUtils.formatVersion(v.mcver));
|
||||
iv.installer = iv.universal = v.mirror;
|
||||
root.add(v);
|
||||
versions.add(iv);
|
||||
|
||||
|
||||
List<InstallerVersion> ivl = ArrayUtils.tryGetMapWithList(versionMap, StrUtils.formatVersion(v.mcver));
|
||||
ivl.add(iv);
|
||||
}
|
||||
@@ -112,10 +108,10 @@ public class OptiFineVersionList extends InstallerVersionList {
|
||||
} catch (ParserConfigurationException | SAXException | IOException | DOMException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
|
||||
|
||||
Collections.sort(versions, InstallerVersionComparator.INSTANCE);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "OptiFine - OptiFine Official Site";
|
||||
@@ -124,11 +120,11 @@ public class OptiFineVersionList extends InstallerVersionList {
|
||||
@Override
|
||||
public List<InstallerVersion> getVersions(String mcVersion) {
|
||||
if (versions == null || versionMap == null) return null;
|
||||
if(StrUtils.isBlank(mcVersion)) return versions;
|
||||
List c = versionMap.get(mcVersion);
|
||||
if(c == null) return versions;
|
||||
if (StrUtils.isBlank(mcVersion)) return versions;
|
||||
List c = versionMap.get(mcVersion);
|
||||
if (c == null) return versions;
|
||||
Collections.sort(c, InstallerVersionComparator.INSTANCE);
|
||||
return c;
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.util.Arrays;
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public class Extract extends Object implements Cloneable {
|
||||
|
||||
String[] exclude;
|
||||
|
||||
@Override
|
||||
@@ -31,6 +32,5 @@ public class Extract extends Object implements Cloneable {
|
||||
e.exclude = exclude == null ? null : Arrays.copyOf(exclude, exclude.length);
|
||||
return e;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ package org.jackhuang.hellominecraft.launcher.version;
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public enum GameDirType {
|
||||
|
||||
ROOT_FOLDER,
|
||||
VERSION_FOLDER;
|
||||
}
|
||||
|
||||
@@ -24,33 +24,39 @@ import org.jackhuang.hellominecraft.launcher.utils.download.DownloadType;
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public abstract class IMinecraftLibrary implements Cloneable {
|
||||
|
||||
|
||||
public String name;
|
||||
|
||||
public IMinecraftLibrary(String name) {
|
||||
this.name = name;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
public abstract boolean isRequiredToUnzip();
|
||||
|
||||
public abstract String[] getDecompressExtractRules();
|
||||
|
||||
public abstract void init();
|
||||
|
||||
public abstract boolean allow();
|
||||
|
||||
public abstract File getFilePath(File gameDir);
|
||||
|
||||
public abstract String getDownloadURL(String urlBase, DownloadType downloadType);
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if(obj instanceof MinecraftLibrary)
|
||||
return ((MinecraftLibrary) obj).name.equals(name);
|
||||
return false;
|
||||
if (obj instanceof MinecraftLibrary)
|
||||
return ((MinecraftLibrary) obj).name.equals(name);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 3;
|
||||
hash = 89 * hash + (this.name != null ? this.name.hashCode() : 0);
|
||||
return hash;
|
||||
int hash = 3;
|
||||
hash = 89 * hash + (this.name != null ? this.name.hashCode() : 0);
|
||||
return hash;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public abstract Object clone();
|
||||
}
|
||||
|
||||
@@ -29,46 +29,46 @@ import org.jackhuang.hellominecraft.launcher.utils.download.DownloadType;
|
||||
public class MinecraftClassicVersion extends MinecraftVersion {
|
||||
|
||||
public MinecraftClassicVersion() {
|
||||
super();
|
||||
super();
|
||||
|
||||
mainClass = "net.minecraft.client.Minecraft";
|
||||
id = "Classic";
|
||||
type = "release";
|
||||
processArguments = assets = releaseTime = time = null;
|
||||
minecraftArguments = "${auth_player_name} ${auth_session} --workDir ${game_directory}";
|
||||
libraries = new ArrayList<>();
|
||||
libraries.add(new MinecraftOldLibrary("lwjgl"));
|
||||
libraries.add(new MinecraftOldLibrary("jinput"));
|
||||
libraries.add(new MinecraftOldLibrary("lwjgl_util"));
|
||||
mainClass = "net.minecraft.client.Minecraft";
|
||||
id = "Classic";
|
||||
type = "release";
|
||||
processArguments = assets = releaseTime = time = null;
|
||||
minecraftArguments = "${auth_player_name} ${auth_session} --workDir ${game_directory}";
|
||||
libraries = new ArrayList<>();
|
||||
libraries.add(new MinecraftOldLibrary("lwjgl"));
|
||||
libraries.add(new MinecraftOldLibrary("jinput"));
|
||||
libraries.add(new MinecraftOldLibrary("lwjgl_util"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() {
|
||||
return super.clone();
|
||||
return super.clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MinecraftVersion resolve(IMinecraftProvider manager, Set<String> resolvedSoFar, DownloadType sourceType) {
|
||||
return this;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getJar(File gameDir) {
|
||||
return new File(gameDir, "bin/minecraft.jar");
|
||||
return new File(gameDir, "bin/minecraft.jar");
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getJar(File gameDir, String suffix) {
|
||||
return new File(gameDir, "bin/minecraft" + suffix + ".jar");
|
||||
return new File(gameDir, "bin/minecraft" + suffix + ".jar");
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getNatives(File gameDir) {
|
||||
return new File(gameDir, "bin/natives");
|
||||
return new File(gameDir, "bin/natives");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isAllowedToUnpackNatives() {
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,28 +31,28 @@ import org.jackhuang.hellominecraft.utils.StrUtils;
|
||||
public class MinecraftLibrary extends IMinecraftLibrary {
|
||||
|
||||
public ArrayList<Rules> rules;
|
||||
public String url, formatted=null;
|
||||
public String url, formatted = null;
|
||||
//public boolean serverreq=true, clientreq=true;
|
||||
public String[] checksums;
|
||||
public Natives natives;
|
||||
public Extract extract;
|
||||
|
||||
public MinecraftLibrary(String name) {
|
||||
super(name);
|
||||
super(name);
|
||||
}
|
||||
|
||||
public MinecraftLibrary(ArrayList<Rules> rules, String url, String[] checksums, Natives natives, String name, Extract extract) {
|
||||
super(name);
|
||||
this.rules = rules == null ? null : (ArrayList<Rules>) rules.clone();
|
||||
this.url = url;
|
||||
this.checksums = checksums == null ? null : Arrays.copyOf(checksums, checksums.length);
|
||||
this.natives = natives == null ? null : (Natives)natives.clone();
|
||||
this.extract = extract == null ? null :(Extract)extract.clone();
|
||||
super(name);
|
||||
this.rules = rules == null ? null : (ArrayList<Rules>) rules.clone();
|
||||
this.url = url;
|
||||
this.checksums = checksums == null ? null : Arrays.copyOf(checksums, checksums.length);
|
||||
this.natives = natives == null ? null : (Natives) natives.clone();
|
||||
this.extract = extract == null ? null : (Extract) extract.clone();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object clone() {
|
||||
return new MinecraftLibrary(rules, url, checksums, natives, name, extract);
|
||||
return new MinecraftLibrary(rules, url, checksums, natives, name, extract);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -62,73 +62,68 @@ public class MinecraftLibrary extends IMinecraftLibrary {
|
||||
*/
|
||||
@Override
|
||||
public boolean allow() {
|
||||
boolean flag = false;
|
||||
if (rules == null || rules.isEmpty()) {
|
||||
flag = true;
|
||||
} else {
|
||||
for (Rules r : rules) {
|
||||
if (r.action.equals("disallow")) {
|
||||
if (r.os != null && (StrUtils.isBlank(r.os.name) || r.os.name.equalsIgnoreCase(OS.os().toString()))) {
|
||||
flag = false;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (r.os == null || (r.os != null && (StrUtils.isBlank(r.os.name) || r.os.name.equalsIgnoreCase(OS.os().toString())))) {
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return flag;
|
||||
boolean flag = false;
|
||||
if (rules == null || rules.isEmpty())
|
||||
flag = true;
|
||||
else
|
||||
for (Rules r : rules)
|
||||
if (r.action.equals("disallow")) {
|
||||
if (r.os != null && (StrUtils.isBlank(r.os.name) || r.os.name.equalsIgnoreCase(OS.os().toString()))) {
|
||||
flag = false;
|
||||
break;
|
||||
}
|
||||
} else
|
||||
if (r.os == null || (r.os != null && (StrUtils.isBlank(r.os.name) || r.os.name.equalsIgnoreCase(OS.os().toString()))))
|
||||
flag = true;
|
||||
return flag;
|
||||
}
|
||||
|
||||
private String formatArch(String nati) {
|
||||
return nati == null ? "" : nati.replace("${arch}", Platform.getPlatform().getBit());
|
||||
return nati == null ? "" : nati.replace("${arch}", Platform.getPlatform().getBit());
|
||||
}
|
||||
|
||||
private String getNative() {
|
||||
OS os = OS.os();
|
||||
if (os == OS.WINDOWS) {
|
||||
return formatArch(natives.windows);
|
||||
} else if (os == OS.OSX) {
|
||||
return formatArch(natives.osx);
|
||||
} else {
|
||||
return formatArch(natives.linux);
|
||||
}
|
||||
OS os = OS.os();
|
||||
if (os == OS.WINDOWS)
|
||||
return formatArch(natives.windows);
|
||||
else if (os == OS.OSX)
|
||||
return formatArch(natives.osx);
|
||||
else
|
||||
return formatArch(natives.linux);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRequiredToUnzip() {
|
||||
return natives != null && allow();
|
||||
return natives != null && allow();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
String str = name;
|
||||
String[] s = str.split(":");
|
||||
str = s[0];
|
||||
str = str.replace('.', File.separatorChar);
|
||||
if (natives == null) {
|
||||
str += File.separator + s[1] + File.separator + s[2]
|
||||
+ File.separator + s[1] + '-' + s[2] + ".jar";
|
||||
} else {
|
||||
str += File.separator + s[1] + File.separator + s[2]
|
||||
+ File.separator + s[1] + '-' + s[2] + '-';
|
||||
str += getNative();
|
||||
str += ".jar";
|
||||
}
|
||||
formatted = str;
|
||||
String str = name;
|
||||
String[] s = str.split(":");
|
||||
str = s[0];
|
||||
str = str.replace('.', File.separatorChar);
|
||||
if (natives == null)
|
||||
str += File.separator + s[1] + File.separator + s[2]
|
||||
+ File.separator + s[1] + '-' + s[2] + ".jar";
|
||||
else {
|
||||
str += File.separator + s[1] + File.separator + s[2]
|
||||
+ File.separator + s[1] + '-' + s[2] + '-';
|
||||
str += getNative();
|
||||
str += ".jar";
|
||||
}
|
||||
formatted = str;
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getFilePath(File gameDir) {
|
||||
return new File(gameDir, "libraries" + File.separatorChar + formatted);
|
||||
return new File(gameDir, "libraries" + File.separatorChar + formatted);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDownloadURL(String urlBase, DownloadType downloadType) {
|
||||
if(StrUtils.isNotBlank(url)&&downloadType.getProvider().isAllowedToUseSelfURL()) urlBase = this.url;
|
||||
return urlBase + formatted.replace('\\', '/');
|
||||
if (StrUtils.isNotBlank(url) && downloadType.getProvider().isAllowedToUseSelfURL()) urlBase = this.url;
|
||||
return urlBase + formatted.replace('\\', '/');
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -26,12 +26,12 @@ import org.jackhuang.hellominecraft.launcher.utils.download.DownloadType;
|
||||
public class MinecraftOldLibrary extends MinecraftLibrary {
|
||||
|
||||
public MinecraftOldLibrary(String name) {
|
||||
super(name);
|
||||
super(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRequiredToUnzip() {
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -40,22 +40,22 @@ public class MinecraftOldLibrary extends MinecraftLibrary {
|
||||
|
||||
@Override
|
||||
public boolean allow() {
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getFilePath(File gameDir) {
|
||||
return new File(gameDir, "bin/" + name + ".jar");
|
||||
return new File(gameDir, "bin/" + name + ".jar");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() {
|
||||
return new MinecraftOldLibrary(name);
|
||||
return new MinecraftOldLibrary(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDownloadURL(String urlBase, DownloadType downloadType) {
|
||||
return null;
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ import org.jackhuang.hellominecraft.utils.ArrayUtils;
|
||||
public class MinecraftVersion implements Cloneable, Comparable<MinecraftVersion> {
|
||||
|
||||
public String minecraftArguments, mainClass, time, id, type, processArguments,
|
||||
releaseTime, assets, jar, inheritsFrom;
|
||||
releaseTime, assets, jar, inheritsFrom;
|
||||
public int minimumLauncherVersion;
|
||||
public boolean hidden;
|
||||
|
||||
@@ -43,82 +43,79 @@ public class MinecraftVersion implements Cloneable, Comparable<MinecraftVersion>
|
||||
}
|
||||
|
||||
public MinecraftVersion(String minecraftArguments, String mainClass, String time, String id, String type, String processArguments, String releaseTime, String assets, String jar, String inheritsFrom, int minimumLauncherVersion, List<MinecraftLibrary> libraries, boolean hidden) {
|
||||
this();
|
||||
this.minecraftArguments = minecraftArguments;
|
||||
this.mainClass = mainClass;
|
||||
this.time = time;
|
||||
this.id = id;
|
||||
this.type = type;
|
||||
this.processArguments = processArguments;
|
||||
this.releaseTime = releaseTime;
|
||||
this.assets = assets;
|
||||
this.jar = jar;
|
||||
this.inheritsFrom = inheritsFrom;
|
||||
this.minimumLauncherVersion = minimumLauncherVersion;
|
||||
this();
|
||||
this.minecraftArguments = minecraftArguments;
|
||||
this.mainClass = mainClass;
|
||||
this.time = time;
|
||||
this.id = id;
|
||||
this.type = type;
|
||||
this.processArguments = processArguments;
|
||||
this.releaseTime = releaseTime;
|
||||
this.assets = assets;
|
||||
this.jar = jar;
|
||||
this.inheritsFrom = inheritsFrom;
|
||||
this.minimumLauncherVersion = minimumLauncherVersion;
|
||||
this.hidden = hidden;
|
||||
if(libraries == null) this.libraries = new ArrayList<>();
|
||||
else {
|
||||
this.libraries = new ArrayList<>(libraries.size());
|
||||
for (IMinecraftLibrary library : libraries) {
|
||||
this.libraries.add((MinecraftLibrary) library.clone());
|
||||
}
|
||||
}
|
||||
if (libraries == null) this.libraries = new ArrayList<>();
|
||||
else {
|
||||
this.libraries = new ArrayList<>(libraries.size());
|
||||
for (IMinecraftLibrary library : libraries)
|
||||
this.libraries.add((MinecraftLibrary) library.clone());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() {
|
||||
return new MinecraftVersion(minecraftArguments, mainClass, time, id, type, processArguments, releaseTime, assets, jar, inheritsFrom, minimumLauncherVersion, libraries, hidden);
|
||||
return new MinecraftVersion(minecraftArguments, mainClass, time, id, type, processArguments, releaseTime, assets, jar, inheritsFrom, minimumLauncherVersion, libraries, hidden);
|
||||
}
|
||||
|
||||
public MinecraftVersion resolve(IMinecraftProvider manager, DownloadType sourceType) {
|
||||
return resolve(manager, new HashSet<>(), sourceType);
|
||||
return resolve(manager, new HashSet<>(), sourceType);
|
||||
}
|
||||
|
||||
protected MinecraftVersion resolve(IMinecraftProvider manager, Set<String> resolvedSoFar, DownloadType sourceType) {
|
||||
if (inheritsFrom == null) {
|
||||
return this;
|
||||
}
|
||||
if (!resolvedSoFar.add(id)) {
|
||||
throw new IllegalStateException("Circular dependency detected.");
|
||||
}
|
||||
if (inheritsFrom == null)
|
||||
return this;
|
||||
if (!resolvedSoFar.add(id))
|
||||
throw new IllegalStateException("Circular dependency detected.");
|
||||
|
||||
MinecraftVersion parent = manager.getVersionById(inheritsFrom);
|
||||
if(parent == null) {
|
||||
if(!manager.install(inheritsFrom, sourceType)) return this;
|
||||
parent = manager.getVersionById(inheritsFrom);
|
||||
}
|
||||
parent = parent.resolve(manager, resolvedSoFar, sourceType);
|
||||
MinecraftVersion result = new MinecraftVersion(
|
||||
this.minecraftArguments != null ? this.minecraftArguments : parent.minecraftArguments,
|
||||
this.mainClass != null ? this.mainClass : parent.mainClass,
|
||||
this.time, this.id, this.type, parent.processArguments, this.releaseTime,
|
||||
this.assets != null ? this.assets : parent.assets,
|
||||
this.jar != null ? this.jar : parent.jar,
|
||||
null, parent.minimumLauncherVersion,
|
||||
this.libraries != null ? ArrayUtils.merge(this.libraries, parent.libraries) : parent.libraries, this.hidden);
|
||||
|
||||
return result;
|
||||
MinecraftVersion parent = manager.getVersionById(inheritsFrom);
|
||||
if (parent == null) {
|
||||
if (!manager.install(inheritsFrom, sourceType)) return this;
|
||||
parent = manager.getVersionById(inheritsFrom);
|
||||
}
|
||||
parent = parent.resolve(manager, resolvedSoFar, sourceType);
|
||||
MinecraftVersion result = new MinecraftVersion(
|
||||
this.minecraftArguments != null ? this.minecraftArguments : parent.minecraftArguments,
|
||||
this.mainClass != null ? this.mainClass : parent.mainClass,
|
||||
this.time, this.id, this.type, parent.processArguments, this.releaseTime,
|
||||
this.assets != null ? this.assets : parent.assets,
|
||||
this.jar != null ? this.jar : parent.jar,
|
||||
null, parent.minimumLauncherVersion,
|
||||
this.libraries != null ? ArrayUtils.merge(this.libraries, parent.libraries) : parent.libraries, this.hidden);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public File getJar(File gameDir) {
|
||||
String jarId = this.jar == null ? this.id : this.jar;
|
||||
return new File(gameDir, "versions/" + jarId + "/" + jarId + ".jar");
|
||||
String jarId = this.jar == null ? this.id : this.jar;
|
||||
return new File(gameDir, "versions/" + jarId + "/" + jarId + ".jar");
|
||||
}
|
||||
|
||||
public File getJar(File gameDir, String suffix) {
|
||||
String jarId = this.jar == null ? this.id : this.jar;
|
||||
return new File(gameDir, "versions/" + jarId + "/" + jarId + suffix + ".jar");
|
||||
String jarId = this.jar == null ? this.id : this.jar;
|
||||
return new File(gameDir, "versions/" + jarId + "/" + jarId + suffix + ".jar");
|
||||
}
|
||||
|
||||
public File getNatives(File gameDir) {
|
||||
return new File(gameDir, "versions/" + id + "/" + id
|
||||
+ "-natives");
|
||||
return new File(gameDir, "versions/" + id + "/" + id
|
||||
+ "-natives");
|
||||
}
|
||||
|
||||
|
||||
public boolean isAllowedToUnpackNatives() {
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public String getAssets() {
|
||||
return assets == null ? AssetsIndex.DEFAULT_ASSET_NAME : assets;
|
||||
}
|
||||
|
||||
@@ -118,12 +118,10 @@ public final class MinecraftVersionManager extends IMinecraftProvider {
|
||||
if (StrUtils.formatVersion(id) == null) {
|
||||
if (MessageBox.Show(C.i18n("launcher.versions_json_not_matched_cannot_auto_completion", id), MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION)
|
||||
FileUtils.deleteDirectoryQuietly(dir);
|
||||
} else if (MessageBox.Show(C.i18n("launcher.versions_json_not_matched_needs_auto_completion", id), MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION) {
|
||||
if (!refreshJson(id)) {
|
||||
} else if (MessageBox.Show(C.i18n("launcher.versions_json_not_matched_needs_auto_completion", id), MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION)
|
||||
if (!refreshJson(id))
|
||||
if (MessageBox.Show(C.i18n("launcher.versions_json_not_matched_cannot_auto_completion", id), MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION)
|
||||
FileUtils.deleteDirectoryQuietly(dir);
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
MinecraftVersion mcVersion;
|
||||
@@ -215,10 +213,10 @@ public final class MinecraftVersionManager extends IMinecraftProvider {
|
||||
@Override
|
||||
public File getRunDirectory(String id) {
|
||||
switch (profile.getGameDirType()) {
|
||||
case VERSION_FOLDER:
|
||||
return new File(baseFolder, "versions/" + id + "/");
|
||||
default:
|
||||
return baseFolder;
|
||||
case VERSION_FOLDER:
|
||||
return new File(baseFolder, "versions/" + id + "/");
|
||||
default:
|
||||
return baseFolder;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -226,7 +224,7 @@ public final class MinecraftVersionManager extends IMinecraftProvider {
|
||||
public List<GameLauncher.DownloadLibraryJob> getDownloadLibraries(DownloadType downloadType) {
|
||||
ArrayList<DownloadLibraryJob> downloadLibraries = new ArrayList<>();
|
||||
MinecraftVersion v = profile.getSelectedMinecraftVersion().resolve(this, Settings.getInstance().getDownloadSource());
|
||||
if(v.libraries != null) {
|
||||
if (v.libraries != null)
|
||||
for (IMinecraftLibrary l : v.libraries) {
|
||||
l.init();
|
||||
if (l.allow()) {
|
||||
@@ -239,7 +237,6 @@ public final class MinecraftVersionManager extends IMinecraftProvider {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return downloadLibraries;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ package org.jackhuang.hellominecraft.launcher.version;
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public class Natives implements Cloneable {
|
||||
|
||||
public String windows, osx, linux;
|
||||
|
||||
@Override
|
||||
|
||||
@@ -21,5 +21,6 @@ package org.jackhuang.hellominecraft.launcher.version;
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public class OS {
|
||||
|
||||
public String version, name;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ package org.jackhuang.hellominecraft.launcher.version;
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public class Rules {
|
||||
|
||||
public String action;
|
||||
public OS os;
|
||||
}
|
||||
|
||||
@@ -63,9 +63,8 @@ public class DraggableFrame extends JFrame
|
||||
|
||||
@Override
|
||||
public void mouseDragged(MouseEvent e) {
|
||||
if ((e.getModifiersEx() & 0x400) != 0) {
|
||||
if ((e.getModifiersEx() & 0x400) != 0)
|
||||
setLocation(e.getXOnScreen() - this.dragGripX, e.getYOnScreen() - this.dragGripY);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -914,7 +914,7 @@ btnRefreshLiteLoader.addActionListener(new java.awt.event.ActionListener() {
|
||||
private void btnRemoveProfileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRemoveProfileActionPerformed
|
||||
if (profile == null) return;
|
||||
if (MessageBox.Show(C.i18n("ui.message.sure_remove", profile.getName()), MessageBox.YES_NO_OPTION) == MessageBox.NO_OPTION) return;
|
||||
if(Settings.delVersion(profile)) {
|
||||
if (Settings.delVersion(profile)) {
|
||||
cboProfiles.removeItem(profile.getName());
|
||||
profile = Settings.getOneProfile();
|
||||
if (profile != null) {
|
||||
@@ -925,12 +925,12 @@ btnRefreshLiteLoader.addActionListener(new java.awt.event.ActionListener() {
|
||||
}//GEN-LAST:event_btnRemoveProfileActionPerformed
|
||||
|
||||
private void cboVersionsItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cboVersionsItemStateChanged
|
||||
|
||||
|
||||
if (isLoading || evt.getStateChange() != ItemEvent.SELECTED || cboVersions.getSelectedIndex() < 0 || StrUtils.isBlank((String) cboVersions.getSelectedItem()) || getProfile() == null)
|
||||
return;
|
||||
loadMinecraftVersion((String) cboVersions.getSelectedItem());
|
||||
versionChanged(getProfile(), (String) cboVersions.getSelectedItem());
|
||||
|
||||
|
||||
getProfile().setSelectedMinecraftVersion(cboVersions.getSelectedItem().toString());
|
||||
cboVersions.setToolTipText(cboVersions.getSelectedItem().toString());
|
||||
Settings.save();
|
||||
|
||||
@@ -48,7 +48,7 @@ public class HeaderTab extends JLabel
|
||||
return this.isActive;
|
||||
}
|
||||
|
||||
public void setIsActive(boolean isActive) {
|
||||
public final void setIsActive(boolean isActive) {
|
||||
this.isActive = isActive;
|
||||
setOpaque(isActive);
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ public class LauncherSettingsPanel extends javax.swing.JPanel {
|
||||
*/
|
||||
public LauncherSettingsPanel() {
|
||||
initComponents();
|
||||
|
||||
|
||||
txtBackgroundPath.setText(Settings.getInstance().getBgpath());
|
||||
txtProxyHost.setText(Settings.getInstance().getProxyHost());
|
||||
txtProxyPort.setText(Settings.getInstance().getProxyPort());
|
||||
@@ -46,7 +46,7 @@ public class LauncherSettingsPanel extends javax.swing.JPanel {
|
||||
cboDownloadSource.setSelectedIndex(Settings.getInstance().getDownloadType());
|
||||
cboTheme.setSelectedIndex(Settings.getInstance().getTheme());
|
||||
chkEnableShadow.setSelected(Settings.getInstance().isEnableShadow());
|
||||
|
||||
|
||||
setBackground(Color.white);
|
||||
setOpaque(true);
|
||||
}
|
||||
@@ -259,9 +259,8 @@ public class LauncherSettingsPanel extends javax.swing.JPanel {
|
||||
fc.setDialogTitle(C.i18n("launcher.choose_bgpath"));
|
||||
fc.setMultiSelectionEnabled(false);
|
||||
fc.showOpenDialog(this);
|
||||
if (fc.getSelectedFile() == null) {
|
||||
if (fc.getSelectedFile() == null)
|
||||
return;
|
||||
}
|
||||
try {
|
||||
String path = fc.getSelectedFile().getCanonicalPath();
|
||||
path = IOUtils.removeLastSeparator(path);
|
||||
@@ -289,7 +288,7 @@ public class LauncherSettingsPanel extends javax.swing.JPanel {
|
||||
|
||||
private void cboThemeItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cboThemeItemStateChanged
|
||||
Settings.getInstance().setTheme(cboTheme.getSelectedIndex());
|
||||
if(MainFrame.instance != null)
|
||||
if (MainFrame.instance != null)
|
||||
MainFrame.instance.reloadColor();
|
||||
}//GEN-LAST:event_cboThemeItemStateChanged
|
||||
|
||||
|
||||
@@ -86,8 +86,7 @@ public final class MainFrame extends DraggableFrame {
|
||||
|
||||
if (enableShadow)
|
||||
try {
|
||||
//AWTUtilities.setWindowOpaque(this, false);
|
||||
setBackground(new Color(0,0,0,0));
|
||||
setBackground(new Color(0, 0, 0, 0));
|
||||
getRootPane().setBorder(border = new DropShadowBorder(borderColor, 4));
|
||||
} catch (Throwable ex) {
|
||||
HMCLog.err("Failed to set window transparent.", ex);
|
||||
@@ -250,14 +249,14 @@ public final class MainFrame extends DraggableFrame {
|
||||
this.mainTab.setIsActive(true);
|
||||
this.mainPanel.onSelected();
|
||||
} else if (tabName.equalsIgnoreCase("game")) {
|
||||
if(gamePanel == null) {
|
||||
if (gamePanel == null) {
|
||||
gamePanel = new GameSettingsPanel();
|
||||
gamePanelWrapper.add(gamePanel);
|
||||
}
|
||||
this.gameTab.setIsActive(true);
|
||||
this.gamePanel.onSelected();
|
||||
} else if (tabName.equalsIgnoreCase("launcher")) {
|
||||
if(launcherPanel == null) {
|
||||
if (launcherPanel == null) {
|
||||
launcherPanel = new LauncherSettingsPanel();
|
||||
launcherPanelWrapper.add(launcherPanel);
|
||||
}
|
||||
|
||||
@@ -457,7 +457,7 @@ public class MainPagePanel extends javax.swing.JPanel {
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
MessageBox.Show(C.i18n("mainwindow.no_version"));
|
||||
showedNoVersion = true;
|
||||
});
|
||||
});
|
||||
} else {
|
||||
for (MinecraftVersion mcVersion : getCurrentProfile().getMinecraftProvider().getVersions()) {
|
||||
if (mcVersion.hidden) continue;
|
||||
|
||||
Reference in New Issue
Block a user