clean up HMCLCore
This commit is contained in:
@@ -28,22 +28,22 @@ public final class AccountBuilder<T extends Account> {
|
||||
public AccountBuilder() {
|
||||
}
|
||||
|
||||
public AccountBuilder setSelector(CharacterSelector selector) {
|
||||
public AccountBuilder<T> setSelector(CharacterSelector selector) {
|
||||
this.selector = Objects.requireNonNull(selector);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AccountBuilder setUsername(String username) {
|
||||
public AccountBuilder<T> setUsername(String username) {
|
||||
this.username = Objects.requireNonNull(username);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AccountBuilder setPassword(String password) {
|
||||
public AccountBuilder<T> setPassword(String password) {
|
||||
this.password = password;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AccountBuilder setAdditionalData(Object additionalData) {
|
||||
public AccountBuilder<T> setAdditionalData(Object additionalData) {
|
||||
this.additionalData = additionalData;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -28,16 +28,12 @@ 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;
|
||||
|
||||
import static org.jackhuang.hmcl.util.DigestUtils.digest;
|
||||
import static org.jackhuang.hmcl.util.Hex.encodeHex;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author huangyuhui
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
package org.jackhuang.hmcl.download.game;
|
||||
|
||||
import org.jackhuang.hmcl.download.DownloadProvider;
|
||||
import org.jackhuang.hmcl.download.RemoteVersion;
|
||||
import org.jackhuang.hmcl.download.VersionList;
|
||||
import org.jackhuang.hmcl.task.GetTask;
|
||||
import org.jackhuang.hmcl.task.Task;
|
||||
|
||||
@@ -14,8 +14,6 @@ import org.tukaani.xz.XZInputStream;
|
||||
import java.io.*;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.*;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarInputStream;
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
package org.jackhuang.hmcl.event;
|
||||
|
||||
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.
|
||||
|
||||
@@ -47,7 +47,7 @@ public final class LibrariesDownloadInfo {
|
||||
}
|
||||
|
||||
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() {
|
||||
return logging == null ? Collections.EMPTY_MAP : Collections.unmodifiableMap(logging);
|
||||
return logging == null ? Collections.emptyMap() : Collections.unmodifiableMap(logging);
|
||||
}
|
||||
|
||||
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() {
|
||||
return compatibilityRules == null ? Collections.EMPTY_LIST : Collections.unmodifiableList(compatibilityRules);
|
||||
return compatibilityRules == null ? Collections.emptyList() : Collections.unmodifiableList(compatibilityRules);
|
||||
}
|
||||
|
||||
public DownloadInfo getDownloadInfo() {
|
||||
@@ -247,14 +247,14 @@ public class Version implements Comparable<Version>, Validation {
|
||||
if (StringUtils.isBlank(id))
|
||||
throw new JsonParseException("Version ID cannot be blank");
|
||||
if (downloads != null)
|
||||
for (Map.Entry entry : downloads.entrySet()) {
|
||||
for (Map.Entry<DownloadType, DownloadInfo> entry : downloads.entrySet()) {
|
||||
if (!(entry.getKey() instanceof DownloadType))
|
||||
throw new JsonParseException("Version downloads key must be DownloadType");
|
||||
if (!(entry.getValue() instanceof DownloadInfo))
|
||||
throw new JsonParseException("Version downloads value must be DownloadInfo");
|
||||
}
|
||||
if (logging != null)
|
||||
for (Map.Entry entry : logging.entrySet()) {
|
||||
for (Map.Entry<DownloadType, LoggingInfo> entry : logging.entrySet()) {
|
||||
if (!(entry.getKey() instanceof DownloadType))
|
||||
throw new JsonParseException("Version logging key must be DownloadType");
|
||||
if (!(entry.getValue() instanceof LoggingInfo))
|
||||
|
||||
@@ -300,10 +300,6 @@ public class DefaultLauncher extends Launcher {
|
||||
throw new PermissionException();
|
||||
}
|
||||
|
||||
private void startMonitors(ManagedProcess managedProcess, ProcessListener processListener) {
|
||||
startMonitors(managedProcess, processListener, true);
|
||||
}
|
||||
|
||||
private void startMonitors(ManagedProcess managedProcess, ProcessListener processListener, boolean isDaemon) {
|
||||
processListener.setProcess(managedProcess);
|
||||
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.util.FileUtils;
|
||||
import org.jackhuang.hmcl.util.IOUtils;
|
||||
import org.jackhuang.hmcl.util.Unzipper;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
package org.jackhuang.hmcl.util;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
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
|
||||
*/
|
||||
public void putDirectory(Path source, String targetDir, Predicate<String> filter) throws IOException {
|
||||
File[] files = null;
|
||||
|
||||
Path root = fs.getPath(targetDir);
|
||||
Files.createDirectories(root);
|
||||
Files.walkFileTree(source, new SimpleFileVisitor<Path>() {
|
||||
|
||||
Reference in New Issue
Block a user