Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
61a8ab5199 | ||
|
|
ce721c2e09 | ||
|
|
2862e3a6ee | ||
|
|
75c4a24cbd | ||
|
|
1cf7d791cc | ||
|
|
62fecc08ac | ||
|
|
491ca63342 | ||
|
|
b232a255e7 | ||
|
|
0870f42557 | ||
|
|
85237eac7e | ||
|
|
8d5088d2e4 | ||
|
|
47f5bf1ea5 | ||
|
|
deebadef3a | ||
|
|
ce24ae4fae | ||
|
|
16152de39d | ||
|
|
4a2ac63d25 | ||
|
|
5437968c83 | ||
|
|
8022252452 | ||
|
|
ea6571fdb6 | ||
|
|
2f7f692b84 | ||
|
|
721df1d17c | ||
|
|
7a2e43f949 |
No files matched your search
Executable → Regular
+2
@@ -25,3 +25,5 @@ HMCL/build/
|
|||||||
HMCLServer/
|
HMCLServer/
|
||||||
HMCSM/build/
|
HMCSM/build/
|
||||||
MetroLookAndFeel/build/
|
MetroLookAndFeel/build/
|
||||||
|
/HMCUtils/build/
|
||||||
|
/HMCLaF/build/
|
||||||
+32
-2
@@ -47,6 +47,7 @@ String mavenArtifactId = name
|
|||||||
|
|
||||||
task generateSources(type: Copy) {
|
task generateSources(type: Copy) {
|
||||||
from 'src/main/java'
|
from 'src/main/java'
|
||||||
|
from 'src/core/java'
|
||||||
into "$buildDir/generated-src"
|
into "$buildDir/generated-src"
|
||||||
filter(org.apache.tools.ant.filters.ReplaceTokens, tokens: [
|
filter(org.apache.tools.ant.filters.ReplaceTokens, tokens: [
|
||||||
'HELLO_MINECRAFT_LAUNCHER_VERSION_FOR_GRADLE_REPLACING': mavenVersion
|
'HELLO_MINECRAFT_LAUNCHER_VERSION_FOR_GRADLE_REPLACING': mavenVersion
|
||||||
@@ -55,6 +56,35 @@ task generateSources(type: Copy) {
|
|||||||
compileJava.setSource "$buildDir/generated-src"
|
compileJava.setSource "$buildDir/generated-src"
|
||||||
compileJava.dependsOn generateSources
|
compileJava.dependsOn generateSources
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
main {
|
||||||
|
java {
|
||||||
|
srcDirs = [
|
||||||
|
'src/core/java/',
|
||||||
|
'src/main/java/'
|
||||||
|
]
|
||||||
|
}
|
||||||
|
resources {
|
||||||
|
srcDirs = ['src/main/resources/']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
core {
|
||||||
|
java {
|
||||||
|
compileClasspath += main.compileClasspath
|
||||||
|
runtimeClasspath += main.runtimeClasspath
|
||||||
|
srcDirs 'src/core/java/'
|
||||||
|
}
|
||||||
|
resources {
|
||||||
|
srcDirs 'src/main/resources/'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
configurations {
|
||||||
|
coreCompile.extendsFrom compile
|
||||||
|
coreRuntime.extendsFrom runtime
|
||||||
|
}
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral();
|
mavenCentral();
|
||||||
@@ -80,8 +110,8 @@ configure(install.repositories.mavenInstaller) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile project(":MetroLookAndFeel")
|
compile project(":HMCLaF")
|
||||||
compile project(":HMCLAPI")
|
compile project(":HMCUtils")
|
||||||
compile group: "org.commonjava.googlecode.markdown4j", name: "markdown4j", version: "2.2-cj-1.0"
|
compile group: "org.commonjava.googlecode.markdown4j", name: "markdown4j", version: "2.2-cj-1.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
+2
-3
@@ -19,7 +19,6 @@ package org.jackhuang.hellominecraft.launcher.api;
|
|||||||
|
|
||||||
import org.jackhuang.hellominecraft.launcher.core.GameException;
|
import org.jackhuang.hellominecraft.launcher.core.GameException;
|
||||||
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftService;
|
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftService;
|
||||||
import org.jackhuang.hellominecraft.launcher.setting.Profile;
|
|
||||||
import org.jackhuang.hellominecraft.launcher.core.auth.AuthenticationException;
|
import org.jackhuang.hellominecraft.launcher.core.auth.AuthenticationException;
|
||||||
import org.jackhuang.hellominecraft.launcher.core.auth.IAuthenticator;
|
import org.jackhuang.hellominecraft.launcher.core.auth.IAuthenticator;
|
||||||
import org.jackhuang.hellominecraft.launcher.core.auth.UserProfileProvider;
|
import org.jackhuang.hellominecraft.launcher.core.auth.UserProfileProvider;
|
||||||
@@ -35,12 +34,12 @@ public interface IPlugin {
|
|||||||
/**
|
/**
|
||||||
* You can modify the application actions by this method.
|
* You can modify the application actions by this method.
|
||||||
*
|
*
|
||||||
* @param profile info to the Minecraft Loader
|
* @param obj minecraft service wanted
|
||||||
*
|
*
|
||||||
* @return For example, you can implement IMinecraftProvider to support
|
* @return For example, you can implement IMinecraftProvider to support
|
||||||
* MultiMC
|
* MultiMC
|
||||||
*/
|
*/
|
||||||
IMinecraftService provideMinecraftService(Profile profile);
|
IMinecraftService provideMinecraftService(Object obj);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register authenticators by calling IAuthenticator.LOGINS.add.
|
* Register authenticators by calling IAuthenticator.LOGINS.add.
|
||||||
+10
-7
@@ -18,7 +18,6 @@
|
|||||||
package org.jackhuang.hellominecraft.launcher.api;
|
package org.jackhuang.hellominecraft.launcher.api;
|
||||||
|
|
||||||
import org.jackhuang.hellominecraft.util.logging.HMCLog;
|
import org.jackhuang.hellominecraft.util.logging.HMCLog;
|
||||||
import org.jackhuang.hellominecraft.launcher.util.DefaultPlugin;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -26,17 +25,21 @@ import org.jackhuang.hellominecraft.launcher.util.DefaultPlugin;
|
|||||||
*/
|
*/
|
||||||
public class PluginManager {
|
public class PluginManager {
|
||||||
|
|
||||||
private static IPlugin NOW_PLUGIN = new DefaultPlugin();
|
private static IPlugin NOW_PLUGIN;
|
||||||
|
|
||||||
public static void getServerPlugin() {
|
public static void getServerPlugin() {
|
||||||
try {
|
try {
|
||||||
ClassLoader cl = Thread.currentThread().getContextClassLoader();
|
getPlugin(Thread.currentThread().getContextClassLoader().loadClass("org.jackhuang.hellominecraft.launcher.server.ServerPlugin"));
|
||||||
Class c = cl.loadClass("org.jackhuang.hellominecraft.launcher.server.ServerPlugin");
|
|
||||||
IPlugin p = (IPlugin) c.newInstance();
|
|
||||||
NOW_PLUGIN = p;
|
|
||||||
} catch (ClassNotFoundException ignore) {
|
} catch (ClassNotFoundException ignore) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void getPlugin(Class<?> cls) {
|
||||||
|
try {
|
||||||
|
IPlugin p = (IPlugin) cls.newInstance();
|
||||||
|
NOW_PLUGIN = p;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
HMCLog.err("Failed to new instance");
|
HMCLog.err("Failed to new instance");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
File renamed without changes.
+6
-10
@@ -20,7 +20,6 @@ package org.jackhuang.hellominecraft.launcher.core;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import org.jackhuang.hellominecraft.util.system.FileUtils;
|
import org.jackhuang.hellominecraft.util.system.FileUtils;
|
||||||
import org.jackhuang.hellominecraft.util.system.IOUtils;
|
|
||||||
import org.jackhuang.hellominecraft.util.system.OS;
|
import org.jackhuang.hellominecraft.util.system.OS;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -63,14 +62,11 @@ public final class MCUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static File getInitGameDir() {
|
public static File getInitGameDir() {
|
||||||
File gameDir = IOUtils.currentDir();
|
File gameDir = new File(MCUtils.minecraft());
|
||||||
if (gameDir.exists()) {
|
if (!gameDir.exists()) {
|
||||||
gameDir = new File(gameDir, MCUtils.minecraft());
|
File newFile = MCUtils.getLocation();
|
||||||
if (!gameDir.exists()) {
|
if (newFile.exists())
|
||||||
File newFile = MCUtils.getLocation();
|
gameDir = newFile;
|
||||||
if (newFile.exists())
|
|
||||||
gameDir = newFile;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return gameDir;
|
return gameDir;
|
||||||
}
|
}
|
||||||
@@ -80,6 +76,6 @@ public final class MCUtils {
|
|||||||
public static void tryWriteProfile(File gameDir) throws IOException {
|
public static void tryWriteProfile(File gameDir) throws IOException {
|
||||||
File file = new File(gameDir, "launcher_profiles.json");
|
File file = new File(gameDir, "launcher_profiles.json");
|
||||||
if (!file.exists())
|
if (!file.exists())
|
||||||
FileUtils.writeStringToFile(file, PROFILE);
|
FileUtils.write(file, PROFILE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+5
@@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.jackhuang.hellominecraft.launcher.core.asset;
|
package org.jackhuang.hellominecraft.launcher.core.asset;
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -29,7 +30,11 @@ import java.util.Set;
|
|||||||
public class AssetsIndex {
|
public class AssetsIndex {
|
||||||
|
|
||||||
public static final String DEFAULT_ASSET_NAME = "legacy";
|
public static final String DEFAULT_ASSET_NAME = "legacy";
|
||||||
|
|
||||||
|
@SerializedName("objects")
|
||||||
public Map<String, AssetsObject> objects;
|
public Map<String, AssetsObject> objects;
|
||||||
|
|
||||||
|
@SerializedName("virtual")
|
||||||
public boolean virtual;
|
public boolean virtual;
|
||||||
|
|
||||||
public AssetsIndex() {
|
public AssetsIndex() {
|
||||||
+1
-1
@@ -66,7 +66,7 @@ public class AssetsMojangLoader extends IAssetsHandler {
|
|||||||
public void executeTask() throws Throwable {
|
public void executeTask() throws Throwable {
|
||||||
if (!areDependTasksSucceeded)
|
if (!areDependTasksSucceeded)
|
||||||
throw new IllegalStateException("Failed to get asset index");
|
throw new IllegalStateException("Failed to get asset index");
|
||||||
String result = FileUtils.readFileToString(f);
|
String result = FileUtils.read(f);
|
||||||
if (StrUtils.isBlank(result))
|
if (StrUtils.isBlank(result))
|
||||||
throw new IllegalStateException("Index json is empty, please redownload it!");
|
throw new IllegalStateException("Index json is empty, please redownload it!");
|
||||||
AssetsIndex o = C.GSON.fromJson(result, AssetsIndex.class);
|
AssetsIndex o = C.GSON.fromJson(result, AssetsIndex.class);
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
+8
-26
@@ -22,7 +22,6 @@ import java.io.File;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.jackhuang.hellominecraft.util.C;
|
import org.jackhuang.hellominecraft.util.C;
|
||||||
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftAssetService;
|
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftAssetService;
|
||||||
@@ -30,8 +29,7 @@ import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftService;
|
|||||||
import org.jackhuang.hellominecraft.launcher.core.version.AssetIndexDownloadInfo;
|
import org.jackhuang.hellominecraft.launcher.core.version.AssetIndexDownloadInfo;
|
||||||
import org.jackhuang.hellominecraft.launcher.core.version.MinecraftVersion;
|
import org.jackhuang.hellominecraft.launcher.core.version.MinecraftVersion;
|
||||||
import org.jackhuang.hellominecraft.util.MessageBox;
|
import org.jackhuang.hellominecraft.util.MessageBox;
|
||||||
import org.jackhuang.hellominecraft.util.Utils;
|
import org.jackhuang.hellominecraft.util.func.BiFunction;
|
||||||
import org.jackhuang.hellominecraft.util.func.Function;
|
|
||||||
import org.jackhuang.hellominecraft.util.logging.HMCLog;
|
import org.jackhuang.hellominecraft.util.logging.HMCLog;
|
||||||
import org.jackhuang.hellominecraft.util.tasks.Task;
|
import org.jackhuang.hellominecraft.util.tasks.Task;
|
||||||
import org.jackhuang.hellominecraft.util.tasks.TaskWindow;
|
import org.jackhuang.hellominecraft.util.tasks.TaskWindow;
|
||||||
@@ -58,23 +56,7 @@ public class MinecraftAssetService extends IMinecraftAssetService {
|
|||||||
public Task downloadAssets(final MinecraftVersion mv) {
|
public Task downloadAssets(final MinecraftVersion mv) {
|
||||||
if (mv == null)
|
if (mv == null)
|
||||||
return null;
|
return null;
|
||||||
return new TaskInfo("Download Assets") {
|
return IAssetsHandler.ASSETS_HANDLER.getList(mv, service.asset()).after(IAssetsHandler.ASSETS_HANDLER.getDownloadTask(service.getDownloadType().getProvider()));
|
||||||
Collection<Task> afters = new HashSet<>();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Collection<Task> getDependTasks() {
|
|
||||||
return Arrays.asList(IAssetsHandler.ASSETS_HANDLER.getList(mv, service.asset()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void executeTask() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Collection<Task> getAfterTasks() {
|
|
||||||
return Arrays.asList(IAssetsHandler.ASSETS_HANDLER.getDownloadTask(service.getDownloadType().getProvider()));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -151,7 +133,7 @@ public class MinecraftAssetService extends IMinecraftAssetService {
|
|||||||
File objectsDir = new File(assetsDir, "objects");
|
File objectsDir = new File(assetsDir, "objects");
|
||||||
File indexFile = new File(indexDir, assetVersion + ".json");
|
File indexFile = new File(indexDir, assetVersion + ".json");
|
||||||
try {
|
try {
|
||||||
AssetsIndex index = (AssetsIndex) C.GSON.fromJson(FileUtils.readFileToString(indexFile, "UTF-8"), AssetsIndex.class);
|
AssetsIndex index = (AssetsIndex) C.GSON.fromJson(FileUtils.read(indexFile, "UTF-8"), AssetsIndex.class);
|
||||||
|
|
||||||
String hash = ((AssetsObject) index.getFileMap().get(name)).getHash();
|
String hash = ((AssetsObject) index.getFileMap().get(name)).getHash();
|
||||||
return new File(objectsDir, hash.substring(0, 2) + "/" + hash);
|
return new File(objectsDir, hash.substring(0, 2) + "/" + hash);
|
||||||
@@ -170,7 +152,7 @@ public class MinecraftAssetService extends IMinecraftAssetService {
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String assetIndexContent = FileUtils.readFileToString(indexFile, "UTF-8");
|
String assetIndexContent = FileUtils.read(indexFile, "UTF-8");
|
||||||
AssetsIndex index = (AssetsIndex) C.GSON.fromJson(assetIndexContent, AssetsIndex.class);
|
AssetsIndex index = (AssetsIndex) C.GSON.fromJson(assetIndexContent, AssetsIndex.class);
|
||||||
|
|
||||||
if (index == null)
|
if (index == null)
|
||||||
@@ -198,7 +180,7 @@ public class MinecraftAssetService extends IMinecraftAssetService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String assetIndexContent = FileUtils.readFileToString(indexFile, "UTF-8");
|
String assetIndexContent = FileUtils.read(indexFile, "UTF-8");
|
||||||
AssetsIndex index = (AssetsIndex) C.GSON.fromJson(assetIndexContent, AssetsIndex.class);
|
AssetsIndex index = (AssetsIndex) C.GSON.fromJson(assetIndexContent, AssetsIndex.class);
|
||||||
|
|
||||||
if (index == null)
|
if (index == null)
|
||||||
@@ -213,7 +195,7 @@ public class MinecraftAssetService extends IMinecraftAssetService {
|
|||||||
if (original.exists()) {
|
if (original.exists()) {
|
||||||
cnt++;
|
cnt++;
|
||||||
if (!target.isFile())
|
if (!target.isFile())
|
||||||
FileUtils.copyFile(original, target, false);
|
FileUtils.copyFile(original, target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// If the scale new format existent file is lower then 0.1, use the old format.
|
// If the scale new format existent file is lower then 0.1, use the old format.
|
||||||
@@ -227,8 +209,8 @@ public class MinecraftAssetService extends IMinecraftAssetService {
|
|||||||
return virtualRoot;
|
return virtualRoot;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final Function<MinecraftVersion, String> ASSET_PROVIDER_IMPL = t -> {
|
public final BiFunction<MinecraftVersion, Boolean, String> ASSET_PROVIDER_IMPL = (t, allow) -> {
|
||||||
if (!checkAssetsExistance(t.getAssetsIndex()))
|
if (allow && !checkAssetsExistance(t.getAssetsIndex()))
|
||||||
if (MessageBox.Show(C.i18n("assets.no_assets"), MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION)
|
if (MessageBox.Show(C.i18n("assets.no_assets"), MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION)
|
||||||
TaskWindow.execute(downloadAssets(t));
|
TaskWindow.execute(downloadAssets(t));
|
||||||
return reconstructAssets(t.getAssetsIndex()).getAbsolutePath();
|
return reconstructAssets(t.getAssetsIndex()).getAbsolutePath();
|
||||||
File renamed without changes.
File renamed without changes.
+2
-1
@@ -96,7 +96,8 @@ public abstract class IAuthenticator {
|
|||||||
public void onLoadSettings(Map m) {
|
public void onLoadSettings(Map m) {
|
||||||
if (m == null)
|
if (m == null)
|
||||||
return;
|
return;
|
||||||
username = (String) m.get("IAuthenticator_UserName");
|
Object o = m.get("IAuthenticator_UserName");
|
||||||
|
username = o instanceof String ? (String) o : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUserName() {
|
public String getUserName() {
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+12
-2
@@ -17,14 +17,24 @@
|
|||||||
*/
|
*/
|
||||||
package org.jackhuang.hellominecraft.launcher.core.auth.yggdrasil;
|
package org.jackhuang.hellominecraft.launcher.core.auth.yggdrasil;
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
public class Response {
|
public class Response {
|
||||||
|
|
||||||
public String accessToken, clientToken;
|
@SerializedName("accessToken")
|
||||||
|
public String accessToken;
|
||||||
|
@SerializedName("clientToken")
|
||||||
|
public String clientToken;
|
||||||
|
@SerializedName("selectedProfile")
|
||||||
public GameProfile selectedProfile;
|
public GameProfile selectedProfile;
|
||||||
|
@SerializedName("availableProfiles")
|
||||||
public GameProfile[] availableProfiles;
|
public GameProfile[] availableProfiles;
|
||||||
|
@SerializedName("user")
|
||||||
public User user;
|
public User user;
|
||||||
|
@SerializedName("error")
|
||||||
public String error;
|
public String error;
|
||||||
|
@SerializedName("errorMessage")
|
||||||
public String errorMessage;
|
public String errorMessage;
|
||||||
|
@SerializedName("cause")
|
||||||
public String cause;
|
public String cause;
|
||||||
}
|
}
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+1
-1
@@ -25,7 +25,7 @@ public class CurseDownloadProvider extends MojangDownloadProvider {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getParsedDownloadURL(String str) {
|
public String getParsedDownloadURL(String str) {
|
||||||
return str == null ? null : str.replace("http://files.minecraftforge.net/maven", "http://ftb.cursecdn.com/FTB2/maven/");
|
return str == null ? null : str.replace("http://files.minecraftforge.net/maven", "http://ftb.cursecdn.com/FTB2/maven");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
+1
-1
@@ -85,7 +85,7 @@ public class MinecraftDownloadService extends IMinecraftDownloadService {
|
|||||||
if (mvj.exists() && !mvj.delete())
|
if (mvj.exists() && !mvj.delete())
|
||||||
HMCLog.warn("Failed to delete " + mvj);
|
HMCLog.warn("Failed to delete " + mvj);
|
||||||
try {
|
try {
|
||||||
MinecraftVersion mv = C.GSON.fromJson(FileUtils.readFileToStringQuietly(new File(vpath, id + ".json")), MinecraftVersion.class);
|
MinecraftVersion mv = C.GSON.fromJson(FileUtils.readQuietly(new File(vpath, id + ".json")), MinecraftVersion.class);
|
||||||
if (mv == null)
|
if (mv == null)
|
||||||
throw new JsonSyntaxException("incorrect version");
|
throw new JsonSyntaxException("incorrect version");
|
||||||
|
|
||||||
File renamed without changes.
+1
-1
@@ -29,6 +29,6 @@ public class MinecraftRemoteVersion {
|
|||||||
public String getUrl(DownloadType type) {
|
public String getUrl(DownloadType type) {
|
||||||
if (url == null)
|
if (url == null)
|
||||||
return type.getProvider().getVersionsDownloadURL() + id + "/" + id + ".json";
|
return type.getProvider().getVersionsDownloadURL() + id + "/" + id + ".json";
|
||||||
return url;
|
return type.getProvider().getParsedDownloadURL(url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+3
@@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.jackhuang.hellominecraft.launcher.core.download;
|
package org.jackhuang.hellominecraft.launcher.core.download;
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import org.jackhuang.hellominecraft.util.C;
|
import org.jackhuang.hellominecraft.util.C;
|
||||||
import org.jackhuang.hellominecraft.util.NetUtils;
|
import org.jackhuang.hellominecraft.util.NetUtils;
|
||||||
@@ -28,7 +29,9 @@ import org.jackhuang.hellominecraft.util.OverridableSwingWorker;
|
|||||||
*/
|
*/
|
||||||
public class MinecraftRemoteVersions {
|
public class MinecraftRemoteVersions {
|
||||||
|
|
||||||
|
@SerializedName("versions")
|
||||||
public ArrayList<MinecraftRemoteVersion> versions;
|
public ArrayList<MinecraftRemoteVersion> versions;
|
||||||
|
@SerializedName("latest")
|
||||||
public MinecraftRemoteLatestVersion latest;
|
public MinecraftRemoteLatestVersion latest;
|
||||||
|
|
||||||
private static volatile MinecraftRemoteVersions INSTANCE = null;
|
private static volatile MinecraftRemoteVersions INSTANCE = null;
|
||||||
+1
-1
@@ -64,7 +64,7 @@ public class MojangDownloadProvider extends IDownloadProvider {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getAssetsDownloadURL() {
|
public String getAssetsDownloadURL() {
|
||||||
return "http://resources.download.minecraft.net/";
|
return "https://resources.download.minecraft.net/";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
+3
-12
@@ -22,13 +22,13 @@ import java.util.ArrayList;
|
|||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import org.jackhuang.hellominecraft.util.func.Consumer;
|
import org.jackhuang.hellominecraft.util.tasks.Task;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author huangyuhui
|
* @author huangyuhui
|
||||||
*/
|
*/
|
||||||
public abstract class InstallerVersionList implements Consumer<String[]> {
|
public abstract class InstallerVersionList {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Refresh installer versions list from the downloaded content.
|
* Refresh installer versions list from the downloaded content.
|
||||||
@@ -37,7 +37,7 @@ public abstract class InstallerVersionList implements Consumer<String[]> {
|
|||||||
*
|
*
|
||||||
* @throws java.lang.Exception including network exceptions, IO exceptions.
|
* @throws java.lang.Exception including network exceptions, IO exceptions.
|
||||||
*/
|
*/
|
||||||
public abstract void refreshList(String[] versions) throws Exception;
|
public abstract Task refresh(String[] versions);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Installer name.
|
* Installer name.
|
||||||
@@ -117,13 +117,4 @@ public abstract class InstallerVersionList implements Consumer<String[]> {
|
|||||||
return o2.compareTo(o1);
|
return o2.compareTo(o1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void accept(String[] v) {
|
|
||||||
try {
|
|
||||||
refreshList(v);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw new RuntimeException(ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
File renamed without changes.
+19
-36
@@ -27,10 +27,9 @@ import org.jackhuang.hellominecraft.launcher.core.install.liteloader.LiteLoaderV
|
|||||||
import org.jackhuang.hellominecraft.launcher.core.install.optifine.OptiFineInstaller;
|
import org.jackhuang.hellominecraft.launcher.core.install.optifine.OptiFineInstaller;
|
||||||
import org.jackhuang.hellominecraft.launcher.core.install.optifine.vanilla.OptiFineDownloadFormatter;
|
import org.jackhuang.hellominecraft.launcher.core.install.optifine.vanilla.OptiFineDownloadFormatter;
|
||||||
import org.jackhuang.hellominecraft.util.tasks.Task;
|
import org.jackhuang.hellominecraft.util.tasks.Task;
|
||||||
import org.jackhuang.hellominecraft.util.tasks.TaskInfo;
|
|
||||||
import org.jackhuang.hellominecraft.util.tasks.TaskWindow;
|
|
||||||
import org.jackhuang.hellominecraft.util.tasks.download.FileDownloadTask;
|
import org.jackhuang.hellominecraft.util.tasks.download.FileDownloadTask;
|
||||||
import org.jackhuang.hellominecraft.util.system.IOUtils;
|
import org.jackhuang.hellominecraft.util.system.IOUtils;
|
||||||
|
import org.jackhuang.hellominecraft.util.tasks.DeleteFileTask;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -58,47 +57,31 @@ public final class MinecraftInstallerService extends IMinecraftInstallerService
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Task downloadForge(String installId, InstallerVersion v) {
|
public Task downloadForge(String installId, InstallerVersion v) {
|
||||||
return new TaskInfo("Forge Downloader") {
|
File filepath = IOUtils.tryGetCanonicalFile("forge-installer.jar");
|
||||||
@Override
|
if (v.installer == null)
|
||||||
public void executeTask() {
|
return null;
|
||||||
File filepath = IOUtils.tryGetCanonicalFile(IOUtils.currentDirWithSeparator() + "forge-installer.jar");
|
else
|
||||||
if (v.installer != null)
|
return new FileDownloadTask(service.getDownloadType().getProvider().getParsedDownloadURL(v.installer), filepath).setTag("forge")
|
||||||
TaskWindow.factory()
|
.after(new ForgeInstaller(service, filepath))
|
||||||
.append(new FileDownloadTask(service.getDownloadType().getProvider().getParsedDownloadURL(v.installer), filepath).setTag("forge"))
|
.after(new DeleteFileTask(filepath));
|
||||||
.append(new ForgeInstaller(service, filepath))
|
|
||||||
.create();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Task downloadOptiFine(String installId, InstallerVersion v) {
|
public Task downloadOptiFine(String installId, InstallerVersion v) {
|
||||||
return new TaskInfo("OptiFine Downloader") {
|
File filepath = IOUtils.tryGetCanonicalFile("optifine-installer.jar");
|
||||||
@Override
|
if (v.installer == null)
|
||||||
public void executeTask() {
|
return null;
|
||||||
File filepath = IOUtils.tryGetCanonicalFile(IOUtils.currentDirWithSeparator() + "optifine-installer.jar");
|
OptiFineDownloadFormatter task = new OptiFineDownloadFormatter(v.installer);
|
||||||
if (v.installer != null) {
|
return task.after(new FileDownloadTask(filepath).registerPreviousResult(task).setTag("optifine"))
|
||||||
OptiFineDownloadFormatter task = new OptiFineDownloadFormatter(v.installer);
|
.after(new OptiFineInstaller(service, installId, v, filepath))
|
||||||
TaskWindow.factory().append(task)
|
.after(new DeleteFileTask(filepath));
|
||||||
.append(new FileDownloadTask(filepath).registerPreviousResult(task).setTag("optifine"))
|
|
||||||
.append(new OptiFineInstaller(service, installId, v, filepath))
|
|
||||||
.create();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Task downloadLiteLoader(String installId, InstallerVersion v) {
|
public Task downloadLiteLoader(String installId, InstallerVersion v) {
|
||||||
return new TaskInfo("LiteLoader Downloader") {
|
File filepath = IOUtils.tryGetCanonicalFile("liteloader-universal.jar");
|
||||||
@Override
|
FileDownloadTask task = (FileDownloadTask) new FileDownloadTask(v.universal, filepath).setTag("LiteLoader");
|
||||||
public void executeTask() {
|
return task.after(new LiteLoaderInstaller(service, installId, (LiteLoaderVersionList.LiteLoaderInstallerVersion) v).registerPreviousResult(task))
|
||||||
File filepath = IOUtils.tryGetCanonicalFile(IOUtils.currentDirWithSeparator() + "liteloader-universal.jar");
|
.after(new DeleteFileTask(filepath));
|
||||||
FileDownloadTask task = (FileDownloadTask) new FileDownloadTask(v.universal, filepath).setTag("LiteLoader");
|
|
||||||
TaskWindow.factory()
|
|
||||||
.append(task).append(new LiteLoaderInstaller(service, installId, (LiteLoaderVersionList.LiteLoaderInstallerVersion) v).registerPreviousResult(task))
|
|
||||||
.create();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
-2
@@ -23,7 +23,6 @@ import java.util.ArrayList;
|
|||||||
import org.jackhuang.hellominecraft.util.logging.HMCLog;
|
import org.jackhuang.hellominecraft.util.logging.HMCLog;
|
||||||
import org.jackhuang.hellominecraft.util.system.Compressor;
|
import org.jackhuang.hellominecraft.util.system.Compressor;
|
||||||
import org.jackhuang.hellominecraft.util.system.FileUtils;
|
import org.jackhuang.hellominecraft.util.system.FileUtils;
|
||||||
import org.jackhuang.hellominecraft.util.system.IOUtils;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -40,7 +39,7 @@ public class PackMinecraftInstaller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void install() throws IOException {
|
public void install() throws IOException {
|
||||||
File file = new File(IOUtils.currentDir(), "HMCL-MERGE-TEMP");
|
File file = new File("HMCL-MERGE-TEMP");
|
||||||
if (!file.exists() && !file.mkdirs())
|
if (!file.exists() && !file.mkdirs())
|
||||||
HMCLog.warn("Failed to make directories: " + file);
|
HMCLog.warn("Failed to make directories: " + file);
|
||||||
for (String src1 : src)
|
for (String src1 : src)
|
||||||
File renamed without changes.
File renamed without changes.
+11
@@ -17,20 +17,31 @@
|
|||||||
*/
|
*/
|
||||||
package org.jackhuang.hellominecraft.launcher.core.install.forge;
|
package org.jackhuang.hellominecraft.launcher.core.install.forge;
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author huangyuhui
|
* @author huangyuhui
|
||||||
*/
|
*/
|
||||||
public class Install {
|
public class Install {
|
||||||
|
|
||||||
|
@SerializedName("profileName")
|
||||||
private String profileName;
|
private String profileName;
|
||||||
|
@SerializedName("target")
|
||||||
private String target;
|
private String target;
|
||||||
|
@SerializedName("path")
|
||||||
private String path;
|
private String path;
|
||||||
|
@SerializedName("version")
|
||||||
private String version;
|
private String version;
|
||||||
|
@SerializedName("filePath")
|
||||||
private String filePath;
|
private String filePath;
|
||||||
|
@SerializedName("welcome")
|
||||||
private String welcome;
|
private String welcome;
|
||||||
|
@SerializedName("minecraft")
|
||||||
private String minecraft;
|
private String minecraft;
|
||||||
|
@SerializedName("mirrorList")
|
||||||
private String mirrorList;
|
private String mirrorList;
|
||||||
|
@SerializedName("logo")
|
||||||
private String logo;
|
private String logo;
|
||||||
|
|
||||||
public Install() {
|
public Install() {
|
||||||
File renamed without changes.
+136
@@ -0,0 +1,136 @@
|
|||||||
|
/*
|
||||||
|
* Hello Minecraft! Launcher.
|
||||||
|
* Copyright (C) 2013 huangyuhui <huanghongxun2008@126.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see {http://www.gnu.org/licenses/}.
|
||||||
|
*/
|
||||||
|
package org.jackhuang.hellominecraft.launcher.core.install.forge;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import org.jackhuang.hellominecraft.util.C;
|
||||||
|
import org.jackhuang.hellominecraft.launcher.core.download.DownloadType;
|
||||||
|
import org.jackhuang.hellominecraft.util.StrUtils;
|
||||||
|
import org.jackhuang.hellominecraft.launcher.core.install.InstallerVersionList;
|
||||||
|
import org.jackhuang.hellominecraft.launcher.core.install.InstallerVersionNewerComparator;
|
||||||
|
import org.jackhuang.hellominecraft.util.tasks.Task;
|
||||||
|
import org.jackhuang.hellominecraft.util.tasks.TaskInfo;
|
||||||
|
import org.jackhuang.hellominecraft.util.tasks.download.HTTPGetTask;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author huangyuhui
|
||||||
|
*/
|
||||||
|
public class MinecraftForgeVersionList extends InstallerVersionList {
|
||||||
|
|
||||||
|
private static volatile MinecraftForgeVersionList instance;
|
||||||
|
|
||||||
|
public static MinecraftForgeVersionList getInstance() {
|
||||||
|
if (instance == null)
|
||||||
|
instance = new MinecraftForgeVersionList();
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MinecraftForgeVersionRoot root;
|
||||||
|
public Map<String, List<InstallerVersion>> versionMap;
|
||||||
|
public List<InstallerVersion> versions;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Task refresh(String[] needed) {
|
||||||
|
if (root != null)
|
||||||
|
return null;
|
||||||
|
return new TaskInfo(C.i18n("install.forge.get_list")) {
|
||||||
|
HTTPGetTask task = new HTTPGetTask(DownloadType.getSuggestedDownloadType().getProvider().getParsedDownloadURL(C.URL_FORGE_LIST));
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<Task> getDependTasks() {
|
||||||
|
return Arrays.asList(task);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void executeTask() throws Throwable {
|
||||||
|
if (!areDependTasksSucceeded)
|
||||||
|
return;
|
||||||
|
String s = task.getResult();
|
||||||
|
|
||||||
|
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 = DownloadType.getSuggestedDownloadType().getProvider().getParsedDownloadURL(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;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (StrUtils.isBlank(iv.installer) || StrUtils.isBlank(iv.universal))
|
||||||
|
continue;
|
||||||
|
Collections.sort(al, new InstallerVersionNewerComparator());
|
||||||
|
al.add(iv);
|
||||||
|
versions.add(iv);
|
||||||
|
}
|
||||||
|
|
||||||
|
versionMap.put(StrUtils.formatVersion(mcver), al);
|
||||||
|
}
|
||||||
|
|
||||||
|
Collections.sort(versions, new InstallerVersionComparator());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<InstallerVersion> getVersionsImpl(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;
|
||||||
|
Collections.sort(c, InstallerVersionComparator.INSTANCE);
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "Forge - MinecraftForge Offical Site";
|
||||||
|
}
|
||||||
|
}
|
||||||
+17
-2
@@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.jackhuang.hellominecraft.launcher.core.install.forge;
|
package org.jackhuang.hellominecraft.launcher.core.install.forge;
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -25,8 +26,22 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
public class MinecraftForgeVersionRoot {
|
public class MinecraftForgeVersionRoot {
|
||||||
|
|
||||||
public String artifact, webpath, adfly, homepage, name;
|
@SerializedName("artifact")
|
||||||
public Map<String, int[]> branches, mcversion;
|
public String artifact;
|
||||||
|
@SerializedName("webpath")
|
||||||
|
public String webpath;
|
||||||
|
@SerializedName("adfly")
|
||||||
|
public String adfly;
|
||||||
|
@SerializedName("homepage")
|
||||||
|
public String homepage;
|
||||||
|
@SerializedName("name")
|
||||||
|
public String name;
|
||||||
|
@SerializedName("branches")
|
||||||
|
public Map<String, int[]> branches;
|
||||||
|
@SerializedName("mcversion")
|
||||||
|
public Map<String, int[]> mcversion;
|
||||||
|
@SerializedName("promos")
|
||||||
public Map<String, Integer> promos;
|
public Map<String, Integer> promos;
|
||||||
|
@SerializedName("number")
|
||||||
public Map<Integer, MinecraftForgeVersion> number;
|
public Map<Integer, MinecraftForgeVersion> number;
|
||||||
}
|
}
|
||||||
File renamed without changes.
+2
@@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.jackhuang.hellominecraft.launcher.core.install.liteloader;
|
package org.jackhuang.hellominecraft.launcher.core.install.liteloader;
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -25,5 +26,6 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
public class LiteLoaderMCVersions {
|
public class LiteLoaderMCVersions {
|
||||||
|
|
||||||
|
@SerializedName("artefacts")
|
||||||
public Map<String, Map<String, LiteLoaderVersion>> artefacts;
|
public Map<String, Map<String, LiteLoaderVersion>> artefacts;
|
||||||
}
|
}
|
||||||
+12
-1
@@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.jackhuang.hellominecraft.launcher.core.install.liteloader;
|
package org.jackhuang.hellominecraft.launcher.core.install.liteloader;
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
import org.jackhuang.hellominecraft.launcher.core.version.MinecraftLibrary;
|
import org.jackhuang.hellominecraft.launcher.core.version.MinecraftLibrary;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -25,6 +26,16 @@ import org.jackhuang.hellominecraft.launcher.core.version.MinecraftLibrary;
|
|||||||
*/
|
*/
|
||||||
public class LiteLoaderVersion {
|
public class LiteLoaderVersion {
|
||||||
|
|
||||||
public String tweakClass, file, version, md5, timestamp;
|
@SerializedName("tweakClass")
|
||||||
|
public String tweakClass;
|
||||||
|
@SerializedName("file")
|
||||||
|
public String file;
|
||||||
|
@SerializedName("version")
|
||||||
|
public String version;
|
||||||
|
@SerializedName("md5")
|
||||||
|
public String md5;
|
||||||
|
@SerializedName("timestamp")
|
||||||
|
public String timestamp;
|
||||||
|
@SerializedName("libraries")
|
||||||
public MinecraftLibrary[] libraries;
|
public MinecraftLibrary[] libraries;
|
||||||
}
|
}
|
||||||
+46
-29
@@ -19,6 +19,7 @@ package org.jackhuang.hellominecraft.launcher.core.install.liteloader;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -28,8 +29,10 @@ import org.jackhuang.hellominecraft.launcher.core.version.MinecraftLibrary;
|
|||||||
import org.jackhuang.hellominecraft.launcher.core.install.InstallerVersionList;
|
import org.jackhuang.hellominecraft.launcher.core.install.InstallerVersionList;
|
||||||
import org.jackhuang.hellominecraft.launcher.core.install.InstallerVersionList.InstallerVersion;
|
import org.jackhuang.hellominecraft.launcher.core.install.InstallerVersionList.InstallerVersion;
|
||||||
import org.jackhuang.hellominecraft.launcher.core.install.InstallerVersionNewerComparator;
|
import org.jackhuang.hellominecraft.launcher.core.install.InstallerVersionNewerComparator;
|
||||||
import org.jackhuang.hellominecraft.util.NetUtils;
|
|
||||||
import org.jackhuang.hellominecraft.util.StrUtils;
|
import org.jackhuang.hellominecraft.util.StrUtils;
|
||||||
|
import org.jackhuang.hellominecraft.util.tasks.Task;
|
||||||
|
import org.jackhuang.hellominecraft.util.tasks.TaskInfo;
|
||||||
|
import org.jackhuang.hellominecraft.util.tasks.download.HTTPGetTask;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -50,38 +53,52 @@ public class LiteLoaderVersionList extends InstallerVersionList {
|
|||||||
public List<InstallerVersion> versions;
|
public List<InstallerVersion> versions;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void refreshList(String[] needed) throws Exception {
|
public Task refresh(String[] needed) {
|
||||||
String s = NetUtils.get(C.URL_LITELOADER_LIST);
|
|
||||||
if (root != null)
|
if (root != null)
|
||||||
return;
|
return null;
|
||||||
|
return new TaskInfo(C.i18n("install.liteloader.get_list")) {
|
||||||
|
HTTPGetTask task = new HTTPGetTask(C.URL_LITELOADER_LIST);
|
||||||
|
|
||||||
root = C.GSON.fromJson(s, LiteLoaderVersionsRoot.class);
|
@Override
|
||||||
|
public Collection<Task> getDependTasks() {
|
||||||
versionMap = new HashMap<>();
|
return Arrays.asList(task);
|
||||||
versions = new ArrayList<>();
|
|
||||||
|
|
||||||
for (Map.Entry<String, LiteLoaderMCVersions> arr : root.versions.entrySet()) {
|
|
||||||
ArrayList<InstallerVersion> al = new ArrayList<>();
|
|
||||||
LiteLoaderMCVersions mcv = arr.getValue();
|
|
||||||
if (mcv == null || mcv.artefacts == null || mcv.artefacts.get("com.mumfrey:liteloader") == null)
|
|
||||||
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);
|
|
||||||
iv.installer = "http://dl.liteloader.com/redist/" + iv.mcVersion + "/liteloader-installer-" + iv.selfVersion.replace("_", "-") + ".jar";
|
|
||||||
al.add(iv);
|
|
||||||
versions.add(iv);
|
|
||||||
}
|
}
|
||||||
Collections.sort(al, new InstallerVersionNewerComparator());
|
|
||||||
versionMap.put(StrUtils.formatVersion(arr.getKey()), al);
|
|
||||||
}
|
|
||||||
|
|
||||||
Collections.sort(versions, InstallerVersionComparator.INSTANCE);
|
@Override
|
||||||
|
public void executeTask() throws Throwable {
|
||||||
|
if (!areDependTasksSucceeded)
|
||||||
|
return;
|
||||||
|
String s = task.getResult();
|
||||||
|
|
||||||
|
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();
|
||||||
|
if (mcv == null || mcv.artefacts == null || mcv.artefacts.get("com.mumfrey:liteloader") == null)
|
||||||
|
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);
|
||||||
|
iv.installer = "http://dl.liteloader.com/redist/" + iv.mcVersion + "/liteloader-installer-" + iv.selfVersion.replace("_", "-") + ".jar";
|
||||||
|
al.add(iv);
|
||||||
|
versions.add(iv);
|
||||||
|
}
|
||||||
|
Collections.sort(al, new InstallerVersionNewerComparator());
|
||||||
|
versionMap.put(StrUtils.formatVersion(arr.getKey()), al);
|
||||||
|
}
|
||||||
|
|
||||||
|
Collections.sort(versions, InstallerVersionComparator.INSTANCE);
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
+8
-1
@@ -17,13 +17,20 @@
|
|||||||
*/
|
*/
|
||||||
package org.jackhuang.hellominecraft.launcher.core.install.liteloader;
|
package org.jackhuang.hellominecraft.launcher.core.install.liteloader;
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author huangyuhui
|
* @author huangyuhui
|
||||||
*/
|
*/
|
||||||
public class LiteLoaderVersionsMeta {
|
public class LiteLoaderVersionsMeta {
|
||||||
|
|
||||||
private String description, authors, url;
|
@SerializedName("versions")
|
||||||
|
private String description;
|
||||||
|
@SerializedName("authors")
|
||||||
|
private String authors;
|
||||||
|
@SerializedName("url")
|
||||||
|
private String url;
|
||||||
|
|
||||||
public LiteLoaderVersionsMeta() {
|
public LiteLoaderVersionsMeta() {
|
||||||
}
|
}
|
||||||
+3
@@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.jackhuang.hellominecraft.launcher.core.install.liteloader;
|
package org.jackhuang.hellominecraft.launcher.core.install.liteloader;
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -25,6 +26,8 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
public class LiteLoaderVersionsRoot {
|
public class LiteLoaderVersionsRoot {
|
||||||
|
|
||||||
|
@SerializedName("versions")
|
||||||
public Map<String, LiteLoaderMCVersions> versions;
|
public Map<String, LiteLoaderMCVersions> versions;
|
||||||
|
@SerializedName("meta")
|
||||||
public LiteLoaderVersionsMeta meta;
|
public LiteLoaderVersionsMeta meta;
|
||||||
}
|
}
|
||||||
+3
-2
@@ -72,14 +72,15 @@ public class OptiFineInstaller extends Task implements PreviousResultRegistrar<F
|
|||||||
mv.mainClass = "net.minecraft.launchwrapper.Launch";
|
mv.mainClass = "net.minecraft.launchwrapper.Launch";
|
||||||
mv.libraries.add(1, new MinecraftLibrary("net.minecraft:launchwrapper:1.7"));
|
mv.libraries.add(1, new MinecraftLibrary("net.minecraft:launchwrapper:1.7"));
|
||||||
}
|
}
|
||||||
mv.minecraftArguments += " --tweakClass optifine.OptiFineTweaker";
|
if (!mv.minecraftArguments.contains("FMLTweaker"))
|
||||||
|
mv.minecraftArguments += " --tweakClass optifine.OptiFineTweaker";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
File loc = new File(service.baseDirectory(), "versions/" + mv.id);
|
File loc = new File(service.baseDirectory(), "versions/" + mv.id);
|
||||||
if (!loc.exists() && loc.mkdirs())
|
if (!loc.exists() && loc.mkdirs())
|
||||||
HMCLog.warn("Failed to make directories: " + loc);
|
HMCLog.warn("Failed to make directories: " + loc);
|
||||||
File json = new File(loc, mv.id + ".json");
|
File json = new File(loc, mv.id + ".json");
|
||||||
FileUtils.writeStringToFile(json, C.GSON.toJson(mv, MinecraftVersion.class));
|
FileUtils.write(json, C.GSON.toJson(mv, MinecraftVersion.class));
|
||||||
|
|
||||||
service.version().refreshVersions();
|
service.version().refreshVersions();
|
||||||
}
|
}
|
||||||
File renamed without changes.
+41
-25
@@ -20,6 +20,8 @@ package org.jackhuang.hellominecraft.launcher.core.install.optifine.bmcl;
|
|||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -30,8 +32,10 @@ import org.jackhuang.hellominecraft.util.C;
|
|||||||
import org.jackhuang.hellominecraft.util.ArrayUtils;
|
import org.jackhuang.hellominecraft.util.ArrayUtils;
|
||||||
import org.jackhuang.hellominecraft.launcher.core.install.InstallerVersionList;
|
import org.jackhuang.hellominecraft.launcher.core.install.InstallerVersionList;
|
||||||
import org.jackhuang.hellominecraft.launcher.core.install.optifine.OptiFineVersion;
|
import org.jackhuang.hellominecraft.launcher.core.install.optifine.OptiFineVersion;
|
||||||
import org.jackhuang.hellominecraft.util.NetUtils;
|
|
||||||
import org.jackhuang.hellominecraft.util.StrUtils;
|
import org.jackhuang.hellominecraft.util.StrUtils;
|
||||||
|
import org.jackhuang.hellominecraft.util.tasks.Task;
|
||||||
|
import org.jackhuang.hellominecraft.util.tasks.TaskInfo;
|
||||||
|
import org.jackhuang.hellominecraft.util.tasks.download.HTTPGetTask;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -55,34 +59,46 @@ public class OptiFineBMCLVersionList extends InstallerVersionList {
|
|||||||
}.getType();
|
}.getType();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void refreshList(String[] needed) throws Exception {
|
public Task refresh(String[] needed) {
|
||||||
String s = NetUtils.get("http://bmclapi.bangbang93.com/optifine/versionlist");
|
return new TaskInfo(C.i18n("install.optifine.get_list")) {
|
||||||
|
HTTPGetTask task = new HTTPGetTask("http://bmclapi.bangbang93.com/optifine/versionlist");
|
||||||
|
|
||||||
versionMap = new HashMap<>();
|
@Override
|
||||||
versions = new ArrayList<>();
|
public Collection<Task> getDependTasks() {
|
||||||
|
return Arrays.asList(task);
|
||||||
if (s == null)
|
|
||||||
return;
|
|
||||||
root = C.GSON.fromJson(s, TYPE);
|
|
||||||
for (OptiFineVersion v : root) {
|
|
||||||
v.setMirror(v.getMirror().replace("http://optifine.net/http://optifine.net/", "http://optifine.net/"));
|
|
||||||
|
|
||||||
if (StrUtils.isBlank(v.getMCVersion())) {
|
|
||||||
Pattern p = Pattern.compile("OptiFine (.*) HD");
|
|
||||||
Matcher m = p.matcher(v.getVersion());
|
|
||||||
while (m.find())
|
|
||||||
v.setMCVersion(m.group(1));
|
|
||||||
}
|
}
|
||||||
InstallerVersion iv = new InstallerVersion(v.getVersion(), StrUtils.formatVersion(v.getMCVersion()));
|
|
||||||
|
|
||||||
List<InstallerVersion> al = ArrayUtils.tryGetMapWithList(versionMap, StrUtils.formatVersion(v.getMCVersion()));
|
@Override
|
||||||
//String url = "http://bmclapi.bangbang93.com/optifine/" + iv.selfVersion.replace(" ", "%20");
|
public void executeTask() throws Throwable {
|
||||||
iv.installer = iv.universal = v.getMirror();
|
String s = task.getResult();
|
||||||
al.add(iv);
|
|
||||||
versions.add(iv);
|
|
||||||
}
|
|
||||||
|
|
||||||
Collections.sort(versions, InstallerVersionComparator.INSTANCE);
|
versionMap = new HashMap<>();
|
||||||
|
versions = new ArrayList<>();
|
||||||
|
|
||||||
|
if (s == null)
|
||||||
|
return;
|
||||||
|
root = C.GSON.fromJson(s, TYPE);
|
||||||
|
for (OptiFineVersion v : root) {
|
||||||
|
v.setMirror(v.getMirror().replace("http://optifine.net/http://optifine.net/", "http://optifine.net/"));
|
||||||
|
|
||||||
|
if (StrUtils.isBlank(v.getMCVersion())) {
|
||||||
|
Pattern p = Pattern.compile("OptiFine (.*) HD");
|
||||||
|
Matcher m = p.matcher(v.getVersion());
|
||||||
|
while (m.find())
|
||||||
|
v.setMCVersion(m.group(1));
|
||||||
|
}
|
||||||
|
InstallerVersion iv = new InstallerVersion(v.getVersion(), StrUtils.formatVersion(v.getMCVersion()));
|
||||||
|
|
||||||
|
List<InstallerVersion> al = ArrayUtils.tryGetMapWithList(versionMap, StrUtils.formatVersion(v.getMCVersion()));
|
||||||
|
//String url = "http://bmclapi.bangbang93.com/optifine/" + iv.selfVersion.replace(" ", "%20");
|
||||||
|
iv.installer = iv.universal = v.getMirror();
|
||||||
|
al.add(iv);
|
||||||
|
versions.add(iv);
|
||||||
|
}
|
||||||
|
|
||||||
|
Collections.sort(versions, InstallerVersionComparator.INSTANCE);
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
File renamed without changes.
+155
@@ -0,0 +1,155 @@
|
|||||||
|
/*
|
||||||
|
* Hello Minecraft! Launcher.
|
||||||
|
* Copyright (C) 2013 huangyuhui <huanghongxun2008@126.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see {http://www.gnu.org/licenses/}.
|
||||||
|
*/
|
||||||
|
package org.jackhuang.hellominecraft.launcher.core.install.optifine.vanilla;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
import org.jackhuang.hellominecraft.launcher.core.install.InstallerVersionList;
|
||||||
|
import org.jackhuang.hellominecraft.launcher.core.install.optifine.OptiFineVersion;
|
||||||
|
import org.jackhuang.hellominecraft.util.ArrayUtils;
|
||||||
|
import org.jackhuang.hellominecraft.util.C;
|
||||||
|
import org.jackhuang.hellominecraft.util.StrUtils;
|
||||||
|
import org.jackhuang.hellominecraft.util.tasks.Task;
|
||||||
|
import org.jackhuang.hellominecraft.util.tasks.TaskInfo;
|
||||||
|
import org.jackhuang.hellominecraft.util.tasks.download.HTTPGetTask;
|
||||||
|
import org.w3c.dom.DOMException;
|
||||||
|
import org.w3c.dom.Document;
|
||||||
|
import org.w3c.dom.Element;
|
||||||
|
import org.w3c.dom.NodeList;
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<OptiFineVersion> root = new ArrayList();
|
||||||
|
public Map<String, List<InstallerVersion>> versionMap;
|
||||||
|
public List<InstallerVersion> versions;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Task refresh(String[] sss) {
|
||||||
|
if (versions != null)
|
||||||
|
return null;
|
||||||
|
return new TaskInfo(C.i18n("install.optifine.get_list")) {
|
||||||
|
HTTPGetTask task = new HTTPGetTask("http://optifine.net/downloads");
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<Task> getDependTasks() {
|
||||||
|
return Arrays.asList(task);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void executeTask() throws Throwable {
|
||||||
|
if (!areDependTasksSucceeded)
|
||||||
|
return;
|
||||||
|
String content = task.getResult();
|
||||||
|
versionMap = new HashMap<>();
|
||||||
|
versions = new ArrayList<>();
|
||||||
|
|
||||||
|
content = content.replace(" ", " ").replace(">", ">").replace("<", "<").replace("<br>", "<br />");
|
||||||
|
|
||||||
|
try {
|
||||||
|
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||||
|
DocumentBuilder db = factory.newDocumentBuilder();
|
||||||
|
Document doc = db.parse(new ByteArrayInputStream(content.getBytes("UTF-8")));
|
||||||
|
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"))) {
|
||||||
|
NodeList tr = e.getElementsByTagName("tr");
|
||||||
|
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.setMirror(((Element) td.getElementsByTagName("a").item(0)).getAttribute("href"));
|
||||||
|
if (StrUtils.startsWith(td.getAttribute("class"), "downloadLineDownload"))
|
||||||
|
v.setDownloadLink(((Element) td.getElementsByTagName("a").item(0)).getAttribute("href"));
|
||||||
|
if (StrUtils.startsWith(td.getAttribute("class"), "downloadLineDate"))
|
||||||
|
v.setDate(td.getTextContent());
|
||||||
|
if (StrUtils.startsWith(td.getAttribute("class"), "downloadLineFile"))
|
||||||
|
v.setVersion(td.getTextContent());
|
||||||
|
}
|
||||||
|
if (StrUtils.isBlank(v.getMCVersion())) {
|
||||||
|
Pattern p = Pattern.compile("OptiFine (.*?) ");
|
||||||
|
Matcher m = p.matcher(v.getVersion());
|
||||||
|
while (m.find())
|
||||||
|
v.setMCVersion(StrUtils.formatVersion(m.group(1)));
|
||||||
|
}
|
||||||
|
InstallerVersion iv = new InstallerVersion(v.getVersion(), StrUtils.formatVersion(v.getMCVersion()));
|
||||||
|
iv.installer = iv.universal = v.getMirror();
|
||||||
|
root.add(v);
|
||||||
|
versions.add(iv);
|
||||||
|
|
||||||
|
List<InstallerVersion> ivl = ArrayUtils.tryGetMapWithList(versionMap, StrUtils.formatVersion(v.getMCVersion()));
|
||||||
|
ivl.add(iv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (ParserConfigurationException | SAXException | IOException | DOMException ex) {
|
||||||
|
throw new RuntimeException(ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
Collections.sort(versions, InstallerVersionComparator.INSTANCE);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "OptiFine - OptiFine Official Site";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<InstallerVersion> getVersionsImpl(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;
|
||||||
|
Collections.sort(c, InstallerVersionComparator.INSTANCE);
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
-1
@@ -29,7 +29,6 @@ import org.jackhuang.hellominecraft.util.MessageBox;
|
|||||||
import org.jackhuang.hellominecraft.util.system.OS;
|
import org.jackhuang.hellominecraft.util.system.OS;
|
||||||
import org.jackhuang.hellominecraft.util.system.Platform;
|
import org.jackhuang.hellominecraft.util.system.Platform;
|
||||||
import org.jackhuang.hellominecraft.util.StrUtils;
|
import org.jackhuang.hellominecraft.util.StrUtils;
|
||||||
import org.jackhuang.hellominecraft.util.Utils;
|
|
||||||
import org.jackhuang.hellominecraft.launcher.core.GameException;
|
import org.jackhuang.hellominecraft.launcher.core.GameException;
|
||||||
import org.jackhuang.hellominecraft.launcher.core.auth.UserProfileProvider;
|
import org.jackhuang.hellominecraft.launcher.core.auth.UserProfileProvider;
|
||||||
import org.jackhuang.hellominecraft.launcher.core.version.MinecraftVersion;
|
import org.jackhuang.hellominecraft.launcher.core.version.MinecraftVersion;
|
||||||
File renamed without changes.
+12
-7
@@ -96,10 +96,12 @@ public class GameLauncher {
|
|||||||
if (file != null)
|
if (file != null)
|
||||||
FileUtils.cleanDirectoryQuietly(file);
|
FileUtils.cleanDirectoryQuietly(file);
|
||||||
|
|
||||||
HMCLog.log("Detecting libraries...");
|
if (!options.isNotCheckGame()) {
|
||||||
launchingStateChangedEvent.execute(LaunchingState.DownloadingLibraries);
|
HMCLog.log("Detecting libraries...");
|
||||||
if (!downloadLibrariesEvent.execute(service.download().getDownloadLibraries(loader.getMinecraftVersion())))
|
launchingStateChangedEvent.execute(LaunchingState.DownloadingLibraries);
|
||||||
throw new GameException("Failed to download libraries");
|
if (!downloadLibrariesEvent.execute(service.download().getDownloadLibraries(loader.getMinecraftVersion())))
|
||||||
|
throw new GameException("Failed to download libraries");
|
||||||
|
}
|
||||||
|
|
||||||
HMCLog.log("Unpacking natives...");
|
HMCLog.log("Unpacking natives...");
|
||||||
launchingStateChangedEvent.execute(LaunchingState.DecompressingNatives);
|
launchingStateChangedEvent.execute(LaunchingState.DecompressingNatives);
|
||||||
@@ -118,8 +120,8 @@ public class GameLauncher {
|
|||||||
*
|
*
|
||||||
* @throws IOException failed creating process
|
* @throws IOException failed creating process
|
||||||
*/
|
*/
|
||||||
public void launch(List str) throws IOException {
|
public void launch(List<String> str) throws IOException {
|
||||||
if (!service.version().onLaunch())
|
if (!service.version().onLaunch(options.getLaunchVersion()))
|
||||||
return;
|
return;
|
||||||
if (StrUtils.isNotBlank(options.getPrecalledCommand())) {
|
if (StrUtils.isNotBlank(options.getPrecalledCommand())) {
|
||||||
Process p = Runtime.getRuntime().exec(options.getPrecalledCommand());
|
Process p = Runtime.getRuntime().exec(options.getPrecalledCommand());
|
||||||
@@ -131,6 +133,7 @@ public class GameLauncher {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
HMCLog.log("Starting process");
|
HMCLog.log("Starting process");
|
||||||
|
HMCLog.log(str.toString());
|
||||||
ProcessBuilder builder = new ProcessBuilder(str);
|
ProcessBuilder builder = new ProcessBuilder(str);
|
||||||
if (options.getLaunchVersion() == null || service.baseDirectory() == null)
|
if (options.getLaunchVersion() == null || service.baseDirectory() == null)
|
||||||
throw new Error("Fucking bug!");
|
throw new Error("Fucking bug!");
|
||||||
@@ -153,7 +156,7 @@ public class GameLauncher {
|
|||||||
*/
|
*/
|
||||||
public File makeLauncher(String launcherName, List str) throws IOException {
|
public File makeLauncher(String launcherName, List str) throws IOException {
|
||||||
HMCLog.log("Making shell launcher...");
|
HMCLog.log("Making shell launcher...");
|
||||||
service.version().onLaunch();
|
service.version().onLaunch(options.getLaunchVersion());
|
||||||
boolean isWin = OS.os() == OS.WINDOWS;
|
boolean isWin = OS.os() == OS.WINDOWS;
|
||||||
File f = new File(launcherName + (isWin ? ".bat" : ".sh"));
|
File f = new File(launcherName + (isWin ? ".bat" : ".sh"));
|
||||||
if (!f.exists() && !f.createNewFile())
|
if (!f.exists() && !f.createNewFile())
|
||||||
@@ -172,6 +175,8 @@ public class GameLauncher {
|
|||||||
if (appdata != null) {
|
if (appdata != null) {
|
||||||
writer.write("set appdata=" + appdata);
|
writer.write("set appdata=" + appdata);
|
||||||
writer.newLine();
|
writer.newLine();
|
||||||
|
writer.write("cd %appdata%");
|
||||||
|
writer.newLine();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (StrUtils.isNotBlank(options.getPrecalledCommand())) {
|
if (StrUtils.isNotBlank(options.getPrecalledCommand())) {
|
||||||
+9
-1
@@ -30,7 +30,7 @@ public class LaunchOptions {
|
|||||||
|
|
||||||
private String name, versionName, javaArgs, minecraftArgs, maxMemory, permSize, width, height, serverIp, wrapper;
|
private String name, versionName, javaArgs, minecraftArgs, maxMemory, permSize, width, height, serverIp, wrapper;
|
||||||
private String proxyHost, proxyPort, proxyUser, proxyPass, javaDir, launchVersion, type, precalledCommand;
|
private String proxyHost, proxyPort, proxyUser, proxyPass, javaDir, launchVersion, type, precalledCommand;
|
||||||
private boolean fullscreen, noJVMArgs;
|
private boolean fullscreen, noJVMArgs, notCheckGame;
|
||||||
private JdkVersion java;
|
private JdkVersion java;
|
||||||
private File gameDir;
|
private File gameDir;
|
||||||
private GameDirType gameDirType;
|
private GameDirType gameDirType;
|
||||||
@@ -222,4 +222,12 @@ public class LaunchOptions {
|
|||||||
public void setType(String type) {
|
public void setType(String type) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isNotCheckGame() {
|
||||||
|
return notCheckGame;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNotCheckGame(boolean notCheckGame) {
|
||||||
|
this.notCheckGame = notCheckGame;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
File renamed without changes.
File renamed without changes.
+5
-5
@@ -21,7 +21,6 @@ import java.io.File;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.jackhuang.hellominecraft.util.StrUtils;
|
import org.jackhuang.hellominecraft.util.StrUtils;
|
||||||
import org.jackhuang.hellominecraft.util.func.Function;
|
|
||||||
import org.jackhuang.hellominecraft.util.logging.HMCLog;
|
import org.jackhuang.hellominecraft.util.logging.HMCLog;
|
||||||
import org.jackhuang.hellominecraft.util.system.IOUtils;
|
import org.jackhuang.hellominecraft.util.system.IOUtils;
|
||||||
import org.jackhuang.hellominecraft.util.system.OS;
|
import org.jackhuang.hellominecraft.util.system.OS;
|
||||||
@@ -30,6 +29,7 @@ import org.jackhuang.hellominecraft.launcher.core.auth.UserProfileProvider;
|
|||||||
import org.jackhuang.hellominecraft.launcher.core.version.MinecraftLibrary;
|
import org.jackhuang.hellominecraft.launcher.core.version.MinecraftLibrary;
|
||||||
import org.jackhuang.hellominecraft.launcher.core.version.MinecraftVersion;
|
import org.jackhuang.hellominecraft.launcher.core.version.MinecraftVersion;
|
||||||
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftService;
|
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftService;
|
||||||
|
import org.jackhuang.hellominecraft.util.func.BiFunction;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -57,7 +57,7 @@ public class MinecraftLoader extends AbstractMinecraftLoader {
|
|||||||
|
|
||||||
String[] splitted = StrUtils.tokenize(version.minecraftArguments);
|
String[] splitted = StrUtils.tokenize(version.minecraftArguments);
|
||||||
|
|
||||||
String game_assets = assetProvider.apply(version);
|
String game_assets = assetProvider.apply(version, !options.isNotCheckGame());
|
||||||
|
|
||||||
for (String t : splitted) {
|
for (String t : splitted) {
|
||||||
t = t.replace("${auth_player_name}", lr.getUserName());
|
t = t.replace("${auth_player_name}", lr.getUserName());
|
||||||
@@ -96,13 +96,13 @@ public class MinecraftLoader extends AbstractMinecraftLoader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Function<MinecraftVersion, String> DEFAULT_ASSET_PROVIDER = t -> {
|
private final BiFunction<MinecraftVersion, Boolean, String> DEFAULT_ASSET_PROVIDER = (t, allow) -> {
|
||||||
return new File(service.baseDirectory(), "assets").getAbsolutePath();
|
return new File(service.baseDirectory(), "assets").getAbsolutePath();
|
||||||
};
|
};
|
||||||
|
|
||||||
private Function<MinecraftVersion, String> assetProvider = DEFAULT_ASSET_PROVIDER;
|
private BiFunction<MinecraftVersion, Boolean, String> assetProvider = DEFAULT_ASSET_PROVIDER;
|
||||||
|
|
||||||
public void setAssetProvider(Function<MinecraftVersion, String> assetProvider) {
|
public void setAssetProvider(BiFunction<MinecraftVersion, Boolean, String> assetProvider) {
|
||||||
if (assetProvider == null)
|
if (assetProvider == null)
|
||||||
this.assetProvider = DEFAULT_ASSET_PROVIDER;
|
this.assetProvider = DEFAULT_ASSET_PROVIDER;
|
||||||
else
|
else
|
||||||
File renamed without changes.
+21
-1
@@ -18,6 +18,7 @@
|
|||||||
package org.jackhuang.hellominecraft.launcher.core.mod;
|
package org.jackhuang.hellominecraft.launcher.core.mod;
|
||||||
|
|
||||||
import com.google.gson.JsonSyntaxException;
|
import com.google.gson.JsonSyntaxException;
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -37,8 +38,27 @@ import org.jackhuang.hellominecraft.util.system.FileUtils;
|
|||||||
*/
|
*/
|
||||||
public class ModInfo implements Comparable<ModInfo> {
|
public class ModInfo implements Comparable<ModInfo> {
|
||||||
|
|
||||||
|
@SerializedName("location")
|
||||||
public File location;
|
public File location;
|
||||||
public String modid, name, description, author, version, mcversion, url, updateUrl, credits;
|
@SerializedName("modid")
|
||||||
|
public String modid;
|
||||||
|
@SerializedName("name")
|
||||||
|
public String name;
|
||||||
|
@SerializedName("description")
|
||||||
|
public String description;
|
||||||
|
@SerializedName("author")
|
||||||
|
public String author;
|
||||||
|
@SerializedName("version")
|
||||||
|
public String version;
|
||||||
|
@SerializedName("mcversion")
|
||||||
|
public String mcversion;
|
||||||
|
@SerializedName("url")
|
||||||
|
public String url;
|
||||||
|
@SerializedName("updateUrl")
|
||||||
|
public String updateUrl;
|
||||||
|
@SerializedName("credits")
|
||||||
|
public String credits;
|
||||||
|
@SerializedName("authorList")
|
||||||
public String[] authorList;
|
public String[] authorList;
|
||||||
|
|
||||||
public boolean isActive() {
|
public boolean isActive() {
|
||||||
+2
-2
@@ -164,13 +164,13 @@ public final class ModpackManager {
|
|||||||
HMCLog.warn("Failed to rename incorrect json " + oldFile + " to " + nowFile);
|
HMCLog.warn("Failed to rename incorrect json " + oldFile + " to " + nowFile);
|
||||||
|
|
||||||
File json = new File(nowFile, "pack.json");
|
File json = new File(nowFile, "pack.json");
|
||||||
MinecraftVersion mv = C.GSON.fromJson(FileUtils.readFileToString(json), MinecraftVersion.class);
|
MinecraftVersion mv = C.GSON.fromJson(FileUtils.read(json), MinecraftVersion.class);
|
||||||
if (mv.jar == null)
|
if (mv.jar == null)
|
||||||
throw new FileNotFoundException(C.i18n("modpack.incorrect_format.no_jar"));
|
throw new FileNotFoundException(C.i18n("modpack.incorrect_format.no_jar"));
|
||||||
|
|
||||||
c.add(service.download().downloadMinecraftJar(mv, new File(nowFile, id + ".jar")));
|
c.add(service.download().downloadMinecraftJar(mv, new File(nowFile, id + ".jar")));
|
||||||
mv.jar = null;
|
mv.jar = null;
|
||||||
FileUtils.writeStringToFile(json, C.GSON.toJson(mv));
|
FileUtils.write(json, C.GSON.toJson(mv));
|
||||||
if (!json.renameTo(new File(nowFile, id + ".json")))
|
if (!json.renameTo(new File(nowFile, id + ".json")))
|
||||||
HMCLog.warn("Failed to rename pack.json to new id");
|
HMCLog.warn("Failed to rename pack.json to new id");
|
||||||
|
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+1
-8
@@ -72,13 +72,6 @@ public abstract class IMinecraftProvider {
|
|||||||
*/
|
*/
|
||||||
public abstract boolean install(String version, Consumer<MinecraftVersion> callback);
|
public abstract boolean install(String version, Consumer<MinecraftVersion> callback);
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the thing like ".minecraft/resourcepacks".
|
|
||||||
*
|
|
||||||
* @return the thing
|
|
||||||
*/
|
|
||||||
public abstract File getResourcePacks();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param v should be resolved
|
* @param v should be resolved
|
||||||
@@ -164,7 +157,7 @@ public abstract class IMinecraftProvider {
|
|||||||
*
|
*
|
||||||
* @return if false, will break the launch process.
|
* @return if false, will break the launch process.
|
||||||
*/
|
*/
|
||||||
public abstract boolean onLaunch();
|
public abstract boolean onLaunch(String id);
|
||||||
|
|
||||||
public File baseDirectory() {
|
public File baseDirectory() {
|
||||||
return service.baseDirectory();
|
return service.baseDirectory();
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
+2
@@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.jackhuang.hellominecraft.launcher.core.version;
|
package org.jackhuang.hellominecraft.launcher.core.version;
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.jackhuang.hellominecraft.util.StrUtils;
|
import org.jackhuang.hellominecraft.util.StrUtils;
|
||||||
@@ -27,6 +28,7 @@ import org.jackhuang.hellominecraft.util.StrUtils;
|
|||||||
*/
|
*/
|
||||||
public class Extract implements Cloneable {
|
public class Extract implements Cloneable {
|
||||||
|
|
||||||
|
@SerializedName("exclude")
|
||||||
public List<String> exclude = new ArrayList<>();
|
public List<String> exclude = new ArrayList<>();
|
||||||
|
|
||||||
public boolean allow(String path) {
|
public boolean allow(String path) {
|
||||||
File renamed without changes.
+4
@@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.jackhuang.hellominecraft.launcher.core.version;
|
package org.jackhuang.hellominecraft.launcher.core.version;
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
import org.jackhuang.hellominecraft.launcher.core.download.DownloadType;
|
import org.jackhuang.hellominecraft.launcher.core.download.DownloadType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -25,8 +26,11 @@ import org.jackhuang.hellominecraft.launcher.core.download.DownloadType;
|
|||||||
*/
|
*/
|
||||||
public class GameDownloadInfo implements Cloneable {
|
public class GameDownloadInfo implements Cloneable {
|
||||||
|
|
||||||
|
@SerializedName("sha1")
|
||||||
public String sha1;
|
public String sha1;
|
||||||
|
@SerializedName("size")
|
||||||
public int size;
|
public int size;
|
||||||
|
@SerializedName("url")
|
||||||
protected String url;
|
protected String url;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
File renamed without changes.
+3
@@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.jackhuang.hellominecraft.launcher.core.version;
|
package org.jackhuang.hellominecraft.launcher.core.version;
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -25,6 +26,8 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
public class LibrariesDownloadInfo {
|
public class LibrariesDownloadInfo {
|
||||||
|
|
||||||
|
@SerializedName("classifiers")
|
||||||
Map<String, LibraryDownloadInfo> classifiers;
|
Map<String, LibraryDownloadInfo> classifiers;
|
||||||
|
@SerializedName("artifact")
|
||||||
LibraryDownloadInfo artifact;
|
LibraryDownloadInfo artifact;
|
||||||
}
|
}
|
||||||
+6
-2
@@ -17,8 +17,10 @@
|
|||||||
*/
|
*/
|
||||||
package org.jackhuang.hellominecraft.launcher.core.version;
|
package org.jackhuang.hellominecraft.launcher.core.version;
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
import org.jackhuang.hellominecraft.launcher.core.download.DownloadType;
|
import org.jackhuang.hellominecraft.launcher.core.download.DownloadType;
|
||||||
import org.jackhuang.hellominecraft.util.StrUtils;
|
import org.jackhuang.hellominecraft.util.StrUtils;
|
||||||
|
import org.jackhuang.hellominecraft.util.system.IOUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -26,19 +28,21 @@ import org.jackhuang.hellominecraft.util.StrUtils;
|
|||||||
*/
|
*/
|
||||||
public class LibraryDownloadInfo extends GameDownloadInfo {
|
public class LibraryDownloadInfo extends GameDownloadInfo {
|
||||||
|
|
||||||
|
@SerializedName("path")
|
||||||
public String path;
|
public String path;
|
||||||
|
@SerializedName("forgeURL")
|
||||||
public String forgeURL;
|
public String forgeURL;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUrl(DownloadType dt, boolean allowSelf) {
|
public String getUrl(DownloadType dt, boolean allowSelf) {
|
||||||
String myURL = (forgeURL == null ? dt.getProvider().getLibraryDownloadURL() : forgeURL) + "/";
|
String myURL = (forgeURL == null ? dt.getProvider().getLibraryDownloadURL() : forgeURL);
|
||||||
if (StrUtils.isNotBlank(url) && allowSelf)
|
if (StrUtils.isNotBlank(url) && allowSelf)
|
||||||
myURL = url;
|
myURL = url;
|
||||||
if (!myURL.endsWith(".jar"))
|
if (!myURL.endsWith(".jar"))
|
||||||
if (path == null)
|
if (path == null)
|
||||||
return null;
|
return null;
|
||||||
else
|
else
|
||||||
myURL += path.replace('\\', '/');
|
myURL = IOUtils.addURLSeparator(myURL) + path.replace('\\', '/');
|
||||||
return myURL;
|
return myURL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
File renamed without changes.
+6
@@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.jackhuang.hellominecraft.launcher.core.version;
|
package org.jackhuang.hellominecraft.launcher.core.version;
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -30,10 +31,15 @@ import org.jackhuang.hellominecraft.util.StrUtils;
|
|||||||
*/
|
*/
|
||||||
public class MinecraftLibrary extends IMinecraftLibrary {
|
public class MinecraftLibrary extends IMinecraftLibrary {
|
||||||
|
|
||||||
|
@SerializedName("rules")
|
||||||
public ArrayList<Rules> rules;
|
public ArrayList<Rules> rules;
|
||||||
|
@SerializedName("url")
|
||||||
public String url;
|
public String url;
|
||||||
|
@SerializedName("natives")
|
||||||
public Natives natives;
|
public Natives natives;
|
||||||
|
@SerializedName("extract")
|
||||||
public Extract extract;
|
public Extract extract;
|
||||||
|
@SerializedName("downloads")
|
||||||
public LibrariesDownloadInfo downloads;
|
public LibrariesDownloadInfo downloads;
|
||||||
|
|
||||||
public MinecraftLibrary(String name) {
|
public MinecraftLibrary(String name) {
|
||||||
File renamed without changes.
+28
-4
@@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.jackhuang.hellominecraft.launcher.core.version;
|
package org.jackhuang.hellominecraft.launcher.core.version;
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -37,14 +38,37 @@ import org.jackhuang.hellominecraft.util.Utils;
|
|||||||
*/
|
*/
|
||||||
public class MinecraftVersion implements Cloneable, Comparable<MinecraftVersion> {
|
public class MinecraftVersion implements Cloneable, Comparable<MinecraftVersion> {
|
||||||
|
|
||||||
public String minecraftArguments, mainClass, time, id, type, processArguments,
|
@SerializedName("minecraftArguments")
|
||||||
releaseTime, jar, inheritsFrom, runDir;
|
public String minecraftArguments;
|
||||||
|
@SerializedName("mainClass")
|
||||||
|
public String mainClass;
|
||||||
|
@SerializedName("time")
|
||||||
|
public String time;
|
||||||
|
@SerializedName("id")
|
||||||
|
public String id;
|
||||||
|
@SerializedName("type")
|
||||||
|
public String type;
|
||||||
|
@SerializedName("processArguments")
|
||||||
|
public String processArguments;
|
||||||
|
@SerializedName("releaseTime")
|
||||||
|
public String releaseTime;
|
||||||
|
@SerializedName("jar")
|
||||||
|
public String jar;
|
||||||
|
@SerializedName("inheritsFrom")
|
||||||
|
public String inheritsFrom;
|
||||||
|
@SerializedName("runDir")
|
||||||
|
public String runDir;
|
||||||
|
@SerializedName("assets")
|
||||||
protected String assets;
|
protected String assets;
|
||||||
|
@SerializedName("minimumLauncherVersion")
|
||||||
public int minimumLauncherVersion;
|
public int minimumLauncherVersion;
|
||||||
|
@SerializedName("hidden")
|
||||||
public boolean hidden;
|
public boolean hidden;
|
||||||
|
@SerializedName("assetIndex")
|
||||||
public AssetIndexDownloadInfo assetIndex;
|
public AssetIndexDownloadInfo assetIndex;
|
||||||
|
@SerializedName("downloads")
|
||||||
private Map<String, GameDownloadInfo> downloads;
|
private Map<String, GameDownloadInfo> downloads;
|
||||||
|
@SerializedName("libraries")
|
||||||
public ArrayList<MinecraftLibrary> libraries;
|
public ArrayList<MinecraftLibrary> libraries;
|
||||||
|
|
||||||
public MinecraftVersion() {
|
public MinecraftVersion() {
|
||||||
@@ -121,7 +145,7 @@ public class MinecraftVersion implements Cloneable, Comparable<MinecraftVersion>
|
|||||||
this.assets != null ? this.assets : parent.assets,
|
this.assets != null ? this.assets : parent.assets,
|
||||||
this.jar != null ? this.jar : parent.jar,
|
this.jar != null ? this.jar : parent.jar,
|
||||||
null, this.runDir, parent.minimumLauncherVersion,
|
null, this.runDir, parent.minimumLauncherVersion,
|
||||||
this.libraries != null ? ArrayUtils.merge(this.libraries, parent.libraries) : parent.libraries, this.hidden,
|
this.libraries != null ? ArrayUtils.merge(parent.libraries, this.libraries) : parent.libraries, this.hidden,
|
||||||
this.downloads != null ? this.downloads : parent.downloads,
|
this.downloads != null ? this.downloads : parent.downloads,
|
||||||
this.assetIndex != null ? this.assetIndex : parent.assetIndex);
|
this.assetIndex != null ? this.assetIndex : parent.assetIndex);
|
||||||
|
|
||||||
+6
-11
@@ -111,7 +111,7 @@ public class MinecraftVersionManager extends IMinecraftProvider {
|
|||||||
}
|
}
|
||||||
MinecraftVersion mcVersion;
|
MinecraftVersion mcVersion;
|
||||||
try {
|
try {
|
||||||
mcVersion = C.GSON.fromJson(FileUtils.readFileToString(jsonFile), MinecraftVersion.class);
|
mcVersion = C.GSON.fromJson(FileUtils.read(jsonFile), MinecraftVersion.class);
|
||||||
if (mcVersion == null)
|
if (mcVersion == null)
|
||||||
throw new GameException("Wrong json format, got null.");
|
throw new GameException("Wrong json format, got null.");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -119,7 +119,7 @@ public class MinecraftVersionManager extends IMinecraftProvider {
|
|||||||
if (MessageBox.Show(C.i18n("launcher.versions_json_not_formatted", id), MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION) {
|
if (MessageBox.Show(C.i18n("launcher.versions_json_not_formatted", id), MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION) {
|
||||||
service.download().downloadMinecraftVersionJson(id);
|
service.download().downloadMinecraftVersionJson(id);
|
||||||
try {
|
try {
|
||||||
mcVersion = C.GSON.fromJson(FileUtils.readFileToString(jsonFile), MinecraftVersion.class);
|
mcVersion = C.GSON.fromJson(FileUtils.read(jsonFile), MinecraftVersion.class);
|
||||||
if (mcVersion == null)
|
if (mcVersion == null)
|
||||||
throw new GameException("Wrong json format, got null.");
|
throw new GameException("Wrong json format, got null.");
|
||||||
} catch (IOException | GameException | JsonSyntaxException ex) {
|
} catch (IOException | GameException | JsonSyntaxException ex) {
|
||||||
@@ -164,7 +164,7 @@ public class MinecraftVersionManager extends IMinecraftProvider {
|
|||||||
public boolean renameVersion(String from, String to) {
|
public boolean renameVersion(String from, String to) {
|
||||||
try {
|
try {
|
||||||
File fromJson = new File(versionRoot(from), from + ".json");
|
File fromJson = new File(versionRoot(from), from + ".json");
|
||||||
MinecraftVersion mcVersion = C.GSON.fromJson(FileUtils.readFileToString(fromJson), MinecraftVersion.class);
|
MinecraftVersion mcVersion = C.GSON.fromJson(FileUtils.read(fromJson), MinecraftVersion.class);
|
||||||
mcVersion.id = to;
|
mcVersion.id = to;
|
||||||
FileUtils.writeQuietly(fromJson, C.GSON.toJson(mcVersion));
|
FileUtils.writeQuietly(fromJson, C.GSON.toJson(mcVersion));
|
||||||
File toDir = versionRoot(to);
|
File toDir = versionRoot(to);
|
||||||
@@ -198,7 +198,7 @@ public class MinecraftVersionManager extends IMinecraftProvider {
|
|||||||
return false;
|
return false;
|
||||||
if (callback != null) {
|
if (callback != null) {
|
||||||
File mvt = new File(versionRoot(id), id + ".json");
|
File mvt = new File(versionRoot(id), id + ".json");
|
||||||
MinecraftVersion v = C.GSON.fromJson(FileUtils.readFileToStringQuietly(mvt), MinecraftVersion.class);
|
MinecraftVersion v = C.GSON.fromJson(FileUtils.readQuietly(mvt), MinecraftVersion.class);
|
||||||
if (v == null)
|
if (v == null)
|
||||||
return false;
|
return false;
|
||||||
callback.accept(v);
|
callback.accept(v);
|
||||||
@@ -254,13 +254,8 @@ public class MinecraftVersionManager extends IMinecraftProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public File getResourcePacks() {
|
public boolean onLaunch(String id) {
|
||||||
return new File(service.baseDirectory(), "resourcepacks");
|
File resourcePacks = new File(getRunDirectory(id), "resourcepacks");
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onLaunch() {
|
|
||||||
File resourcePacks = getResourcePacks();
|
|
||||||
if (!resourcePacks.exists() && !resourcePacks.mkdirs())
|
if (!resourcePacks.exists() && !resourcePacks.mkdirs())
|
||||||
HMCLog.warn("Failed to make resourcePacks: " + resourcePacks);
|
HMCLog.warn("Failed to make resourcePacks: " + resourcePacks);
|
||||||
return true;
|
return true;
|
||||||
+8
-1
@@ -17,13 +17,20 @@
|
|||||||
*/
|
*/
|
||||||
package org.jackhuang.hellominecraft.launcher.core.version;
|
package org.jackhuang.hellominecraft.launcher.core.version;
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author huangyuhui
|
* @author huangyuhui
|
||||||
*/
|
*/
|
||||||
public class Natives implements Cloneable {
|
public class Natives implements Cloneable {
|
||||||
|
|
||||||
public String windows, osx, linux;
|
@SerializedName("windows")
|
||||||
|
public String windows;
|
||||||
|
@SerializedName("osx")
|
||||||
|
public String osx;
|
||||||
|
@SerializedName("linux")
|
||||||
|
public String linux;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("CloneDeclaresCloneNotSupported")
|
@SuppressWarnings("CloneDeclaresCloneNotSupported")
|
||||||
+5
-1
@@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.jackhuang.hellominecraft.launcher.core.version;
|
package org.jackhuang.hellominecraft.launcher.core.version;
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
import org.jackhuang.hellominecraft.util.StrUtils;
|
import org.jackhuang.hellominecraft.util.StrUtils;
|
||||||
import org.jackhuang.hellominecraft.util.system.OS;
|
import org.jackhuang.hellominecraft.util.system.OS;
|
||||||
|
|
||||||
@@ -26,7 +27,10 @@ import org.jackhuang.hellominecraft.util.system.OS;
|
|||||||
*/
|
*/
|
||||||
public class OSRestriction {
|
public class OSRestriction {
|
||||||
|
|
||||||
private String version, name;
|
@SerializedName("version")
|
||||||
|
private String version;
|
||||||
|
@SerializedName("name")
|
||||||
|
public String name;
|
||||||
|
|
||||||
public String getVersion() {
|
public String getVersion() {
|
||||||
return version;
|
return version;
|
||||||
+4
@@ -17,13 +17,17 @@
|
|||||||
*/
|
*/
|
||||||
package org.jackhuang.hellominecraft.launcher.core.version;
|
package org.jackhuang.hellominecraft.launcher.core.version;
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author huangyuhui
|
* @author huangyuhui
|
||||||
*/
|
*/
|
||||||
public class Rules {
|
public class Rules {
|
||||||
|
|
||||||
|
@SerializedName("action")
|
||||||
private String action;
|
private String action;
|
||||||
|
@SerializedName("os")
|
||||||
private OSRestriction os;
|
private OSRestriction os;
|
||||||
|
|
||||||
public Rules() {
|
public Rules() {
|
||||||
Binary file not shown.
Loaded 100 of 326 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user