localization

This commit is contained in:
huangyuhui
2018-01-20 11:18:59 +08:00
parent b90d6b7b8c
commit 6db41431ed
194 changed files with 696 additions and 2188 deletions

View File

@@ -17,13 +17,14 @@
*/
package org.jackhuang.hmcl.auth;
import java.net.Proxy;
import java.util.Map;
import java.util.Objects;
import org.jackhuang.hmcl.util.Lang;
import org.jackhuang.hmcl.util.Pair;
import org.jackhuang.hmcl.util.StringUtils;
import java.net.Proxy;
import java.util.Map;
import java.util.Objects;
/**
*
* @author huang

View File

@@ -17,9 +17,10 @@
*/
package org.jackhuang.hmcl.auth;
import java.util.Map;
import org.jackhuang.hmcl.util.DigestUtils;
import java.util.Map;
/**
*
* @author huangyuhui

View File

@@ -5,10 +5,11 @@
*/
package org.jackhuang.hmcl.auth.yggdrasil;
import java.util.Map;
import org.jackhuang.hmcl.util.Lang;
import org.jackhuang.hmcl.util.Pair;
import java.util.Map;
/**
*
* @author huangyuhui

View File

@@ -17,13 +17,7 @@
*/
package org.jackhuang.hmcl.auth.yggdrasil;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import com.google.gson.*;
import org.jackhuang.hmcl.util.Immutable;
import java.lang.reflect.Type;

View File

@@ -17,23 +17,12 @@
*/
package org.jackhuang.hmcl.auth.yggdrasil;
import com.google.gson.JsonArray;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import com.google.gson.*;
import org.jackhuang.hmcl.util.Lang;
import java.lang.reflect.Type;
import java.util.*;
public final class PropertyMap extends HashMap<String, Property> {
public List<Map<String, String>> toList() {

View File

@@ -20,16 +20,19 @@ package org.jackhuang.hmcl.auth.yggdrasil;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonParseException;
import java.io.IOException;
import java.net.Proxy;
import java.net.URL;
import java.util.*;
import org.jackhuang.hmcl.auth.*;
import org.jackhuang.hmcl.util.NetworkUtils;
import org.jackhuang.hmcl.util.StringUtils;
import org.jackhuang.hmcl.util.UUIDTypeAdapter;
import java.io.IOException;
import java.net.Proxy;
import java.net.URL;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
/**
*
* @author huang

View File

@@ -17,13 +17,15 @@
*/
package org.jackhuang.hmcl.auth.yggdrasil;
import org.jackhuang.hmcl.auth.AccountFactory;
import org.jackhuang.hmcl.util.Lang;
import org.jackhuang.hmcl.util.UUIDTypeAdapter;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import org.jackhuang.hmcl.auth.AccountFactory;
import org.jackhuang.hmcl.util.Lang;
import static org.jackhuang.hmcl.auth.yggdrasil.YggdrasilAccount.*;
import org.jackhuang.hmcl.util.UUIDTypeAdapter;
/**
*

View File

@@ -17,7 +17,6 @@
*/
package org.jackhuang.hmcl.download;
import java.net.Proxy;
import org.jackhuang.hmcl.download.forge.ForgeInstallTask;
import org.jackhuang.hmcl.download.game.GameAssetDownloadTask;
import org.jackhuang.hmcl.download.game.GameLibrariesTask;
@@ -30,6 +29,8 @@ import org.jackhuang.hmcl.game.Version;
import org.jackhuang.hmcl.task.ParallelTask;
import org.jackhuang.hmcl.task.Task;
import java.net.Proxy;
/**
* Note: This class has no state.
*

View File

@@ -17,19 +17,15 @@
*/
package org.jackhuang.hmcl.download;
import java.util.function.Function;
import org.jackhuang.hmcl.download.game.GameAssetDownloadTask;
import org.jackhuang.hmcl.download.game.GameDownloadTask;
import org.jackhuang.hmcl.download.game.GameLibrariesTask;
import org.jackhuang.hmcl.download.game.GameLoggingDownloadTask;
import org.jackhuang.hmcl.download.game.VersionJsonDownloadTask;
import org.jackhuang.hmcl.download.game.VersionJsonSaveTask;
import org.jackhuang.hmcl.download.game.*;
import org.jackhuang.hmcl.game.Version;
import org.jackhuang.hmcl.task.ParallelTask;
import org.jackhuang.hmcl.task.Task;
import org.jackhuang.hmcl.util.AutoTypingMap;
import org.jackhuang.hmcl.util.Constants;
import java.util.function.Function;
/**
*
* @author huangyuhui

View File

@@ -17,11 +17,12 @@
*/
package org.jackhuang.hmcl.download;
import java.net.Proxy;
import org.jackhuang.hmcl.game.GameRepository;
import org.jackhuang.hmcl.game.Version;
import org.jackhuang.hmcl.task.Task;
import java.net.Proxy;
/**
* Do everything that will connect to Internet.
* Downloading Minecraft files.

View File

@@ -17,10 +17,11 @@
*/
package org.jackhuang.hmcl.download;
import org.jackhuang.hmcl.task.Task;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import org.jackhuang.hmcl.task.Task;
/**
* The builder which provide a task to build Minecraft environment.

View File

@@ -17,9 +17,10 @@
*/
package org.jackhuang.hmcl.download;
import org.jackhuang.hmcl.util.VersionNumber;
import java.util.Comparator;
import java.util.Objects;
import org.jackhuang.hmcl.util.VersionNumber;
/**
* The remote version.

View File

@@ -17,14 +17,11 @@
*/
package org.jackhuang.hmcl.download;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Optional;
import java.util.TreeSet;
import org.jackhuang.hmcl.task.Task;
import org.jackhuang.hmcl.util.SimpleMultimap;
import java.util.*;
/**
* The remote version list.
*

View File

@@ -17,17 +17,6 @@
*/
package org.jackhuang.hmcl.download.forge;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import org.jackhuang.hmcl.download.DefaultDependencyManager;
import org.jackhuang.hmcl.download.RemoteVersion;
import org.jackhuang.hmcl.download.VersionList;
@@ -43,6 +32,14 @@ import org.jackhuang.hmcl.util.FileUtils;
import org.jackhuang.hmcl.util.IOUtils;
import org.jackhuang.hmcl.util.NetworkUtils;
import java.io.*;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
/**
*
* @author huangyuhui

View File

@@ -17,10 +17,6 @@
*/
package org.jackhuang.hmcl.download.forge;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import org.jackhuang.hmcl.download.DownloadProvider;
import org.jackhuang.hmcl.download.RemoteVersion;
import org.jackhuang.hmcl.download.VersionList;
@@ -31,6 +27,11 @@ import org.jackhuang.hmcl.util.NetworkUtils;
import org.jackhuang.hmcl.util.StringUtils;
import org.jackhuang.hmcl.util.VersionNumber;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
/**
*
* @author huangyuhui
@@ -54,7 +55,7 @@ public final class ForgeVersionList extends VersionList<Void> {
}
@Override
public void execute() throws Exception {
public void execute() {
ForgeVersionRoot root = Constants.GSON.fromJson(task.getResult(), ForgeVersionRoot.class);
if (root == null)
return;

View File

@@ -18,10 +18,11 @@
package org.jackhuang.hmcl.download.forge;
import com.google.gson.JsonParseException;
import java.util.Map;
import org.jackhuang.hmcl.util.Immutable;
import org.jackhuang.hmcl.util.Validation;
import java.util.Map;
/**
*
* @author huangyuhui

View File

@@ -17,15 +17,7 @@
*/
package org.jackhuang.hmcl.download.game;
import java.io.File;
import java.io.IOException;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import org.jackhuang.hmcl.download.AbstractDependencyManager;
import org.jackhuang.hmcl.game.AssetIndexInfo;
import org.jackhuang.hmcl.game.AssetObject;
import org.jackhuang.hmcl.game.Version;
import org.jackhuang.hmcl.task.FileDownloadTask;
@@ -35,6 +27,14 @@ import org.jackhuang.hmcl.util.FileUtils;
import org.jackhuang.hmcl.util.Logging;
import org.jackhuang.hmcl.util.NetworkUtils;
import java.io.File;
import java.io.IOException;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
/**
*
* @author huangyuhui
@@ -71,7 +71,7 @@ public final class GameAssetDownloadTask extends Task {
}
@Override
public void execute() throws Exception {
public void execute() {
int size = refreshTask.getResult().size();
for (Map.Entry<File, AssetObject> entry : refreshTask.getResult()) {
File file = entry.getKey();

View File

@@ -17,10 +17,6 @@
*/
package org.jackhuang.hmcl.download.game;
import java.io.File;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
import org.jackhuang.hmcl.download.AbstractDependencyManager;
import org.jackhuang.hmcl.game.AssetIndexInfo;
import org.jackhuang.hmcl.game.Version;
@@ -29,6 +25,11 @@ import org.jackhuang.hmcl.task.Task;
import org.jackhuang.hmcl.util.FileUtils;
import org.jackhuang.hmcl.util.NetworkUtils;
import java.io.File;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
/**
* This task is to download asset index file provided in minecraft.json.
*

View File

@@ -17,10 +17,6 @@
*/
package org.jackhuang.hmcl.download.game;
import java.io.File;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import org.jackhuang.hmcl.download.AbstractDependencyManager;
import org.jackhuang.hmcl.game.AssetIndex;
import org.jackhuang.hmcl.game.AssetIndexInfo;
@@ -32,6 +28,11 @@ import org.jackhuang.hmcl.util.Constants;
import org.jackhuang.hmcl.util.FileUtils;
import org.jackhuang.hmcl.util.Pair;
import java.io.File;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
/**
* This task is to extract all asset objects described in asset index json.
*

View File

@@ -17,15 +17,16 @@
*/
package org.jackhuang.hmcl.download.game;
import java.io.File;
import java.util.LinkedList;
import java.util.List;
import org.jackhuang.hmcl.download.DefaultDependencyManager;
import org.jackhuang.hmcl.game.Version;
import org.jackhuang.hmcl.task.FileDownloadTask;
import org.jackhuang.hmcl.task.Task;
import org.jackhuang.hmcl.util.NetworkUtils;
import java.io.File;
import java.util.LinkedList;
import java.util.List;
/**
*
* @author huangyuhui
@@ -46,7 +47,7 @@ public final class GameDownloadTask extends Task {
}
@Override
public void execute() throws Exception {
public void execute() {
File jar = dependencyManager.getGameRepository().getVersionJar(version);
dependencies.add(new FileDownloadTask(

View File

@@ -17,9 +17,6 @@
*/
package org.jackhuang.hmcl.download.game;
import java.io.File;
import java.util.LinkedList;
import java.util.List;
import org.jackhuang.hmcl.download.AbstractDependencyManager;
import org.jackhuang.hmcl.game.Library;
import org.jackhuang.hmcl.game.Version;
@@ -27,6 +24,10 @@ import org.jackhuang.hmcl.task.FileDownloadTask;
import org.jackhuang.hmcl.task.Task;
import org.jackhuang.hmcl.util.NetworkUtils;
import java.io.File;
import java.util.LinkedList;
import java.util.List;
/**
* This task is to download game libraries.
* This task should be executed last(especially after game downloading, Forge, LiteLoader and OptiFine install task).
@@ -56,7 +57,7 @@ public final class GameLibrariesTask extends Task {
}
@Override
public void execute() throws Exception {
public void execute() {
version.getLibraries().stream().filter(Library::appliesToCurrentEnvironment).forEach(library -> {
File file = dependencyManager.getGameRepository().getLibraryFile(version, library);
if (!file.exists())

View File

@@ -17,10 +17,6 @@
*/
package org.jackhuang.hmcl.download.game;
import java.io.File;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import org.jackhuang.hmcl.download.DependencyManager;
import org.jackhuang.hmcl.game.DownloadType;
import org.jackhuang.hmcl.game.LoggingInfo;
@@ -29,6 +25,11 @@ import org.jackhuang.hmcl.task.FileDownloadTask;
import org.jackhuang.hmcl.task.Task;
import org.jackhuang.hmcl.util.NetworkUtils;
import java.io.File;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
/**
* This task is to download log4j configuration file provided in minecraft.json.
*
@@ -57,7 +58,7 @@ public final class GameLoggingDownloadTask extends Task {
}
@Override
public void execute() throws Exception {
public void execute() {
if (version.getLogging() == null || !version.getLogging().containsKey(DownloadType.CLIENT))
return;

View File

@@ -19,12 +19,13 @@ package org.jackhuang.hmcl.download.game;
import com.google.gson.JsonParseException;
import com.google.gson.annotations.SerializedName;
import java.util.Date;
import org.jackhuang.hmcl.game.ReleaseType;
import org.jackhuang.hmcl.util.Constants;
import org.jackhuang.hmcl.util.StringUtils;
import org.jackhuang.hmcl.util.Validation;
import java.util.Date;
/**
*
* @author huangyuhui

View File

@@ -17,10 +17,11 @@
*/
package org.jackhuang.hmcl.download.game;
import java.util.Date;
import org.jackhuang.hmcl.game.ReleaseType;
import org.jackhuang.hmcl.util.Immutable;
import java.util.Date;
/**
*
* @author huangyuhui

View File

@@ -18,9 +18,10 @@
package org.jackhuang.hmcl.download.game;
import com.google.gson.annotations.SerializedName;
import org.jackhuang.hmcl.util.Immutable;
import java.util.Collections;
import java.util.List;
import org.jackhuang.hmcl.util.Immutable;
/**
*

View File

@@ -17,8 +17,6 @@
*/
package org.jackhuang.hmcl.download.game;
import java.util.Collection;
import java.util.Collections;
import org.jackhuang.hmcl.download.DownloadProvider;
import org.jackhuang.hmcl.download.RemoteVersion;
import org.jackhuang.hmcl.download.VersionList;
@@ -28,6 +26,9 @@ import org.jackhuang.hmcl.util.Constants;
import org.jackhuang.hmcl.util.NetworkUtils;
import org.jackhuang.hmcl.util.VersionNumber;
import java.util.Collection;
import java.util.Collections;
/**
*
* @author huangyuhui
@@ -49,7 +50,7 @@ public final class GameVersionList extends VersionList<GameRemoteVersionTag> {
}
@Override
public void execute() throws Exception {
public void execute() {
versions.clear();
GameRemoteVersions root = Constants.GSON.fromJson(task.getResult(), GameRemoteVersions.class);

View File

@@ -17,10 +17,6 @@
*/
package org.jackhuang.hmcl.download.game;
import java.net.Proxy;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import org.jackhuang.hmcl.download.DefaultDependencyManager;
import org.jackhuang.hmcl.download.RemoteVersion;
import org.jackhuang.hmcl.download.VersionList;
@@ -28,6 +24,11 @@ import org.jackhuang.hmcl.task.GetTask;
import org.jackhuang.hmcl.task.Task;
import org.jackhuang.hmcl.util.NetworkUtils;
import java.net.Proxy;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
/**
*
* @author huangyuhui
@@ -59,7 +60,7 @@ public final class VersionJsonDownloadTask extends Task {
}
@Override
public void execute() throws Exception {
public void execute() {
RemoteVersion<?> remoteVersion = gameVersionList.getVersions(gameVersion).stream().findFirst()
.orElseThrow(() -> new IllegalStateException("Cannot find specific version " + gameVersion + " in remote repository"));
String jsonURL = dependencyManager.getDownloadProvider().injectURL(remoteVersion.getUrl());

View File

@@ -17,14 +17,15 @@
*/
package org.jackhuang.hmcl.download.game;
import java.io.File;
import java.io.IOException;
import org.jackhuang.hmcl.game.DefaultGameRepository;
import org.jackhuang.hmcl.game.Version;
import org.jackhuang.hmcl.task.Task;
import org.jackhuang.hmcl.util.Constants;
import org.jackhuang.hmcl.util.FileUtils;
import java.io.File;
import java.io.IOException;
/**
* This task is to save the version json.
*

View File

@@ -18,11 +18,12 @@
package org.jackhuang.hmcl.download.liteloader;
import com.google.gson.annotations.SerializedName;
import org.jackhuang.hmcl.game.Library;
import org.jackhuang.hmcl.util.Immutable;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
import org.jackhuang.hmcl.game.Library;
import org.jackhuang.hmcl.util.Immutable;
/**
*

View File

@@ -17,15 +17,9 @@
*/
package org.jackhuang.hmcl.download.liteloader;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import org.jackhuang.hmcl.download.DefaultDependencyManager;
import org.jackhuang.hmcl.download.RemoteVersion;
import org.jackhuang.hmcl.download.game.GameLibrariesTask;
import org.jackhuang.hmcl.game.Arguments;
import org.jackhuang.hmcl.game.LibrariesDownloadInfo;
import org.jackhuang.hmcl.game.Library;
import org.jackhuang.hmcl.game.LibraryDownloadInfo;
@@ -34,6 +28,11 @@ import org.jackhuang.hmcl.task.Task;
import org.jackhuang.hmcl.task.TaskResult;
import org.jackhuang.hmcl.util.Lang;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
/**
* Note: LiteLoader must be installed after Forge.
*
@@ -89,7 +88,7 @@ public final class LiteLoaderInstallTask extends TaskResult<Version> {
}
@Override
public void execute() throws Exception {
public void execute() {
Library library = new Library(
"com.mumfrey", "liteloader", remote.getSelfVersion(), null,
"http://dl.liteloader.com/versions/",

View File

@@ -17,9 +17,10 @@
*/
package org.jackhuang.hmcl.download.liteloader;
import org.jackhuang.hmcl.game.Library;
import java.util.Collection;
import java.util.Collections;
import org.jackhuang.hmcl.game.Library;
/**
*

View File

@@ -17,11 +17,12 @@
*/
package org.jackhuang.hmcl.download.liteloader;
import java.util.Collection;
import java.util.Collections;
import org.jackhuang.hmcl.game.Library;
import org.jackhuang.hmcl.util.Immutable;
import java.util.Collection;
import java.util.Collections;
/**
*
* @author huangyuhui

View File

@@ -17,9 +17,6 @@
*/
package org.jackhuang.hmcl.download.liteloader;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
import org.jackhuang.hmcl.download.DownloadProvider;
import org.jackhuang.hmcl.download.RemoteVersion;
import org.jackhuang.hmcl.download.VersionList;
@@ -29,6 +26,10 @@ import org.jackhuang.hmcl.util.Constants;
import org.jackhuang.hmcl.util.NetworkUtils;
import org.jackhuang.hmcl.util.VersionNumber;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
/**
*
* @author huangyuhui
@@ -50,7 +51,7 @@ public final class LiteLoaderVersionList extends VersionList<LiteLoaderRemoteVer
}
@Override
public void execute() throws Exception {
public void execute() {
LiteLoaderVersionsRoot root = Constants.GSON.fromJson(task.getResult(), LiteLoaderVersionsRoot.class);
versions.clear();

View File

@@ -18,9 +18,10 @@
package org.jackhuang.hmcl.download.liteloader;
import com.google.gson.annotations.SerializedName;
import org.jackhuang.hmcl.util.Immutable;
import java.util.Collections;
import java.util.Map;
import org.jackhuang.hmcl.util.Immutable;
/**
*

View File

@@ -18,11 +18,6 @@
package org.jackhuang.hmcl.download.optifine;
import com.google.gson.reflect.TypeToken;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.jackhuang.hmcl.download.DownloadProvider;
import org.jackhuang.hmcl.download.RemoteVersion;
import org.jackhuang.hmcl.download.VersionList;
@@ -33,6 +28,8 @@ import org.jackhuang.hmcl.util.NetworkUtils;
import org.jackhuang.hmcl.util.StringUtils;
import org.jackhuang.hmcl.util.VersionNumber;
import java.util.*;
/**
*
* @author huangyuhui
@@ -54,7 +51,7 @@ public final class OptiFineBMCLVersionList extends VersionList<Void> {
}
@Override
public void execute() throws Exception {
public void execute() {
versions.clear();
Set<String> duplicates = new HashSet<>();
List<OptiFineVersion> root = Constants.GSON.fromJson(task.getResult(), new TypeToken<List<OptiFineVersion>>() {

View File

@@ -17,11 +17,12 @@
*/
package org.jackhuang.hmcl.download.optifine;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.jackhuang.hmcl.task.TaskResult;
import org.jackhuang.hmcl.util.NetworkUtils;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
*
* @author huangyuhui

View File

@@ -17,26 +17,20 @@
*/
package org.jackhuang.hmcl.download.optifine;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import org.jackhuang.hmcl.download.DefaultDependencyManager;
import org.jackhuang.hmcl.download.RemoteVersion;
import org.jackhuang.hmcl.download.VersionList;
import org.jackhuang.hmcl.download.game.GameLibrariesTask;
import org.jackhuang.hmcl.game.Argument;
import org.jackhuang.hmcl.game.Arguments;
import org.jackhuang.hmcl.game.LibrariesDownloadInfo;
import org.jackhuang.hmcl.game.Library;
import org.jackhuang.hmcl.game.LibraryDownloadInfo;
import org.jackhuang.hmcl.game.StringArgument;
import org.jackhuang.hmcl.game.Version;
import org.jackhuang.hmcl.game.*;
import org.jackhuang.hmcl.task.Task;
import org.jackhuang.hmcl.task.TaskResult;
import org.jackhuang.hmcl.util.Lang;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
/**
* <b>Note</b>: OptiFine should be installed in the end.
*
@@ -97,7 +91,7 @@ public final class OptiFineInstallTask extends TaskResult<Version> {
}
@Override
public void execute() throws Exception {
public void execute() {
Library library = new Library(
"net.optifine", "optifine", remoteVersion, null, null,
new LibrariesDownloadInfo(new LibraryDownloadInfo(

View File

@@ -17,13 +17,6 @@
*/
package org.jackhuang.hmcl.download.optifine;
import java.io.ByteArrayInputStream;
import java.util.Collection;
import java.util.Collections;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.jackhuang.hmcl.download.DownloadProvider;
import org.jackhuang.hmcl.download.RemoteVersion;
import org.jackhuang.hmcl.download.VersionList;
@@ -34,6 +27,14 @@ import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import java.io.ByteArrayInputStream;
import java.util.Collection;
import java.util.Collections;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
*
* @author huangyuhui

View File

@@ -18,7 +18,6 @@
package org.jackhuang.hmcl.event;
import java.util.HashMap;
import org.jackhuang.hmcl.task.Schedulers;
/**
*

View File

@@ -17,12 +17,11 @@
*/
package org.jackhuang.hmcl.event;
import org.jackhuang.hmcl.util.SimpleMultimap;
import java.util.EnumMap;
import java.util.HashSet;
import java.util.function.Consumer;
import org.jackhuang.hmcl.task.Scheduler;
import org.jackhuang.hmcl.task.Schedulers;
import org.jackhuang.hmcl.util.SimpleMultimap;
/**
*

View File

@@ -17,8 +17,6 @@
*/
package org.jackhuang.hmcl.event;
import java.util.EventObject;
/**
*
* @author huang

View File

@@ -17,7 +17,6 @@
*/
package org.jackhuang.hmcl.event;
import java.util.EventObject;
import org.jackhuang.hmcl.util.ManagedProcess;
/**

View File

@@ -19,8 +19,6 @@ package org.jackhuang.hmcl.event;
import org.jackhuang.hmcl.game.Version;
import java.util.EventObject;
/**
* This event gets fired when a minecraft version has been loaded.
* <br>

View File

@@ -17,7 +17,6 @@
*/
package org.jackhuang.hmcl.event;
import java.util.EventObject;
import org.jackhuang.hmcl.util.ManagedProcess;
/**

View File

@@ -17,7 +17,6 @@
*/
package org.jackhuang.hmcl.event;
import java.util.EventObject;
import org.jackhuang.hmcl.util.ManagedProcess;
/**

View File

@@ -17,8 +17,6 @@
*/
package org.jackhuang.hmcl.event;
import java.util.EventObject;
/**
* This event gets fired when all the versions in .minecraft folder are loaded.
* <br>

View File

@@ -17,8 +17,6 @@
*/
package org.jackhuang.hmcl.event;
import java.util.EventObject;
/**
* This event gets fired when loading versions in a .minecraft folder.
* <br>

View File

@@ -17,17 +17,12 @@
*/
package org.jackhuang.hmcl.game;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import com.google.gson.*;
import org.jackhuang.hmcl.util.Immutable;
import java.lang.reflect.Type;
import java.util.List;
import java.util.Map;
import org.jackhuang.hmcl.util.Immutable;
/**
*
@@ -45,7 +40,7 @@ public interface Argument extends Cloneable {
*/
List<String> toString(Map<String, String> keys, Map<String, Boolean> features);
public static class Serializer implements JsonDeserializer<Argument>, JsonSerializer<Argument> {
class Serializer implements JsonDeserializer<Argument>, JsonSerializer<Argument> {
public static final Serializer INSTANCE = new Serializer();

View File

@@ -18,16 +18,13 @@
package org.jackhuang.hmcl.game;
import com.google.gson.annotations.SerializedName;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.jackhuang.hmcl.util.Immutable;
import org.jackhuang.hmcl.util.Lang;
import org.jackhuang.hmcl.util.OperatingSystem;
import java.util.*;
import java.util.stream.Collectors;
/**
*
* @author huangyuhui

View File

@@ -18,6 +18,7 @@
package org.jackhuang.hmcl.game;
import com.google.gson.annotations.SerializedName;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

View File

@@ -17,11 +17,12 @@
*/
package org.jackhuang.hmcl.game;
import org.jackhuang.hmcl.util.Immutable;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
import java.util.Objects;
import org.jackhuang.hmcl.util.Immutable;
/**
*

View File

@@ -19,18 +19,17 @@ package org.jackhuang.hmcl.game;
import com.google.gson.JsonParseException;
import com.google.gson.JsonSyntaxException;
import java.io.File;
import java.io.IOException;
import java.util.*;
import java.util.logging.Level;
import org.jackhuang.hmcl.event.*;
import org.jackhuang.hmcl.task.Schedulers;
import org.jackhuang.hmcl.util.Constants;
import org.jackhuang.hmcl.util.FileUtils;
import org.jackhuang.hmcl.util.Lang;
import org.jackhuang.hmcl.util.Logging;
import java.io.File;
import java.io.IOException;
import java.util.*;
import java.util.logging.Level;
/**
* An implementation of classic Minecraft game repository.
*
@@ -279,7 +278,7 @@ public class DefaultGameRepository implements GameRepository {
return assetsDir;
String assetIndexContent = FileUtils.readText(indexFile);
AssetIndex index = (AssetIndex) Constants.GSON.fromJson(assetIndexContent, AssetIndex.class);
AssetIndex index = Constants.GSON.fromJson(assetIndexContent, AssetIndex.class);
if (index == null)
return assetsDir;

View File

@@ -17,9 +17,10 @@
*/
package org.jackhuang.hmcl.game;
import org.jackhuang.hmcl.util.JavaVersion;
import java.io.File;
import java.io.Serializable;
import org.jackhuang.hmcl.util.JavaVersion;
/**
*

View File

@@ -17,10 +17,11 @@
*/
package org.jackhuang.hmcl.game;
import org.jackhuang.hmcl.util.Immutable;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import org.jackhuang.hmcl.util.Immutable;
/**
*

View File

@@ -17,25 +17,17 @@
*/
package org.jackhuang.hmcl.game;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonNull;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import com.google.gson.*;
import com.google.gson.reflect.TypeToken;
import org.jackhuang.hmcl.util.Constants;
import org.jackhuang.hmcl.util.OperatingSystem;
import org.jackhuang.hmcl.util.Platform;
import java.lang.reflect.Type;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import org.jackhuang.hmcl.util.Constants;
import org.jackhuang.hmcl.util.Lang;
import org.jackhuang.hmcl.util.OperatingSystem;
import org.jackhuang.hmcl.util.Platform;
/**
* A class that describes a Minecraft dependency.
*

View File

@@ -17,10 +17,11 @@
*/
package org.jackhuang.hmcl.game;
import java.util.regex.Pattern;
import org.jackhuang.hmcl.util.Lang;
import org.jackhuang.hmcl.util.OperatingSystem;
import java.util.regex.Pattern;
/**
*
* @author huangyuhui
@@ -70,8 +71,7 @@ public final class OSRestriction {
return false;
if (arch != null)
if (Lang.test(() -> !Pattern.compile(arch).matcher(OperatingSystem.SYSTEM_ARCHITECTURE).matches()))
return false;
return !Lang.test(() -> !Pattern.compile(arch).matcher(OperatingSystem.SYSTEM_ARCHITECTURE).matches());
return true;
}

View File

@@ -31,7 +31,7 @@ public enum ReleaseType {
private final String id;
private ReleaseType(String id) {
ReleaseType(String id) {
this.id = id;
}

View File

@@ -17,21 +17,16 @@
*/
package org.jackhuang.hmcl.game;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import com.google.gson.*;
import com.google.gson.reflect.TypeToken;
import org.jackhuang.hmcl.util.Immutable;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.jackhuang.hmcl.util.Immutable;
/**
*

View File

@@ -17,12 +17,13 @@
*/
package org.jackhuang.hmcl.game;
import org.jackhuang.hmcl.util.Immutable;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.jackhuang.hmcl.util.Immutable;
/**
*

View File

@@ -18,23 +18,10 @@
package org.jackhuang.hmcl.game;
import com.google.gson.JsonParseException;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import org.jackhuang.hmcl.util.*;
import java.util.*;
import java.util.logging.Level;
import org.jackhuang.hmcl.util.Constants;
import org.jackhuang.hmcl.util.Immutable;
import org.jackhuang.hmcl.util.Lang;
import org.jackhuang.hmcl.util.Logging;
import org.jackhuang.hmcl.util.StringUtils;
import org.jackhuang.hmcl.util.Validation;
/**
*

View File

@@ -17,32 +17,15 @@
*/
package org.jackhuang.hmcl.launch;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import org.jackhuang.hmcl.auth.AuthInfo;
import org.jackhuang.hmcl.game.*;
import org.jackhuang.hmcl.task.TaskResult;
import org.jackhuang.hmcl.util.*;
import java.io.*;
import java.util.*;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import org.jackhuang.hmcl.auth.AuthInfo;
import org.jackhuang.hmcl.game.Argument;
import org.jackhuang.hmcl.game.Arguments;
import org.jackhuang.hmcl.game.DownloadType;
import org.jackhuang.hmcl.game.GameRepository;
import org.jackhuang.hmcl.game.LaunchOptions;
import org.jackhuang.hmcl.game.Library;
import org.jackhuang.hmcl.game.LoggingInfo;
import org.jackhuang.hmcl.task.TaskResult;
import org.jackhuang.hmcl.util.CompressingUtils;
import org.jackhuang.hmcl.util.FileUtils;
import org.jackhuang.hmcl.util.JavaVersion;
import org.jackhuang.hmcl.util.Lang;
import org.jackhuang.hmcl.util.Log4jLevel;
import org.jackhuang.hmcl.util.ManagedProcess;
import org.jackhuang.hmcl.util.OperatingSystem;
import org.jackhuang.hmcl.util.Pair;
import org.jackhuang.hmcl.util.StringUtils;
/**
*

View File

@@ -17,10 +17,6 @@
*/
package org.jackhuang.hmcl.launch;
import java.util.Collection;
import java.util.List;
import java.util.function.BiConsumer;
import java.util.stream.Collectors;
import org.jackhuang.hmcl.event.EventBus;
import org.jackhuang.hmcl.event.JVMLaunchFailedEvent;
import org.jackhuang.hmcl.event.ProcessExitedAbnormallyEvent;
@@ -29,6 +25,11 @@ import org.jackhuang.hmcl.util.Log4jLevel;
import org.jackhuang.hmcl.util.ManagedProcess;
import org.jackhuang.hmcl.util.StringUtils;
import java.util.Collection;
import java.util.List;
import java.util.function.BiConsumer;
import java.util.stream.Collectors;
/**
*
* @author huangyuhui

View File

@@ -17,16 +17,16 @@
*/
package org.jackhuang.hmcl.launch;
import java.io.File;
import java.io.IOException;
import java.util.List;
import org.jackhuang.hmcl.auth.AuthInfo;
import org.jackhuang.hmcl.game.GameException;
import org.jackhuang.hmcl.game.GameRepository;
import org.jackhuang.hmcl.game.LaunchOptions;
import org.jackhuang.hmcl.game.Version;
import org.jackhuang.hmcl.util.ManagedProcess;
import java.io.File;
import java.io.IOException;
import java.util.List;
/**
*
* @author huangyuhui

View File

@@ -17,12 +17,6 @@
*/
package org.jackhuang.hmcl.launch;
import java.io.*;
import java.util.Date;
import java.util.Optional;
import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.BiConsumer;
import org.jackhuang.hmcl.task.Schedulers;
import org.jackhuang.hmcl.util.Constants;
import org.jackhuang.hmcl.util.Lang;
@@ -35,6 +29,16 @@ import org.xml.sax.XMLReader;
import org.xml.sax.helpers.DefaultHandler;
import org.xml.sax.helpers.XMLReaderFactory;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
import java.util.Date;
import java.util.Optional;
import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.BiConsumer;
/**
* This class is to parse log4j classic XML layout logging,
* since only vanilla Minecraft will enable this layout.
@@ -106,7 +110,7 @@ final class Log4jHandler extends Thread {
private boolean readingMessage = false;
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
public void startElement(String uri, String localName, String qName, Attributes attributes) {
switch (localName) {
case "log4j_Event":
message = new StringBuilder();
@@ -131,7 +135,7 @@ final class Log4jHandler extends Thread {
}
@Override
public void endElement(String uri, String localName, String qName) throws SAXException {
public void endElement(String uri, String localName, String qName) {
switch (localName) {
case "log4j_Event":
callback.accept("[" + date + "] [" + thread + "/" + level.name() + "] [" + logger + "] " + message.toString(), level);
@@ -143,7 +147,7 @@ final class Log4jHandler extends Thread {
}
@Override
public void characters(char[] ch, int start, int length) throws SAXException {
public void characters(char[] ch, int start, int length) {
String line = new String(ch, start, length);
if (line.trim().isEmpty())
return;

View File

@@ -17,14 +17,15 @@
*/
package org.jackhuang.hmcl.launch;
import org.jackhuang.hmcl.util.Constants;
import org.jackhuang.hmcl.util.Logging;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.function.Consumer;
import java.util.logging.Level;
import org.jackhuang.hmcl.util.Constants;
import org.jackhuang.hmcl.util.Logging;
/**
* Pump the given input stream.

View File

@@ -17,6 +17,12 @@
*/
package org.jackhuang.hmcl.mod;
import org.jackhuang.hmcl.download.DefaultDependencyManager;
import org.jackhuang.hmcl.game.GameRepository;
import org.jackhuang.hmcl.task.FileDownloadTask;
import org.jackhuang.hmcl.task.Task;
import org.jackhuang.hmcl.util.*;
import java.io.File;
import java.util.Collection;
import java.util.LinkedList;
@@ -24,16 +30,6 @@ import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Level;
import java.util.stream.Collectors;
import org.jackhuang.hmcl.download.DefaultDependencyManager;
import org.jackhuang.hmcl.game.GameRepository;
import org.jackhuang.hmcl.task.FileDownloadTask;
import org.jackhuang.hmcl.task.Task;
import org.jackhuang.hmcl.util.Constants;
import org.jackhuang.hmcl.util.FileUtils;
import org.jackhuang.hmcl.util.Lang;
import org.jackhuang.hmcl.util.Logging;
import org.jackhuang.hmcl.util.NetworkUtils;
import org.jackhuang.hmcl.util.StringUtils;
/**
* Complete the CurseForge version.

View File

@@ -17,16 +17,17 @@
*/
package org.jackhuang.hmcl.mod;
import java.io.File;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import org.jackhuang.hmcl.download.DefaultDependencyManager;
import org.jackhuang.hmcl.download.GameBuilder;
import org.jackhuang.hmcl.game.DefaultGameRepository;
import org.jackhuang.hmcl.task.Task;
import org.jackhuang.hmcl.util.CompressingUtils;
import java.io.File;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
/**
* Install a downloaded CurseForge modpack.
*

View File

@@ -19,17 +19,16 @@ package org.jackhuang.hmcl.mod;
import com.google.gson.JsonParseException;
import com.google.gson.annotations.SerializedName;
import org.jackhuang.hmcl.util.CompressingUtils;
import org.jackhuang.hmcl.util.Constants;
import org.jackhuang.hmcl.util.Immutable;
import java.io.File;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import org.jackhuang.hmcl.util.CompressingUtils;
import org.jackhuang.hmcl.util.Constants;
import org.jackhuang.hmcl.util.Immutable;
import org.jackhuang.hmcl.util.Lang;
/**
*
* @author huangyuhui

View File

@@ -19,11 +19,12 @@ package org.jackhuang.hmcl.mod;
import com.google.gson.JsonParseException;
import com.google.gson.annotations.SerializedName;
import java.net.URL;
import org.jackhuang.hmcl.util.Immutable;
import org.jackhuang.hmcl.util.NetworkUtils;
import org.jackhuang.hmcl.util.Validation;
import java.net.URL;
/**
*
* @author huangyuhui

View File

@@ -19,13 +19,14 @@ package org.jackhuang.hmcl.mod;
import com.google.gson.JsonParseException;
import com.google.gson.annotations.SerializedName;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import org.jackhuang.hmcl.util.Immutable;
import org.jackhuang.hmcl.util.StringUtils;
import org.jackhuang.hmcl.util.Validation;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
/**
*
* @author huangyuhui

View File

@@ -20,10 +20,6 @@ package org.jackhuang.hmcl.mod;
import com.google.gson.JsonParseException;
import com.google.gson.annotations.SerializedName;
import com.google.gson.reflect.TypeToken;
import java.io.File;
import java.io.IOException;
import java.util.List;
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
import org.apache.commons.compress.archivers.zip.ZipFile;
import org.jackhuang.hmcl.util.Constants;
@@ -31,6 +27,10 @@ import org.jackhuang.hmcl.util.IOUtils;
import org.jackhuang.hmcl.util.Immutable;
import org.jackhuang.hmcl.util.StringUtils;
import java.io.File;
import java.io.IOException;
import java.util.List;
/**
*
* @author huangyuhui

View File

@@ -18,13 +18,14 @@
package org.jackhuang.hmcl.mod;
import com.google.gson.JsonParseException;
import org.jackhuang.hmcl.util.Constants;
import org.jackhuang.hmcl.util.IOUtils;
import org.jackhuang.hmcl.util.Immutable;
import java.io.File;
import java.io.IOException;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import org.jackhuang.hmcl.util.Constants;
import org.jackhuang.hmcl.util.IOUtils;
import org.jackhuang.hmcl.util.Immutable;
/**
*

View File

@@ -0,0 +1,21 @@
/*
* Hello Minecraft! Launcher.
* Copyright (C) 2017 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.hmcl.mod;
public class MinecraftInstanceTask {
}

View File

@@ -17,11 +17,12 @@
*/
package org.jackhuang.hmcl.mod;
import java.io.File;
import org.jackhuang.hmcl.util.FileUtils;
import org.jackhuang.hmcl.util.ImmediateBooleanProperty;
import org.jackhuang.hmcl.util.StringUtils;
import java.io.File;
/**
*
* @author huangyuhui

View File

@@ -17,17 +17,16 @@
*/
package org.jackhuang.hmcl.mod;
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
import org.apache.commons.compress.archivers.zip.ZipFile;
import org.jackhuang.hmcl.util.StringUtils;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.Optional;
import java.util.Properties;
import org.apache.commons.compress.archivers.zip.ZipFile;
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
import org.jackhuang.hmcl.util.Lang;
import org.jackhuang.hmcl.util.StringUtils;
/**
*
* @author huangyuhui

View File

@@ -18,11 +18,12 @@
package org.jackhuang.hmcl.mod;
import com.google.gson.annotations.SerializedName;
import org.jackhuang.hmcl.game.Library;
import org.jackhuang.hmcl.util.Immutable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.jackhuang.hmcl.game.Library;
import org.jackhuang.hmcl.util.Immutable;
/**
*

View File

@@ -17,10 +17,6 @@
*/
package org.jackhuang.hmcl.mod;
import java.io.File;
import java.util.LinkedList;
import java.util.List;
import java.util.Objects;
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
import org.apache.commons.compress.archivers.zip.ZipFile;
import org.jackhuang.hmcl.download.DefaultDependencyManager;
@@ -34,6 +30,11 @@ import org.jackhuang.hmcl.util.Constants;
import org.jackhuang.hmcl.util.IOUtils;
import org.jackhuang.hmcl.util.Lang;
import java.io.File;
import java.util.LinkedList;
import java.util.List;
import java.util.Objects;
/**
*
* @author huangyuhui

View File

@@ -17,12 +17,13 @@
*/
package org.jackhuang.hmcl.task;
import org.jackhuang.hmcl.util.AutoTypingMap;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.function.Function;
import org.jackhuang.hmcl.util.AutoTypingMap;
/**
* A task that combines two tasks and make sure [pred] runs before succ.
@@ -50,7 +51,7 @@ final class CoupleTask<P extends Task> extends Task {
}
@Override
public void execute() throws Exception {
public void execute() {
Task task = succ.apply(getVariables());
if (task != null)
dependencies.add(task);

View File

@@ -17,6 +17,10 @@
*/
package org.jackhuang.hmcl.task;
import org.jackhuang.hmcl.event.EventManager;
import org.jackhuang.hmcl.event.FailedEvent;
import org.jackhuang.hmcl.util.*;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
@@ -27,13 +31,6 @@ import java.net.Proxy;
import java.net.URL;
import java.security.MessageDigest;
import java.util.logging.Level;
import org.jackhuang.hmcl.event.EventManager;
import org.jackhuang.hmcl.event.FailedEvent;
import org.jackhuang.hmcl.util.DigestUtils;
import org.jackhuang.hmcl.util.FileUtils;
import org.jackhuang.hmcl.util.IOUtils;
import org.jackhuang.hmcl.util.Logging;
import org.jackhuang.hmcl.util.NetworkUtils;
/**
* A task that can download a file online.

View File

@@ -17,6 +17,11 @@
*/
package org.jackhuang.hmcl.task;
import org.jackhuang.hmcl.util.Charsets;
import org.jackhuang.hmcl.util.IOUtils;
import org.jackhuang.hmcl.util.Logging;
import org.jackhuang.hmcl.util.NetworkUtils;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -25,10 +30,6 @@ import java.net.Proxy;
import java.net.URL;
import java.nio.charset.Charset;
import java.util.logging.Level;
import org.jackhuang.hmcl.util.Charsets;
import org.jackhuang.hmcl.util.IOUtils;
import org.jackhuang.hmcl.util.Logging;
import org.jackhuang.hmcl.util.NetworkUtils;
/**
*

View File

@@ -40,7 +40,7 @@ public final class ParallelTask extends Task {
}
@Override
public void execute() throws Exception {
public void execute() {
}
@Override

View File

@@ -17,9 +17,10 @@
*/
package org.jackhuang.hmcl.task;
import java.util.concurrent.Future;
import org.jackhuang.hmcl.util.ExceptionalRunnable;
import java.util.concurrent.Future;
/**
* Determines how a task is executed.
*

View File

@@ -17,9 +17,10 @@
*/
package org.jackhuang.hmcl.task;
import org.jackhuang.hmcl.util.ExceptionalRunnable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import org.jackhuang.hmcl.util.ExceptionalRunnable;
/**
*

View File

@@ -17,14 +17,14 @@
*/
package org.jackhuang.hmcl.task;
import org.jackhuang.hmcl.util.ExceptionalRunnable;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Consumer;
import org.jackhuang.hmcl.util.ExceptionalRunnable;
/**
*
@@ -83,7 +83,7 @@ class SchedulerImpl extends Scheduler {
}
@Override
public Void get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
public Void get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException {
latch.await(timeout, unit);
return getImpl();
}

View File

@@ -17,11 +17,7 @@
*/
package org.jackhuang.hmcl.task;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.*;
/**
*

View File

@@ -17,7 +17,6 @@
*/
package org.jackhuang.hmcl.task;
import java.util.function.Consumer;
import org.jackhuang.hmcl.util.AutoTypingMap;
import org.jackhuang.hmcl.util.ExceptionalConsumer;

View File

@@ -17,20 +17,21 @@
*/
package org.jackhuang.hmcl.task;
import javafx.beans.property.ReadOnlyDoubleProperty;
import javafx.beans.property.ReadOnlyDoubleWrapper;
import javafx.beans.property.ReadOnlyStringProperty;
import javafx.beans.property.ReadOnlyStringWrapper;
import org.jackhuang.hmcl.event.EventManager;
import org.jackhuang.hmcl.util.AutoTypingMap;
import org.jackhuang.hmcl.util.ExceptionalConsumer;
import org.jackhuang.hmcl.util.ExceptionalRunnable;
import org.jackhuang.hmcl.util.Properties;
import java.util.Collection;
import java.util.Collections;
import java.util.concurrent.Callable;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Function;
import javafx.beans.property.ReadOnlyDoubleProperty;
import javafx.beans.property.ReadOnlyDoubleWrapper;
import javafx.beans.property.ReadOnlyStringProperty;
import javafx.beans.property.ReadOnlyStringWrapper;
import org.jackhuang.hmcl.util.AutoTypingMap;
import org.jackhuang.hmcl.event.EventManager;
import org.jackhuang.hmcl.util.ExceptionalConsumer;
import org.jackhuang.hmcl.util.ExceptionalRunnable;
import org.jackhuang.hmcl.util.Properties;
/**
* Disposable task.

View File

@@ -17,9 +17,10 @@
*/
package org.jackhuang.hmcl.task;
import java.util.function.Function;
import org.jackhuang.hmcl.util.AutoTypingMap;
import java.util.function.Function;
/**
*
* @author huangyuhui

View File

@@ -17,6 +17,11 @@
*/
package org.jackhuang.hmcl.task;
import org.jackhuang.hmcl.util.AutoTypingMap;
import org.jackhuang.hmcl.util.ExceptionalRunnable;
import org.jackhuang.hmcl.util.Lang;
import org.jackhuang.hmcl.util.Logging;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
@@ -27,10 +32,6 @@ import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Level;
import org.jackhuang.hmcl.util.AutoTypingMap;
import org.jackhuang.hmcl.util.ExceptionalRunnable;
import org.jackhuang.hmcl.util.Lang;
import org.jackhuang.hmcl.util.Logging;
/**
*
@@ -210,7 +211,7 @@ public final class TaskExecutor {
}
@Override
public void run() throws Exception {
public void run() {
try {
Thread.currentThread().setName(task.getName());
if (!executeTask(task))

View File

@@ -17,21 +17,18 @@
*/
package org.jackhuang.hmcl.util;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.function.BiFunction;
import java.util.function.Predicate;
import org.apache.commons.compress.archivers.ArchiveEntry;
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream;
import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream;
import org.apache.commons.compress.archivers.zip.ZipFile;
import java.io.*;
import java.util.function.BiFunction;
import java.util.function.Predicate;
/**
* 文件压缩/解压类
* Utilities of compressing
*
* @author huangyuhui
*/
@@ -43,8 +40,8 @@ public final class CompressingUtils {
/**
* Compress the given directory to a zip file.
*
* @param src the source directory or a file.
* @param destZip the location of dest zip file.
* @param sourceDir the source directory or a file.
* @param zipFile the location of dest zip file.
* @param pathNameCallback callback(pathName, isDirectory) returns your modified pathName
* @throws IOException
*/
@@ -72,7 +69,7 @@ public final class CompressingUtils {
private static void zipFile(File src, String basePath,
ZipArchiveOutputStream zos, BiFunction<String, Boolean, String> pathNameCallback) throws IOException {
File[] files = src.isDirectory() ? src.listFiles() : new File[] { src };
String pathName;//存相对路径(相对于待压缩的根目录)
String pathName;// the relative path (relative to the root directory to be compressed)
byte[] buf = new byte[IOUtils.DEFAULT_BUFFER_SIZE];
for (File file : files)
if (file.isDirectory()) {
@@ -183,7 +180,7 @@ public final class CompressingUtils {
File dir = new File(strtemp);
dir.mkdirs();
} else {
//建目录
// create directories
String strsubdir = gbkPath;
for (int i = 0; i < strsubdir.length(); i++)
if (strsubdir.substring(i, i + 1).equalsIgnoreCase("/")) {
@@ -224,7 +221,7 @@ public final class CompressingUtils {
* Read the text content of a file in zip.
*
* @param file the zip file
* @param location the location of the text in zip file, something like A/B/C/D.txt
* @param name the location of the text in zip file, something like A/B/C/D.txt
* @return the content of given file.
*/
public static String readTextZipEntryQuietly(File file, String name) {

View File

@@ -19,18 +19,19 @@ package org.jackhuang.hmcl.util;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.awt.EventQueue;
import org.jackhuang.hmcl.game.Argument;
import org.jackhuang.hmcl.game.Library;
import org.jackhuang.hmcl.game.RuledArgument;
import org.jackhuang.hmcl.game.StringArgument;
import org.jackhuang.hmcl.task.Schedulers;
import java.awt.*;
import java.io.File;
import java.nio.charset.Charset;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.UUID;
import java.util.function.Consumer;
import org.jackhuang.hmcl.game.Argument;
import org.jackhuang.hmcl.game.Library;
import org.jackhuang.hmcl.game.RuledArgument;
import org.jackhuang.hmcl.game.StringArgument;
import org.jackhuang.hmcl.task.Schedulers;
/**
* Constants.

View File

@@ -17,14 +17,8 @@
*/
package org.jackhuang.hmcl.util;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import com.google.gson.JsonSyntaxException;
import com.google.gson.*;
import java.lang.reflect.Type;
import java.text.DateFormat;
import java.text.ParseException;

View File

@@ -34,7 +34,7 @@ public interface ExceptionalRunnable<E extends Exception> {
};
}
public static ExceptionalRunnable fromRunnable(Runnable r) {
static ExceptionalRunnable fromRunnable(Runnable r) {
return r::run;
}

View File

@@ -17,14 +17,8 @@
*/
package org.jackhuang.hmcl.util;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonNull;
import com.google.gson.JsonParseException;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import com.google.gson.*;
import java.io.File;
import java.lang.reflect.Type;

View File

@@ -17,12 +17,7 @@
*/
package org.jackhuang.hmcl.util;
import java.io.File;
import java.io.FileFilter;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.*;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
@@ -253,9 +248,7 @@ public final class FileUtils {
public static boolean makeFile(File file) {
if (!makeDirectory(file.getAbsoluteFile().getParentFile()))
return false;
if (!file.exists() && !Lang.test(file::createNewFile))
return false;
return true;
return file.exists() || Lang.test(file::createNewFile);
}
public static List<File> listFilesByExtension(File file, String extension) {

View File

@@ -91,7 +91,7 @@ public final class Hex {
public Object decode(Object object) throws Exception {
try {
char[] charArray = (object instanceof String) ? ((String) object).toCharArray() : (char[]) (char[]) object;
char[] charArray = (object instanceof String) ? ((String) object).toCharArray() : (char[]) object;
return decodeHex(charArray);
} catch (ClassCastException e) {
throw new Exception(e.getMessage(), e);
@@ -105,7 +105,7 @@ public final class Hex {
public Object encode(Object object)
throws Exception {
try {
byte[] byteArray = (object instanceof String) ? ((String) object).getBytes(getCharset()) : (byte[]) (byte[]) object;
byte[] byteArray = (object instanceof String) ? ((String) object).getBytes(getCharset()) : (byte[]) object;
return encodeHex(byteArray);
} catch (ClassCastException e) {

View File

@@ -17,11 +17,7 @@
*/
package org.jackhuang.hmcl.util;
import java.io.ByteArrayOutputStream;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.*;
import java.nio.charset.Charset;
/**
@@ -61,7 +57,7 @@ public final class IOUtils {
return readFully(stream).toString();
}
public static String readFullyAsString(InputStream stream, Charset charset) throws IOException {
public static String readFullyAsString(InputStream stream, Charset charset) {
return Lang.invoke(() -> readFully(stream).toString(charset.name()));
}

View File

@@ -17,12 +17,13 @@
*/
package org.jackhuang.hmcl.util;
import java.util.Objects;
import java.util.function.Consumer;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import java.util.Objects;
import java.util.function.Consumer;
/**
*
* @author huangyuhui

View File

@@ -18,12 +18,13 @@
package org.jackhuang.hmcl.util;
import java.util.Objects;
import java.util.function.Consumer;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import java.util.Objects;
import java.util.function.Consumer;
/**
*
* @author huangyuhui

View File

@@ -17,12 +17,13 @@
*/
package org.jackhuang.hmcl.util;
import java.util.Objects;
import java.util.function.Consumer;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import java.util.Objects;
import java.util.function.Consumer;
/**
*
* @author huangyuhui

Some files were not shown because too many files have changed in this diff Show More