mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-22 08:31:07 +03:00
[REFACTOR] IDEA mini refactor
This commit is contained in:
parent
dfbb6e507a
commit
e6516a8991
33 changed files with 75 additions and 148 deletions
|
@ -28,15 +28,12 @@
|
|||
import pro.gravit.utils.helper.IOHelper;
|
||||
import pro.gravit.utils.helper.JVMHelper;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
import pro.gravit.utils.launch.LaunchOptions;
|
||||
import pro.gravit.utils.launch.ModuleLaunch;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.security.Security;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class LaunchServerStarter {
|
||||
|
|
|
@ -1,13 +1,7 @@
|
|||
package pro.gravit.launchserver;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.instrument.Instrumentation;
|
||||
import java.nio.file.*;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
import java.nio.file.attribute.PosixFileAttributeView;
|
||||
import java.nio.file.attribute.PosixFilePermission;
|
||||
import java.util.*;
|
||||
import java.util.jar.JarFile;
|
||||
|
||||
public final class StarterAgent {
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ public static void getFeatures(Class<?> clazz, Set<String> list) {
|
|||
}
|
||||
}
|
||||
|
||||
public final <T> T isSupport(Class<T> clazz) {
|
||||
public <T> T isSupport(Class<T> clazz) {
|
||||
if (core == null) return null;
|
||||
T result = core.isSupport(clazz);
|
||||
if (result == null && mixes != null) {
|
||||
|
@ -71,7 +71,7 @@ public final <T> T isSupport(Class<T> clazz) {
|
|||
return result;
|
||||
}
|
||||
|
||||
public final void init(LaunchServer srv, String name) {
|
||||
public void init(LaunchServer srv, String name) {
|
||||
this.name = name;
|
||||
if (links != null) link(srv);
|
||||
core.init(srv);
|
||||
|
@ -85,7 +85,7 @@ public final void init(LaunchServer srv, String name) {
|
|||
}
|
||||
}
|
||||
|
||||
public final void link(LaunchServer srv) {
|
||||
public void link(LaunchServer srv) {
|
||||
links.forEach((k, v) -> {
|
||||
AuthProviderPair pair = srv.config.getAuthProviderPair(v);
|
||||
if (pair == null) {
|
||||
|
@ -99,7 +99,7 @@ public final void link(LaunchServer srv) {
|
|||
});
|
||||
}
|
||||
|
||||
public final void close() throws IOException {
|
||||
public void close() throws IOException {
|
||||
core.close();
|
||||
if (textureProvider != null) {
|
||||
textureProvider.close();
|
||||
|
|
|
@ -332,7 +332,7 @@ public String toString() {
|
|||
}
|
||||
}
|
||||
|
||||
public class MySQLUser extends SQLUser {
|
||||
public static class MySQLUser extends SQLUser {
|
||||
protected long hwidId;
|
||||
|
||||
public MySQLUser(UUID uuid, String username, String accessToken, String serverId, String password, ClientPermissions permissions, long hwidId) {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package pro.gravit.launchserver.auth.core.interfaces.provider;
|
||||
|
||||
import pro.gravit.launchserver.auth.core.User;
|
||||
import pro.gravit.launchserver.auth.core.UserSession;
|
||||
import pro.gravit.launchserver.socket.Client;
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ public boolean allowGetAccessToken(AuthResponse.AuthContext context) {
|
|||
|
||||
@Override
|
||||
public void init(LaunchServer server) {
|
||||
if (profileWhitelist != null && profileWhitelist.size() > 0) {
|
||||
if (profileWhitelist != null && !profileWhitelist.isEmpty()) {
|
||||
logger.warn("profileWhitelist deprecated. Please use permission 'launchserver.profile.PROFILE_UUID.show' and 'launchserver.profile.PROFILE_UUID.enter'");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,12 +7,10 @@
|
|||
import pro.gravit.utils.helper.IOHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
import pro.gravit.launchserver.LaunchServer;
|
||||
import pro.gravit.launchserver.binary.tasks.LauncherBuildTask;
|
||||
import pro.gravit.utils.Version;
|
||||
import pro.gravit.utils.helper.IOHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
|
|
|
@ -24,7 +24,7 @@ public SaveProfilesCommand(LaunchServer server) {
|
|||
|
||||
public static void saveProfile(ClientProfile profile, Path path) throws IOException {
|
||||
if (profile.getUUID() == null) profile.setUUID(UUID.randomUUID());
|
||||
if (profile.getServers().size() == 0) {
|
||||
if (profile.getServers().isEmpty()) {
|
||||
ClientProfile.ServerProfile serverProfile = new ClientProfile.ServerProfile();
|
||||
serverProfile.isDefault = true;
|
||||
serverProfile.name = profile.getTitle();
|
||||
|
|
|
@ -142,7 +142,7 @@ public void setEnv(LauncherConfig.LauncherEnvironment env) {
|
|||
}
|
||||
|
||||
public void verify() {
|
||||
if (auth == null || auth.size() < 1) {
|
||||
if (auth == null || auth.isEmpty()) {
|
||||
throw new NullPointerException("AuthProviderPair`s count should be at least one");
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
import pro.gravit.launcher.ClientPermissions;
|
||||
import pro.gravit.launcher.profiles.ClientProfile;
|
||||
import pro.gravit.launcher.request.secure.HardwareReportRequest;
|
||||
import pro.gravit.launchserver.LaunchServer;
|
||||
import pro.gravit.launchserver.auth.AuthProviderPair;
|
||||
import pro.gravit.launchserver.auth.core.interfaces.UserHardware;
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
import pro.gravit.launchserver.auth.AuthProviderPair;
|
||||
import pro.gravit.launchserver.auth.Feature;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class FeatureCollectionTest {
|
||||
public static class TestClass1 implements TextInterface1 {
|
||||
|
||||
|
|
|
@ -197,18 +197,18 @@ private void applyJava9Params(List<String> processArgs) {
|
|||
StringBuilder modulesPath = new StringBuilder();
|
||||
StringBuilder modulesAdd = new StringBuilder();
|
||||
for (String moduleName : jvmModules) {
|
||||
if (modulesAdd.length() > 0) modulesAdd.append(",");
|
||||
if (!modulesAdd.isEmpty()) modulesAdd.append(",");
|
||||
modulesAdd.append(moduleName);
|
||||
}
|
||||
for (String modulePath : jvmModulesPaths) {
|
||||
if (modulesPath.length() > 0) modulesPath.append(File.pathSeparator);
|
||||
if (!modulesPath.isEmpty()) modulesPath.append(File.pathSeparator);
|
||||
modulesPath.append(modulePath);
|
||||
}
|
||||
if (modulesAdd.length() > 0) {
|
||||
if (!modulesAdd.isEmpty()) {
|
||||
processArgs.add("--add-modules");
|
||||
processArgs.add(modulesAdd.toString());
|
||||
}
|
||||
if (modulesPath.length() > 0) {
|
||||
if (!modulesPath.isEmpty()) {
|
||||
processArgs.add("--module-path");
|
||||
processArgs.add(modulesPath.toString());
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ public int getProcessorLogicalCount() {
|
|||
|
||||
public boolean isBattery() {
|
||||
List<PowerSource> powerSources = hardware.getPowerSources();
|
||||
return powerSources != null && powerSources.size() != 0;
|
||||
return powerSources != null && !powerSources.isEmpty();
|
||||
}
|
||||
|
||||
//Hardware Information
|
||||
|
@ -93,7 +93,7 @@ public long getGraphicCardMemory() {
|
|||
|
||||
public byte[] getDisplayID() {
|
||||
List<Display> displays = hardware.getDisplays();
|
||||
if (displays == null || displays.size() == 0) return null;
|
||||
if (displays == null || displays.isEmpty()) return null;
|
||||
for (Display display : displays) {
|
||||
return display.getEdid();
|
||||
}
|
||||
|
|
|
@ -96,7 +96,7 @@ public LauncherConfig(String address, ECPublicKey ecdsaPublicKey, RSAPublicKey r
|
|||
this.address = address;
|
||||
this.ecdsaPublicKey = ecdsaPublicKey;
|
||||
this.rsaPublicKey = rsaPublicKey;
|
||||
this.runtime = Collections.unmodifiableMap(new HashMap<>(runtime));
|
||||
this.runtime = Map.copyOf(runtime);
|
||||
this.projectName = projectName;
|
||||
this.clientPort = 32148;
|
||||
environment = LauncherEnvironment.STD;
|
||||
|
@ -109,7 +109,7 @@ public LauncherConfig(String address, ECPublicKey ecdsaPublicKey, RSAPublicKey r
|
|||
|
||||
public LauncherConfig(String address, Map<String, byte[]> runtime, String projectName, LauncherEnvironment env, LauncherTrustManager trustManager) {
|
||||
this.address = address;
|
||||
this.runtime = Collections.unmodifiableMap(new HashMap<>(runtime));
|
||||
this.runtime = Map.copyOf(runtime);
|
||||
this.projectName = projectName;
|
||||
this.clientPort = 32148;
|
||||
this.trustManager = trustManager;
|
||||
|
|
|
@ -203,12 +203,12 @@ public static synchronized RequestRestoreReport restore(boolean needUserInfo, bo
|
|||
}
|
||||
RestoreRequestEvent event = request.request();
|
||||
List<String> invalidTokens = null;
|
||||
if (event.invalidTokens != null && event.invalidTokens.size() > 0) {
|
||||
if (event.invalidTokens != null && !event.invalidTokens.isEmpty()) {
|
||||
Map<String, String> tokens = makeNewTokens(event.invalidTokens);
|
||||
if (!tokens.isEmpty()) {
|
||||
request = new RestoreRequest(authId, null, tokens, false);
|
||||
event = request.request();
|
||||
if (event.invalidTokens != null && event.invalidTokens.size() > 0) {
|
||||
if (event.invalidTokens != null && !event.invalidTokens.isEmpty()) {
|
||||
LogHelper.warning("Tokens %s not restored", String.join(",", event.invalidTokens));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,8 +72,7 @@ public <T extends WebSocketEvent> void processEventHandlers(T event) {
|
|||
|
||||
@SuppressWarnings({"unchecked"})
|
||||
public <T extends WebSocketEvent> void eventHandle(T webSocketEvent) {
|
||||
if (webSocketEvent instanceof RequestEvent) {
|
||||
RequestEvent event = (RequestEvent) webSocketEvent;
|
||||
if (webSocketEvent instanceof RequestEvent event) {
|
||||
if (event.requestUUID == null) {
|
||||
LogHelper.warning("Request event type %s.requestUUID is null", event.getType() == null ? "null" : event.getType());
|
||||
return;
|
||||
|
|
|
@ -51,15 +51,13 @@ protected void channelRead0(ChannelHandlerContext ctx, Object msg) throws Except
|
|||
return;
|
||||
}
|
||||
|
||||
if (msg instanceof FullHttpResponse) {
|
||||
final FullHttpResponse response = (FullHttpResponse) msg;
|
||||
if (msg instanceof FullHttpResponse response) {
|
||||
throw new Exception("Unexpected FullHttpResponse (getStatus=" + response.status() + ", content="
|
||||
+ response.content().toString(CharsetUtil.UTF_8) + ')');
|
||||
}
|
||||
|
||||
final WebSocketFrame frame = (WebSocketFrame) msg;
|
||||
if (frame instanceof TextWebSocketFrame) {
|
||||
final TextWebSocketFrame textFrame = (TextWebSocketFrame) frame;
|
||||
if (frame instanceof TextWebSocketFrame textFrame) {
|
||||
if (LogHelper.isDevEnabled()) {
|
||||
LogHelper.dev("Message: %s", textFrame.text());
|
||||
}
|
||||
|
|
|
@ -28,8 +28,7 @@ public <T extends WebSocketEvent> boolean eventHandle(T event) {
|
|||
if (token != null) {
|
||||
Request.addExtendedToken(event1.getExtendedTokenName(), new Request.ExtendedToken(event1.getExtendedToken(), event1.getExtendedTokenExpire()));
|
||||
}
|
||||
} else if (event instanceof NotificationEvent) {
|
||||
NotificationEvent n = (NotificationEvent) event;
|
||||
} else if (event instanceof NotificationEvent n) {
|
||||
if (DialogService.isNotificationsAvailable()) {
|
||||
DialogService.createNotification(n.icon, n.head, n.message);
|
||||
}
|
||||
|
|
|
@ -78,20 +78,14 @@ private static CheckClassResultApi fromCheckClassResult(LauncherTrustManager.Che
|
|||
|
||||
private static CheckClassResultTypeApi fromType(LauncherTrustManager.CheckClassResultType type) {
|
||||
if (type == null) return null;
|
||||
switch (type) {
|
||||
case NOT_SIGNED:
|
||||
return CheckClassResultTypeApi.NOT_SIGNED;
|
||||
case SUCCESS:
|
||||
return CheckClassResultTypeApi.SUCCESS;
|
||||
case UNTRUSTED:
|
||||
return CheckClassResultTypeApi.UNTRUSTED;
|
||||
case UNVERIFED:
|
||||
return CheckClassResultTypeApi.UNVERIFED;
|
||||
case UNCOMPAT:
|
||||
return CheckClassResultTypeApi.UNCOMPAT;
|
||||
default:
|
||||
return CheckClassResultTypeApi.UNKNOWN;
|
||||
}
|
||||
return switch (type) {
|
||||
case NOT_SIGNED -> CheckClassResultTypeApi.NOT_SIGNED;
|
||||
case SUCCESS -> CheckClassResultTypeApi.SUCCESS;
|
||||
case UNTRUSTED -> CheckClassResultTypeApi.UNTRUSTED;
|
||||
case UNVERIFED -> CheckClassResultTypeApi.UNVERIFED;
|
||||
case UNCOMPAT -> CheckClassResultTypeApi.UNCOMPAT;
|
||||
default -> CheckClassResultTypeApi.UNKNOWN;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ public List<LauncherModule> getModules() {
|
|||
}
|
||||
|
||||
@Override
|
||||
public final boolean verifyClassCheckResult(LauncherTrustManager.CheckClassResult result) {
|
||||
public boolean verifyClassCheckResult(LauncherTrustManager.CheckClassResult result) {
|
||||
return result.type == LauncherTrustManager.CheckClassResultType.SUCCESS;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,16 +30,11 @@ public HashedDir(HInput input) throws IOException {
|
|||
// Read entry
|
||||
HashedEntry entry;
|
||||
Type type = Type.read(input);
|
||||
switch (type) {
|
||||
case FILE:
|
||||
entry = new HashedFile(input);
|
||||
break;
|
||||
case DIR:
|
||||
entry = new HashedDir(input);
|
||||
break;
|
||||
default:
|
||||
throw new AssertionError("Unsupported hashed entry type: " + type.name());
|
||||
}
|
||||
entry = switch (type) {
|
||||
case FILE -> new HashedFile(input);
|
||||
case DIR -> new HashedDir(input);
|
||||
default -> throw new AssertionError("Unsupported hashed entry type: " + type.name());
|
||||
};
|
||||
|
||||
// Try add entry to map
|
||||
VerifyHelper.putIfAbsent(map, name, entry, String.format("Duplicate dir entry: '%s'", name));
|
||||
|
|
|
@ -42,14 +42,11 @@ public BigInteger readBigInteger(int maxBytes) throws IOException {
|
|||
|
||||
public boolean readBoolean() throws IOException {
|
||||
int b = readUnsignedByte();
|
||||
switch (b) {
|
||||
case 0b0:
|
||||
return false;
|
||||
case 0b1:
|
||||
return true;
|
||||
default:
|
||||
throw new IOException("Invalid boolean state: " + b);
|
||||
}
|
||||
return switch (b) {
|
||||
case 0b0 -> false;
|
||||
case 0b1 -> true;
|
||||
default -> throw new IOException("Invalid boolean state: " + b);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ public static String[] parseCommand(CharSequence line) throws CommandException {
|
|||
throw new CommandException("Quotes wasn't closed");
|
||||
|
||||
// Empty args are ignored (except if was quoted)
|
||||
if (wasQuoted || builder.length() > 0)
|
||||
if (wasQuoted || !builder.isEmpty())
|
||||
result.add(builder.toString());
|
||||
|
||||
// Reset file builder
|
||||
|
|
|
@ -14,17 +14,12 @@ public class FormatHelper {
|
|||
public static Ansi rawAnsiFormat(LogHelper.Level level, String dateTime, boolean sub) {
|
||||
Ansi.Color levelColor;
|
||||
boolean bright = level != LogHelper.Level.DEBUG;
|
||||
switch (level) {
|
||||
case WARNING:
|
||||
levelColor = Ansi.Color.YELLOW;
|
||||
break;
|
||||
case ERROR:
|
||||
levelColor = Ansi.Color.RED;
|
||||
break;
|
||||
default: // INFO, DEBUG, Unknown
|
||||
levelColor = Ansi.Color.WHITE;
|
||||
break;
|
||||
}
|
||||
levelColor = switch (level) {
|
||||
case WARNING -> Ansi.Color.YELLOW;
|
||||
case ERROR -> Ansi.Color.RED;
|
||||
default -> // INFO, DEBUG, Unknown
|
||||
Ansi.Color.WHITE;
|
||||
};
|
||||
|
||||
// Date-time
|
||||
Ansi ansi = new Ansi();
|
||||
|
|
|
@ -3,8 +3,6 @@
|
|||
import java.lang.invoke.MethodHandles;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Arrays;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class HackHelper {
|
||||
private static native MethodHandles.Lookup createHackLookupNative(Class<?> lookupClass);
|
||||
|
|
|
@ -138,17 +138,13 @@ public static String getIP(SocketAddress address) {
|
|||
}
|
||||
|
||||
public static Path getRoot() {
|
||||
switch (JVMHelper.OS_TYPE) {
|
||||
case MUSTDIE: {
|
||||
return switch (JVMHelper.OS_TYPE) {
|
||||
case MUSTDIE -> {
|
||||
String drive = System.getenv("SystemDrive").concat("\\");
|
||||
return Paths.get(drive);
|
||||
yield Paths.get(drive);
|
||||
}
|
||||
case LINUX:
|
||||
case MACOSX: {
|
||||
return Paths.get("/");
|
||||
}
|
||||
}
|
||||
throw new UnsupportedOperationException();
|
||||
case LINUX, MACOSX -> Paths.get("/");
|
||||
};
|
||||
}
|
||||
|
||||
public static byte[] getResourceBytes(String name) throws IOException {
|
||||
|
@ -545,19 +541,11 @@ public static void transfer(Path file, OutputStream output) throws IOException {
|
|||
}
|
||||
|
||||
public static String urlDecode(String s) {
|
||||
try {
|
||||
return URLDecoder.decode(s, UNICODE_CHARSET.name());
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new InternalError(e);
|
||||
}
|
||||
return URLDecoder.decode(s, UNICODE_CHARSET);
|
||||
}
|
||||
|
||||
public static String urlEncode(String s) {
|
||||
try {
|
||||
return URLEncoder.encode(s, UNICODE_CHARSET.name());
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new InternalError(e);
|
||||
}
|
||||
return URLEncoder.encode(s, UNICODE_CHARSET);
|
||||
}
|
||||
|
||||
public static String verifyFileName(String fileName) {
|
||||
|
|
|
@ -62,26 +62,19 @@ public static int getBuild() {
|
|||
}
|
||||
|
||||
public static String getNativeExtension(JVMHelper.OS OS_TYPE) {
|
||||
switch (OS_TYPE) {
|
||||
case MUSTDIE:
|
||||
return ".dll";
|
||||
case LINUX:
|
||||
return ".so";
|
||||
case MACOSX:
|
||||
return ".dylib";
|
||||
default:
|
||||
throw new InternalError(String.format("Unsupported OS TYPE '%s'", OS_TYPE));
|
||||
}
|
||||
return switch (OS_TYPE) {
|
||||
case MUSTDIE -> ".dll";
|
||||
case LINUX -> ".so";
|
||||
case MACOSX -> ".dylib";
|
||||
default -> throw new InternalError(String.format("Unsupported OS TYPE '%s'", OS_TYPE));
|
||||
};
|
||||
}
|
||||
|
||||
public static String getNativePrefix(JVMHelper.OS OS_TYPE) {
|
||||
switch (OS_TYPE) {
|
||||
case LINUX:
|
||||
case MACOSX:
|
||||
return "lib";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
return switch (OS_TYPE) {
|
||||
case LINUX, MACOSX -> "lib";
|
||||
default -> "";
|
||||
};
|
||||
}
|
||||
|
||||
public static void appendVars(ProcessBuilder builder, Map<String, String> vars) {
|
||||
|
|
|
@ -13,15 +13,7 @@ public class JavaHelper {
|
|||
public static final List<String> javaFxModules;
|
||||
|
||||
static {
|
||||
List<String> modules = new ArrayList<>();
|
||||
modules.add("javafx.base");
|
||||
modules.add("javafx.graphics");
|
||||
modules.add("javafx.fxml");
|
||||
modules.add("javafx.controls");
|
||||
modules.add("javafx.swing");
|
||||
modules.add("javafx.media");
|
||||
modules.add("javafx.web");
|
||||
javaFxModules = Collections.unmodifiableList(modules);
|
||||
javaFxModules = List.of("javafx.base", "javafx.graphics", "javafx.fxml", "javafx.controls", "javafx.swing", "javafx.media", "javafx.web");
|
||||
}
|
||||
|
||||
public static Path tryGetOpenJFXPath(Path jvmDir) {
|
||||
|
@ -60,7 +52,7 @@ public static boolean tryAddModule(List<Path> paths, String moduleName, StringBu
|
|||
if (path == null) continue;
|
||||
Path result = tryFindModule(path, moduleName);
|
||||
if (result != null) {
|
||||
if (args.length() != 0) args.append(File.pathSeparatorChar);
|
||||
if (!args.isEmpty()) args.append(File.pathSeparatorChar);
|
||||
args.append(result.toAbsolutePath());
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -78,9 +78,7 @@ public static Downloader downloadFile(URI uri, Path path, ExecutorService execut
|
|||
downloader.future = downloader.downloadFile(uri, path);
|
||||
if (closeExecutor) {
|
||||
ExecutorService finalExecutor = executor;
|
||||
downloader.future = downloader.future.thenAccept((e) -> {
|
||||
finalExecutor.shutdownNow();
|
||||
}).exceptionallyCompose((ex) -> {
|
||||
downloader.future = downloader.future.thenAccept((e) -> finalExecutor.shutdownNow()).exceptionallyCompose((ex) -> {
|
||||
finalExecutor.shutdownNow();
|
||||
return CompletableFuture.failedFuture(ex);
|
||||
});
|
||||
|
@ -99,9 +97,7 @@ public static Downloader downloadList(List<SizedFile> files, String baseURL, Pat
|
|||
downloader.future = downloader.downloadFiles(files, baseURL, targetDir, callback, executor, threads);
|
||||
if (closeExecutor) {
|
||||
ExecutorService finalExecutor = executor;
|
||||
downloader.future = downloader.future.thenAccept((e) -> {
|
||||
finalExecutor.shutdownNow();
|
||||
}).exceptionallyCompose((ex) -> {
|
||||
downloader.future = downloader.future.thenAccept((e) -> finalExecutor.shutdownNow()).exceptionallyCompose((ex) -> {
|
||||
finalExecutor.shutdownNow();
|
||||
return CompletableFuture.failedFuture(ex);
|
||||
});
|
||||
|
|
|
@ -34,7 +34,7 @@ public List<LauncherModule> getModules() {
|
|||
}
|
||||
|
||||
@Override
|
||||
public final boolean verifyClassCheckResult(LauncherTrustManager.CheckClassResult result) {
|
||||
public boolean verifyClassCheckResult(LauncherTrustManager.CheckClassResult result) {
|
||||
return result.type == LauncherTrustManager.CheckClassResultType.SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
@ -122,8 +122,7 @@ public void run(String... args) throws Throwable {
|
|||
LogHelper.debug("Read ServerWrapperConfig.json");
|
||||
loadConfig();
|
||||
updateLauncherConfig();
|
||||
if (config.env != null) Launcher.applyLauncherEnv(config.env);
|
||||
else Launcher.applyLauncherEnv(LauncherConfig.LauncherEnvironment.STD);
|
||||
Launcher.applyLauncherEnv(Objects.requireNonNullElse(config.env, LauncherConfig.LauncherEnvironment.STD));
|
||||
StdWebSocketService service = StdWebSocketService.initWebSockets(config.address).get();
|
||||
service.reconnectCallback = () ->
|
||||
{
|
||||
|
@ -153,7 +152,7 @@ public void run(String... args) throws Throwable {
|
|||
KeyService.serverEcPublicKey = SecurityHelper.toPublicECDSAKey(config.encodedServerEcPublicKey);
|
||||
}
|
||||
String classname = (config.mainclass == null || config.mainclass.isEmpty()) ? args[0] : config.mainclass;
|
||||
if (classname.length() == 0) {
|
||||
if (classname.isEmpty()) {
|
||||
LogHelper.error("MainClass not found. Please set MainClass for ServerWrapper.json or first commandline argument");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
@ -174,7 +173,7 @@ public void run(String... args) throws Throwable {
|
|||
LogHelper.info("ServerWrapper: LaunchServer address: %s. Title: %s", config.address, Launcher.profile != null ? Launcher.profile.getTitle() : "unknown");
|
||||
LogHelper.info("Minecraft Version (for profile): %s", wrapper.profile == null ? "unknown" : wrapper.profile.getVersion().toString());
|
||||
String[] real_args;
|
||||
if(config.args != null && config.args.size() > 0) {
|
||||
if(config.args != null && !config.args.isEmpty()) {
|
||||
real_args = config.args.toArray(new String[0]);
|
||||
} else if (args.length > 0) {
|
||||
real_args = new String[args.length - 1];
|
||||
|
|
|
@ -41,10 +41,10 @@ public void run(String... args) throws Exception {
|
|||
}
|
||||
context.workdir = IOHelper.WORKING_DIR;
|
||||
LogHelper.info("Search .jar files in %s", context.workdir.toAbsolutePath());
|
||||
IOHelper.walk(context.workdir, new SimpleFileVisitor<Path>() {
|
||||
IOHelper.walk(context.workdir, new SimpleFileVisitor<>() {
|
||||
@Override
|
||||
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
|
||||
if(file.getFileName().toString().endsWith(".jar")) {
|
||||
if (file.getFileName().toString().endsWith(".jar")) {
|
||||
context.files.add(file);
|
||||
}
|
||||
return FileVisitResult.CONTINUE;
|
||||
|
|
Loading…
Reference in a new issue