clean up HMCLCore
This commit is contained in:
@@ -28,22 +28,22 @@ public final class AccountBuilder<T extends Account> {
|
|||||||
public AccountBuilder() {
|
public AccountBuilder() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public AccountBuilder setSelector(CharacterSelector selector) {
|
public AccountBuilder<T> setSelector(CharacterSelector selector) {
|
||||||
this.selector = Objects.requireNonNull(selector);
|
this.selector = Objects.requireNonNull(selector);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AccountBuilder setUsername(String username) {
|
public AccountBuilder<T> setUsername(String username) {
|
||||||
this.username = Objects.requireNonNull(username);
|
this.username = Objects.requireNonNull(username);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AccountBuilder setPassword(String password) {
|
public AccountBuilder<T> setPassword(String password) {
|
||||||
this.password = password;
|
this.password = password;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AccountBuilder setAdditionalData(Object additionalData) {
|
public AccountBuilder<T> setAdditionalData(Object additionalData) {
|
||||||
this.additionalData = additionalData;
|
this.additionalData = additionalData;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,16 +28,12 @@ import org.jackhuang.hmcl.util.Logging;
|
|||||||
import org.jackhuang.hmcl.util.NetworkUtils;
|
import org.jackhuang.hmcl.util.NetworkUtils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import static org.jackhuang.hmcl.util.DigestUtils.digest;
|
|
||||||
import static org.jackhuang.hmcl.util.Hex.encodeHex;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author huangyuhui
|
* @author huangyuhui
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
package org.jackhuang.hmcl.download.game;
|
package org.jackhuang.hmcl.download.game;
|
||||||
|
|
||||||
import org.jackhuang.hmcl.download.DownloadProvider;
|
import org.jackhuang.hmcl.download.DownloadProvider;
|
||||||
import org.jackhuang.hmcl.download.RemoteVersion;
|
|
||||||
import org.jackhuang.hmcl.download.VersionList;
|
import org.jackhuang.hmcl.download.VersionList;
|
||||||
import org.jackhuang.hmcl.task.GetTask;
|
import org.jackhuang.hmcl.task.GetTask;
|
||||||
import org.jackhuang.hmcl.task.Task;
|
import org.jackhuang.hmcl.task.Task;
|
||||||
|
|||||||
@@ -14,8 +14,6 @@ import org.tukaani.xz.XZInputStream;
|
|||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Paths;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.jar.JarEntry;
|
import java.util.jar.JarEntry;
|
||||||
import java.util.jar.JarInputStream;
|
import java.util.jar.JarInputStream;
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
package org.jackhuang.hmcl.event;
|
package org.jackhuang.hmcl.event;
|
||||||
|
|
||||||
import org.jackhuang.hmcl.util.ManagedProcess;
|
import org.jackhuang.hmcl.util.ManagedProcess;
|
||||||
import org.jackhuang.hmcl.util.ToStringBuilder;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This event gets fired when minecraft process exited successfully and the exit code is 0.
|
* This event gets fired when minecraft process exited successfully and the exit code is 0.
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public final class LibrariesDownloadInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, LibraryDownloadInfo> getClassifiers() {
|
public Map<String, LibraryDownloadInfo> getClassifiers() {
|
||||||
return classifiers == null ? Collections.EMPTY_MAP : Collections.unmodifiableMap(classifiers);
|
return classifiers == null ? Collections.emptyMap() : Collections.unmodifiableMap(classifiers);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -116,15 +116,15 @@ public class Version implements Comparable<Version>, Validation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Map<DownloadType, LoggingInfo> getLogging() {
|
public Map<DownloadType, LoggingInfo> getLogging() {
|
||||||
return logging == null ? Collections.EMPTY_MAP : Collections.unmodifiableMap(logging);
|
return logging == null ? Collections.emptyMap() : Collections.unmodifiableMap(logging);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Library> getLibraries() {
|
public List<Library> getLibraries() {
|
||||||
return libraries == null ? Collections.EMPTY_LIST : Collections.unmodifiableList(libraries);
|
return libraries == null ? Collections.emptyList() : Collections.unmodifiableList(libraries);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<CompatibilityRule> getCompatibilityRules() {
|
public List<CompatibilityRule> getCompatibilityRules() {
|
||||||
return compatibilityRules == null ? Collections.EMPTY_LIST : Collections.unmodifiableList(compatibilityRules);
|
return compatibilityRules == null ? Collections.emptyList() : Collections.unmodifiableList(compatibilityRules);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DownloadInfo getDownloadInfo() {
|
public DownloadInfo getDownloadInfo() {
|
||||||
@@ -247,14 +247,14 @@ public class Version implements Comparable<Version>, Validation {
|
|||||||
if (StringUtils.isBlank(id))
|
if (StringUtils.isBlank(id))
|
||||||
throw new JsonParseException("Version ID cannot be blank");
|
throw new JsonParseException("Version ID cannot be blank");
|
||||||
if (downloads != null)
|
if (downloads != null)
|
||||||
for (Map.Entry entry : downloads.entrySet()) {
|
for (Map.Entry<DownloadType, DownloadInfo> entry : downloads.entrySet()) {
|
||||||
if (!(entry.getKey() instanceof DownloadType))
|
if (!(entry.getKey() instanceof DownloadType))
|
||||||
throw new JsonParseException("Version downloads key must be DownloadType");
|
throw new JsonParseException("Version downloads key must be DownloadType");
|
||||||
if (!(entry.getValue() instanceof DownloadInfo))
|
if (!(entry.getValue() instanceof DownloadInfo))
|
||||||
throw new JsonParseException("Version downloads value must be DownloadInfo");
|
throw new JsonParseException("Version downloads value must be DownloadInfo");
|
||||||
}
|
}
|
||||||
if (logging != null)
|
if (logging != null)
|
||||||
for (Map.Entry entry : logging.entrySet()) {
|
for (Map.Entry<DownloadType, LoggingInfo> entry : logging.entrySet()) {
|
||||||
if (!(entry.getKey() instanceof DownloadType))
|
if (!(entry.getKey() instanceof DownloadType))
|
||||||
throw new JsonParseException("Version logging key must be DownloadType");
|
throw new JsonParseException("Version logging key must be DownloadType");
|
||||||
if (!(entry.getValue() instanceof LoggingInfo))
|
if (!(entry.getValue() instanceof LoggingInfo))
|
||||||
|
|||||||
@@ -300,10 +300,6 @@ public class DefaultLauncher extends Launcher {
|
|||||||
throw new PermissionException();
|
throw new PermissionException();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startMonitors(ManagedProcess managedProcess, ProcessListener processListener) {
|
|
||||||
startMonitors(managedProcess, processListener, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void startMonitors(ManagedProcess managedProcess, ProcessListener processListener, boolean isDaemon) {
|
private void startMonitors(ManagedProcess managedProcess, ProcessListener processListener, boolean isDaemon) {
|
||||||
processListener.setProcess(managedProcess);
|
processListener.setProcess(managedProcess);
|
||||||
Thread stdout = Lang.thread(new StreamPump(managedProcess.getProcess().getInputStream(), it -> {
|
Thread stdout = Lang.thread(new StreamPump(managedProcess.getProcess().getInputStream(), it -> {
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ package org.jackhuang.hmcl.mod;
|
|||||||
|
|
||||||
import org.jackhuang.hmcl.task.Task;
|
import org.jackhuang.hmcl.task.Task;
|
||||||
import org.jackhuang.hmcl.util.FileUtils;
|
import org.jackhuang.hmcl.util.FileUtils;
|
||||||
import org.jackhuang.hmcl.util.IOUtils;
|
|
||||||
import org.jackhuang.hmcl.util.Unzipper;
|
import org.jackhuang.hmcl.util.Unzipper;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public interface ExceptionalRunnable<E extends Exception> {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
static ExceptionalRunnable fromRunnable(Runnable r) {
|
static ExceptionalRunnable<?> fromRunnable(Runnable r) {
|
||||||
return r::run;
|
return r::run;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
package org.jackhuang.hmcl.util;
|
package org.jackhuang.hmcl.util;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|||||||
@@ -67,8 +67,6 @@ public final class Zipper implements Closeable {
|
|||||||
* @param filter returns false if you do not want that file or directory
|
* @param filter returns false if you do not want that file or directory
|
||||||
*/
|
*/
|
||||||
public void putDirectory(Path source, String targetDir, Predicate<String> filter) throws IOException {
|
public void putDirectory(Path source, String targetDir, Predicate<String> filter) throws IOException {
|
||||||
File[] files = null;
|
|
||||||
|
|
||||||
Path root = fs.getPath(targetDir);
|
Path root = fs.getPath(targetDir);
|
||||||
Files.createDirectories(root);
|
Files.createDirectories(root);
|
||||||
Files.walkFileTree(source, new SimpleFileVisitor<Path>() {
|
Files.walkFileTree(source, new SimpleFileVisitor<Path>() {
|
||||||
|
|||||||
Reference in New Issue
Block a user