mirror of
https://github.com/GravitLauncher/Launcher
synced 2025-04-01 22:14:01 +03:00
idea cleanup lancher
This commit is contained in:
parent
a1fdc4cc39
commit
045ed67f12
12 changed files with 18 additions and 28 deletions
|
@ -7,7 +7,6 @@
|
|||
import pro.gravit.launcher.request.Request;
|
||||
import pro.gravit.launcher.request.RequestService;
|
||||
import pro.gravit.launcher.request.WebSocketEvent;
|
||||
import pro.gravit.launcher.request.websockets.ClientWebSocketService;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
public class BasicLauncherEventHandler implements RequestService.EventHandler {
|
||||
|
|
|
@ -140,7 +140,7 @@ public static void main(String[] arguments) throws IOException, InterruptedExcep
|
|||
if (context.memoryLimit != 0) {
|
||||
args.add(String.format("-Xmx%dM", context.memoryLimit));
|
||||
}
|
||||
if(customJvmOptions != null) {
|
||||
if (customJvmOptions != null) {
|
||||
args.addAll(customJvmOptions);
|
||||
}
|
||||
args.add("-cp");
|
||||
|
|
|
@ -246,14 +246,14 @@ public void start(String... args) throws Throwable {
|
|||
try {
|
||||
service = StdWebSocketService.initWebSockets(address).get();
|
||||
} catch (Throwable e) {
|
||||
if(LogHelper.isDebugEnabled()) {
|
||||
if (LogHelper.isDebugEnabled()) {
|
||||
LogHelper.error(e);
|
||||
}
|
||||
LogHelper.warning("Launcher in offline mode");
|
||||
service = initOffline();
|
||||
}
|
||||
Request.setRequestService(service);
|
||||
if(service instanceof StdWebSocketService) {
|
||||
if (service instanceof StdWebSocketService) {
|
||||
((StdWebSocketService) service).reconnectCallback = () ->
|
||||
{
|
||||
LogHelper.debug("WebSocket connect closed. Try reconnect");
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package pro.gravit.launcher.api;
|
||||
|
||||
import pro.gravit.launcher.LauncherEngine;
|
||||
import pro.gravit.launcher.profiles.ClientProfile;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
public class SystemService {
|
||||
private SystemService() {
|
||||
|
|
|
@ -121,7 +121,7 @@ public static void main(String[] args) throws Throwable {
|
|||
List<URL> classpathURLs = classpath.stream().map(IOHelper::toURL).collect(Collectors.toList());
|
||||
// Start client with WatchService monitoring
|
||||
RequestService service;
|
||||
if(params.offlineMode) {
|
||||
if (params.offlineMode) {
|
||||
service = initOffline(LauncherEngine.modulesManager, params);
|
||||
Request.setRequestService(service);
|
||||
} else {
|
||||
|
@ -231,13 +231,13 @@ public static RequestService initOffline(LauncherModulesManager modulesManager,
|
|||
|
||||
public static void applyClientOfflineProcessors(OfflineRequestService service, ClientLauncherProcess.ClientParams params) {
|
||||
service.registerRequestProcessor(ProfileByUsernameRequest.class, (r) -> {
|
||||
if(params.playerProfile.username.equals(r.username)) {
|
||||
if (params.playerProfile.username.equals(r.username)) {
|
||||
return new ProfileByUsernameRequestEvent(params.playerProfile);
|
||||
}
|
||||
throw new RequestException("User not found");
|
||||
});
|
||||
service.registerRequestProcessor(ProfileByUUIDRequest.class, (r) -> {
|
||||
if(params.playerProfile.uuid.equals(r.uuid)) {
|
||||
if (params.playerProfile.uuid.equals(r.uuid)) {
|
||||
return new ProfileByUUIDRequestEvent(params.playerProfile);
|
||||
}
|
||||
throw new RequestException("User not found");
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
import pro.gravit.launcher.Launcher;
|
||||
import pro.gravit.launcher.LauncherConfig;
|
||||
import pro.gravit.launcher.LauncherEngine;
|
||||
import pro.gravit.launcher.LauncherNetworkAPI;
|
||||
import pro.gravit.launcher.client.events.client.ClientProcessBuilderCreateEvent;
|
||||
import pro.gravit.launcher.client.events.client.ClientProcessBuilderLaunchedEvent;
|
||||
import pro.gravit.launcher.client.events.client.ClientProcessBuilderParamsWrittedEvent;
|
||||
|
@ -28,7 +27,6 @@
|
|||
import java.net.SocketAddress;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
@ -79,7 +77,7 @@ public ClientLauncherProcess(Path clientDir, Path assetDir, JavaHelper.JavaVersi
|
|||
this.params.resourcePackDir = resourcePackDir.toAbsolutePath().toString();
|
||||
this.params.assetDir = assetDir.toAbsolutePath().toString();
|
||||
Path nativesPath = workDir.resolve("natives").resolve(JVMHelper.OS_TYPE.name).resolve(javaVersion.arch.name);
|
||||
if(!Files.isDirectory(nativesPath)) {
|
||||
if (!Files.isDirectory(nativesPath)) {
|
||||
nativesPath = workDir.resolve("natives");
|
||||
}
|
||||
this.params.nativesDir = nativesPath.toString();
|
||||
|
@ -158,7 +156,7 @@ public void start(boolean pipeOutput) throws IOException, InterruptedException {
|
|||
.map(Path::toString)
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
if(Launcher.getConfig().environment != LauncherConfig.LauncherEnvironment.PROD) {
|
||||
if (Launcher.getConfig().environment != LauncherConfig.LauncherEnvironment.PROD) {
|
||||
processArgs.add(JVMHelper.jvmProperty(LogHelper.DEV_PROPERTY, String.valueOf(LogHelper.isDevEnabled())));
|
||||
processArgs.add(JVMHelper.jvmProperty(LogHelper.DEBUG_PROPERTY, String.valueOf(LogHelper.isDebugEnabled())));
|
||||
processArgs.add(JVMHelper.jvmProperty(LogHelper.STACKTRACE_PROPERTY, String.valueOf(LogHelper.isStacktraceEnabled())));
|
||||
|
@ -211,7 +209,7 @@ private void applyJava9Params(List<String> processArgs) {
|
|||
if (modulesAdd.length() > 0) modulesAdd.append(",");
|
||||
modulesAdd.append(moduleName);
|
||||
}
|
||||
for(String modulePath : jvmModulesPaths) {
|
||||
for (String modulePath : jvmModulesPaths) {
|
||||
if (modulesPath.length() > 0) modulesPath.append(File.pathSeparator);
|
||||
modulesPath.append(modulePath);
|
||||
}
|
||||
|
|
|
@ -163,7 +163,7 @@ private Result modernPing(HInput input, HOutput output) throws IOException {
|
|||
|
||||
// Parse JSON response
|
||||
JsonObject object = JsonParser.parseString(response).getAsJsonObject();
|
||||
if(object.has("error")) {
|
||||
if (object.has("error")) {
|
||||
throw new IOException(object.get("error").getAsString());
|
||||
}
|
||||
JsonObject playersObject = object.get("players").getAsJsonObject();
|
||||
|
|
|
@ -24,10 +24,10 @@ public String getUsageDescription() {
|
|||
|
||||
@Override
|
||||
public void invoke(String... args) throws Exception {
|
||||
for(LauncherModule module : LauncherEngine.modulesManager.getModules()) {
|
||||
for (LauncherModule module : LauncherEngine.modulesManager.getModules()) {
|
||||
LauncherModuleInfo info = module.getModuleInfo();
|
||||
LauncherTrustManager.CheckClassResult checkStatus = module.getCheckResult();
|
||||
if(!ConsoleManager.isConsoleUnlock) {
|
||||
if (!ConsoleManager.isConsoleUnlock) {
|
||||
LogHelper.info("[MODULE] %s v: %s", info.name, info.version.getVersionString());
|
||||
} else {
|
||||
LogHelper.info("[MODULE] %s v: %s p: %d deps: %s sig: %s", info.name, info.version.getVersionString(), info.priority, Arrays.toString(info.dependencies), checkStatus == null ? "null" : checkStatus.type);
|
||||
|
|
|
@ -57,7 +57,7 @@ public static void main(String[] args) throws Throwable {
|
|||
ConsoleManager.initConsole();
|
||||
LauncherEngine.modulesManager.invokeEvent(new PreConfigPhase());
|
||||
RequestService service;
|
||||
if(offlineMode) {
|
||||
if (offlineMode) {
|
||||
OfflineRequestService offlineRequestService = new OfflineRequestService();
|
||||
LauncherEngine.applyBasicOfflineProcessors(offlineRequestService);
|
||||
OfflineModeEvent event = new OfflineModeEvent(offlineRequestService);
|
||||
|
|
|
@ -18,7 +18,7 @@ public static void checkCertificatesSuccess(X509Certificate[] certs) throws Exce
|
|||
}
|
||||
|
||||
public static String findLibrary(ClassLoader classLoader, String library) {
|
||||
if(classLoader instanceof ClientClassLoader) {
|
||||
if (classLoader instanceof ClientClassLoader) {
|
||||
ClientClassLoader clientClassLoader = (ClientClassLoader) classLoader;
|
||||
return clientClassLoader.findLibrary(library);
|
||||
}
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
package pro.gravit.launcher.utils;
|
||||
|
||||
import pro.gravit.launcher.AsyncDownloader;
|
||||
import pro.gravit.launcher.Launcher;
|
||||
import pro.gravit.launcher.LauncherEngine;
|
||||
import pro.gravit.launcher.LauncherInject;
|
||||
import pro.gravit.launcher.events.request.LauncherRequestEvent;
|
||||
import pro.gravit.launcher.request.update.LauncherRequest;
|
||||
import pro.gravit.utils.helper.IOHelper;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
@ -13,12 +11,10 @@
|
|||
import javax.net.ssl.HttpsURLConnection;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardOpenOption;
|
||||
import java.security.KeyManagementException;
|
||||
import java.security.KeyStoreException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
@ -30,14 +26,16 @@
|
|||
public class LauncherUpdater {
|
||||
@LauncherInject("launcher.certificatePinning")
|
||||
private static boolean isCertificatePinning;
|
||||
|
||||
public static void nothing() {
|
||||
|
||||
}
|
||||
|
||||
private static Path getLauncherPath() {
|
||||
Path pathToCore = IOHelper.getCodeSource(IOHelper.class);
|
||||
Path pathToApi = IOHelper.getCodeSource(LauncherRequest.class);
|
||||
Path pathToSelf = IOHelper.getCodeSource(LauncherUpdater.class);
|
||||
if(pathToCore.equals(pathToApi) && pathToCore.equals(pathToSelf)) {
|
||||
if (pathToCore.equals(pathToApi) && pathToCore.equals(pathToSelf)) {
|
||||
return pathToCore;
|
||||
} else {
|
||||
throw new SecurityException("Found split-jar launcher");
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
package pro.gravit.launcher.utils;
|
||||
|
||||
import pro.gravit.utils.helper.JVMHelper;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
|
||||
public final class NativeJVMHalt {
|
||||
public final int haltCode;
|
||||
|
@ -30,7 +27,7 @@ public static void haltA(int code) {
|
|||
exitMethod.invoke(null, code);
|
||||
} catch (Throwable e) {
|
||||
th[1] = e;
|
||||
if(LogHelper.isDevEnabled()) {
|
||||
if (LogHelper.isDevEnabled()) {
|
||||
LogHelper.error(e);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue