diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 00000000..fa9a842f --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,37 @@ +image: java:8-jdk + +stages: + - build + - test + - deploy + +before_script: + # - echo `pwd` # debug + # - echo "$CI_BUILD_NAME, $CI_BUILD_REF_NAME $CI_BUILD_STAGE" # debug + - export GRADLE_USER_HOME=`pwd`/.gradle + +cache: + paths: + - .gradle/wrapper + - .gradle/caches + +build: + stage: build + script: + - sed -i 's/git@github.com:/https:\/\/github.com\//' .gitmodules + - git submodule sync + - git submodule update --init --recursive + - ./gradlew assemble + artifacts: + paths: + - LaunchServer/build/libs/*.jar + - ServerWrapper/build/libs/*.jar + expire_in: 1 week + +test: + stage: test + script: + - ./gradlew check + +after_script: + - echo "End CI" diff --git a/.travis.yml b/.travis.yml index 5c5057c5..9ce4fe87 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,4 +16,4 @@ cache: - $HOME/.gradle/caches/ - $HOME/.gradle/wrapper/ script: - - ./gradlew build + - ./gradlew build diff --git a/LaunchServer/build.gradle b/LaunchServer/build.gradle index 7787dd61..d090969f 100644 --- a/LaunchServer/build.gradle +++ b/LaunchServer/build.gradle @@ -44,13 +44,15 @@ pack project(':libLauncher') pack project(':LauncherAPI') bundle project(':Radon') - bundle 'mysql:mysql-connector-java:8.0.13' - bundle 'jline:jline:2.14.6' - bundle 'net.sf.proguard:proguard-base:6.0.3' - bundle 'org.fusesource.jansi:jansi:1.17.1' + bundle 'mysql:mysql-connector-java:8.0.16' + bundle 'org.jline:jline:3.11.0' + bundle 'org.jline:jline-reader:3.11.0' + bundle 'org.jline:jline-terminal:3.11.0' + bundle 'net.sf.proguard:proguard-base:6.1.0' + bundle 'org.fusesource.jansi:jansi:1.18' bundle 'commons-io:commons-io:2.6' - bundle 'commons-codec:commons-codec:1.11' - bundle 'org.javassist:javassist:3.24.1-GA' + bundle 'commons-codec:commons-codec:1.12' + bundle 'org.javassist:javassist:3.25.0-GA' bundle 'io.netty:netty-all:4.1.36.Final' bundle 'org.slf4j:slf4j-simple:1.7.25' @@ -79,8 +81,8 @@ bundle project(':Radon') } compileOnlyA 'com.google.guava:guava:26.0-jre' - compileOnlyA 'log4j:log4j:1.2.17' // Do not update (laggy dep). - compileOnlyA 'org.apache.logging.log4j:log4j-core:2.11.2' + compileOnlyA 'log4j:log4j:1.2.17' // Do not update (laggy dep). + compileOnlyA 'org.apache.logging.log4j:log4j-core:2.11.2' } task hikari(type: Copy) { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java index 0062d39e..51743f7d 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java @@ -4,6 +4,7 @@ import ru.gravit.launcher.Launcher; import ru.gravit.launcher.LauncherConfig; import ru.gravit.launcher.NeedGarbageCollection; +import ru.gravit.launcher.config.JsonConfigurable; import ru.gravit.launcher.hasher.HashedDir; import ru.gravit.launcher.managers.ConfigManager; import ru.gravit.launcher.managers.GarbageManager; @@ -38,7 +39,6 @@ import ru.gravit.utils.command.CommandHandler; import ru.gravit.utils.command.JLineCommandHandler; import ru.gravit.utils.command.StdCommandHandler; -import ru.gravit.launcher.config.JsonConfigurable; import ru.gravit.utils.helper.*; import java.io.*; @@ -81,7 +81,7 @@ public static final class Config { public String[] mirrors; public String binaryName; - + public boolean copyBinaries = true; public LauncherConfig.LauncherEnvironment env; @@ -200,8 +200,8 @@ public void verify() { throw new NullPointerException("Netty must not be null"); } } - public void init() - { + + public void init() { Launcher.applyLauncherEnv(env); for (AuthProviderPair provider : auth) { provider.init(); @@ -212,8 +212,7 @@ public void init() protectHandler.checkLaunchServerLicense(); } LaunchServer.server.registerObject("permissionsHandler", permissionsHandler); - for (int i = 0; i < auth.length; ++i) { - AuthProviderPair pair = auth[i]; + for (AuthProviderPair pair : auth) { LaunchServer.server.registerObject("auth.".concat(pair.name).concat(".provider"), pair.provider); LaunchServer.server.registerObject("auth.".concat(pair.name).concat(".handler"), pair.handler); LaunchServer.server.registerObject("auth.".concat(pair.name).concat(".texture"), pair.textureProvider); @@ -225,14 +224,12 @@ public void init() public void close() { try { LaunchServer.server.unregisterObject("permissionsHandler", permissionsHandler); - for (int i = 0; i < auth.length; ++i) { - AuthProviderPair pair = auth[i]; + for (AuthProviderPair pair : auth) { LaunchServer.server.unregisterObject("auth.".concat(pair.name).concat(".provider"), pair.provider); LaunchServer.server.unregisterObject("auth.".concat(pair.name).concat(".handler"), pair.handler); LaunchServer.server.unregisterObject("auth.".concat(pair.name).concat(".texture"), pair.textureProvider); } - } catch (Exception e) - { + } catch (Exception e) { LogHelper.error(e); } try { @@ -267,14 +264,14 @@ public static class ExeConf { public String txtProductVersion; } - public class LauncherConf - { + public class LauncherConf { public String guardType; } public class NettyConfig { public boolean fileServerEnabled; public boolean sendExceptionEnabled; + public boolean ipForwarding; public String launcherURL; public String downloadURL; public String launcherEXEURL; @@ -285,13 +282,13 @@ public class NettyConfig { public LogLevel logLevel = LogLevel.DEBUG; public NettyProxyConfig proxy = new NettyProxyConfig(); } - public class NettyPerformanceConfig - { + + public class NettyPerformanceConfig { public int bossThread; public int workerThread; } - public class NettyProxyConfig - { + + public class NettyProxyConfig { public boolean enabled; public String address = "ws://localhost:9275/api"; public String login = "login"; @@ -299,8 +296,8 @@ public class NettyProxyConfig public String auth_id = "std"; public ArrayList requests = new ArrayList<>(); } - public class NettyBindAddress - { + + public class NettyBindAddress { public String address; public int port; @@ -347,8 +344,8 @@ public static void main(String... args) throws Throwable { LogHelper.printVersion("LaunchServer"); LogHelper.printLicense("LaunchServer"); if (!StarterAgent.isAgentStarted()) { - LogHelper.error("StarterAgent is not started!"); - LogHelper.error("Your should add to JVM options this option: `-javaagent:LaunchServer.jar`"); + LogHelper.error("StarterAgent is not started!"); + LogHelper.error("Your should add to JVM options this option: `-javaagent:LaunchServer.jar`"); } // Start LaunchServer @@ -372,7 +369,7 @@ public static void main(String... args) throws Throwable { public final Path dir; - public final boolean testEnv; + public final boolean testEnv; public final Path launcherLibraries; @@ -479,16 +476,16 @@ public LaunchServer(Path dir, boolean testEnv, String[] args) throws IOException if (testEnv) localCommandHandler = new StdCommandHandler(false); else - try { - Class.forName("jline.Terminal"); + try { + Class.forName("org.jline.terminal.Terminal"); - // JLine2 available - localCommandHandler = new JLineCommandHandler(); - LogHelper.info("JLine2 terminal enabled"); - } catch (ClassNotFoundException ignored) { - localCommandHandler = new StdCommandHandler(true); - LogHelper.warning("JLine2 isn't in classpath, using std"); - } + // JLine2 available + localCommandHandler = new JLineCommandHandler(); + LogHelper.info("JLine2 terminal enabled"); + } catch (ClassNotFoundException ignored) { + localCommandHandler = new StdCommandHandler(true); + LogHelper.warning("JLine2 isn't in classpath, using std"); + } ru.gravit.launchserver.command.handler.CommandHandler.registerCommands(localCommandHandler); commandHandler = localCommandHandler; @@ -531,14 +528,11 @@ public LaunchServer(Path dir, boolean testEnv, String[] args) throws IOException try (BufferedReader reader = IOHelper.newReader(configFile)) { config = Launcher.gsonManager.gson.fromJson(reader, Config.class); } - if(!Files.exists(runtimeConfigFile)) - { + if (!Files.exists(runtimeConfigFile)) { LogHelper.info("Reset LaunchServer runtime config file"); runtime = new LaunchServerRuntimeConfig(); runtime.reset(); - } - else - { + } else { LogHelper.info("Reading LaunchServer runtime config file"); try (BufferedReader reader = IOHelper.newReader(runtimeConfigFile)) { runtime = Launcher.gsonManager.gson.fromJson(reader, LaunchServerRuntimeConfig.class); @@ -643,14 +637,14 @@ public static void initGson() { } private LauncherBinary binary() { - if (launcherEXEBinaryClass != null) { - try { - return launcherEXEBinaryClass.getConstructor(LaunchServer.class).newInstance(this); - } catch (InstantiationException | IllegalAccessException | IllegalArgumentException - | InvocationTargetException | NoSuchMethodException | SecurityException e) { - LogHelper.error(e); - } - } + if (launcherEXEBinaryClass != null) { + try { + return launcherEXEBinaryClass.getConstructor(LaunchServer.class).newInstance(this); + } catch (InstantiationException | IllegalAccessException | IllegalArgumentException + | InvocationTargetException | NoSuchMethodException | SecurityException e) { + LogHelper.error(e); + } + } try { Class.forName("net.sf.launch4j.Builder"); if (config.launch4j.enabled) return new EXEL4JLauncherBinary(this); @@ -673,10 +667,8 @@ public void close() { config.close(); modulesManager.close(); LogHelper.info("Save LaunchServer runtime config"); - try(Writer writer = IOHelper.newWriter(runtimeConfigFile)) - { - if(Launcher.gsonManager.configGson != null) - { + try (Writer writer = IOHelper.newWriter(runtimeConfigFile)) { + if (Launcher.gsonManager.configGson != null) { Launcher.gsonManager.configGson.toJson(runtime, writer); } else { LogHelper.error("Error writing LaunchServer runtime config file. Gson is null"); @@ -725,7 +717,7 @@ private void generateConfigIfNotExists(boolean testEnv) throws IOException { newConfig.netty = new NettyConfig(); newConfig.netty.fileServerEnabled = true; - newConfig.netty.binds = new NettyBindAddress[]{ new NettyBindAddress("0.0.0.0", 9274) }; + newConfig.netty.binds = new NettyBindAddress[]{new NettyBindAddress("0.0.0.0", 9274)}; newConfig.netty.performance = new NettyPerformanceConfig(); newConfig.netty.performance.bossThread = 2; newConfig.netty.performance.workerThread = 8; @@ -753,25 +745,23 @@ private void generateConfigIfNotExists(boolean testEnv) throws IOException { // Set server address String address; if (testEnv) { - address = "localhost"; - newConfig.setProjectName("test"); + address = "localhost"; + newConfig.setProjectName("test"); } else { - System.out.println("LaunchServer address(default: localhost): "); - address = commandHandler.readLine(); - System.out.println("LaunchServer projectName: "); - newConfig.setProjectName(commandHandler.readLine()); + System.out.println("LaunchServer address(default: localhost): "); + address = commandHandler.readLine(); + System.out.println("LaunchServer projectName: "); + newConfig.setProjectName(commandHandler.readLine()); } - if(address == null || address.isEmpty()) - { + if (address == null || address.isEmpty()) { LogHelper.error("Address null. Using localhost"); address = "localhost"; } - if(newConfig.projectName == null || newConfig.projectName.isEmpty()) - { + if (newConfig.projectName == null || newConfig.projectName.isEmpty()) { LogHelper.error("ProjectName null. Using MineCraft"); newConfig.projectName = "MineCraft"; } - + newConfig.legacyAddress = address; newConfig.netty.address = "ws://" + address + ":9274/api"; newConfig.netty.downloadURL = "http://" + address + ":9274/%dirname%/"; @@ -821,8 +811,8 @@ public void run() { // Add shutdown hook, then start LaunchServer if (!this.testEnv) { - JVMHelper.RUNTIME.addShutdownHook(CommonHelper.newThread(null, false, this::close)); - CommonHelper.newThread("Command Thread", true, commandHandler).start(); + JVMHelper.RUNTIME.addShutdownHook(CommonHelper.newThread(null, false, this::close)); + CommonHelper.newThread("Command Thread", true, commandHandler).start(); } rebindServerSocket(); if (config.netty != null) @@ -868,7 +858,8 @@ public void syncUpdatesDir(Collection dirs) throws IOException { // Resolve name and verify is dir String name = IOHelper.getFileName(updateDir); if (!IOHelper.isDir(updateDir)) { - if (!IOHelper.isFile(updateDir) && Arrays.asList(".jar", ".exe", ".hash").stream().noneMatch(e -> updateDir.toString().endsWith(e))) LogHelper.warning("Not update dir: '%s'", name); + if (!IOHelper.isFile(updateDir) && Arrays.asList(".jar", ".exe", ".hash").stream().noneMatch(e -> updateDir.toString().endsWith(e))) + LogHelper.warning("Not update dir: '%s'", name); continue; } @@ -919,6 +910,7 @@ public void registerObject(String name, Object object) { } } + public void unregisterObject(String name, Object object) { if (object instanceof Reloadable) { reloadManager.unregisterReloadable(name); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/StarterAgent.java b/LaunchServer/src/main/java/ru/gravit/launchserver/StarterAgent.java index dc8b7457..510d7342 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/StarterAgent.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/StarterAgent.java @@ -15,31 +15,34 @@ public final class StarterAgent { private static final class StarterVisitor extends SimpleFileVisitor { - private static final Set DPERMS; - static { - Set perms = new HashSet<>(Arrays.asList(PosixFilePermission.values())); - perms.remove(PosixFilePermission.OTHERS_WRITE); - perms.remove(PosixFilePermission.GROUP_WRITE); - DPERMS = Collections.unmodifiableSet(perms); - } + private static final Set DPERMS; + + static { + Set perms = new HashSet<>(Arrays.asList(PosixFilePermission.values())); + perms.remove(PosixFilePermission.OTHERS_WRITE); + perms.remove(PosixFilePermission.GROUP_WRITE); + DPERMS = Collections.unmodifiableSet(perms); + } private final Path filef; - private final boolean fixLib; + private final boolean fixLib; - private StarterVisitor() { + private StarterVisitor() { this.filef = StarterAgent.libraries.resolve(".libraries_chmoded"); this.fixLib = !Files.exists(filef) && !Boolean.getBoolean("launcher.noLibrariesPosixPermsFix"); if (fixLib) { - try { - Files.deleteIfExists(filef); - Files.createFile(filef); - } catch (Throwable t) { } + try { + Files.deleteIfExists(filef); + Files.createFile(filef); + } catch (Throwable ignored) { + } } } @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { - if (fixLib && Files.getFileAttributeView(file, PosixFileAttributeView.class) != null) Files.setPosixFilePermissions(file, DPERMS); + if (fixLib && Files.getFileAttributeView(file, PosixFileAttributeView.class) != null) + Files.setPosixFilePermissions(file, DPERMS); if (file.toFile().getName().endsWith(".jar")) inst.appendToSystemClassLoaderSearch(new JarFile(file.toFile())); return super.visitFile(file, attrs); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/JsonAuthHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/JsonAuthHandler.java index f14fa1b4..34d099ef 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/JsonAuthHandler.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/JsonAuthHandler.java @@ -11,24 +11,24 @@ public class JsonAuthHandler extends CachedAuthHandler { public URL getUrl; public URL updateAuthUrl; public URL updateServerIdUrl; - public class EntryRequestByUsername - { + + public class EntryRequestByUsername { public String username; public EntryRequestByUsername(String username) { this.username = username; } } - public class EntryRequestByUUID - { + + public class EntryRequestByUUID { public UUID uuid; public EntryRequestByUUID(UUID uuid) { this.uuid = uuid; } } - public class UpdateAuthRequest - { + + public class UpdateAuthRequest { public UUID uuid; public String username; public String accessToken; @@ -39,8 +39,8 @@ public UpdateAuthRequest(UUID uuid, String username, String accessToken) { this.accessToken = accessToken; } } - public class UpdateServerIDRequest - { + + public class UpdateServerIDRequest { public UUID uuid; public String serverID; @@ -49,10 +49,11 @@ public UpdateServerIDRequest(UUID uuid, String serverID) { this.serverID = serverID; } } - public class SuccessResponse - { + + public class SuccessResponse { public boolean success; } + @Override protected Entry fetchEntry(String username) throws IOException { return Launcher.gsonManager.configGson.fromJson(HTTPRequest.jsonRequest(Launcher.gsonManager.configGson.toJsonTree(new EntryRequestByUsername(username)), getUrl), Entry.class); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/RequestAuthHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/RequestAuthHandler.java index 5b7a1152..e04c63ed 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/RequestAuthHandler.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/RequestAuthHandler.java @@ -38,10 +38,10 @@ protected Entry fetchEntry(UUID uuid) throws IOException { String accessToken = parts[1]; String serverID = parts[2]; if (LogHelper.isDebugEnabled()) { - LogHelper.debug("[AuthHandler] Got username: " + username); - LogHelper.debug("[AuthHandler] Got accessToken: " + accessToken); - LogHelper.debug("[AuthHandler] Got serverID: " + serverID); - LogHelper.debug("[AuthHandler] Got UUID: " + uuid); + LogHelper.debug("[AuthHandler] Got username: " + username); + LogHelper.debug("[AuthHandler] Got accessToken: " + accessToken); + LogHelper.debug("[AuthHandler] Got serverID: " + serverID); + LogHelper.debug("[AuthHandler] Got UUID: " + uuid); } return new Entry(uuid, username, accessToken, serverID); } @@ -54,31 +54,31 @@ protected Entry fetchEntry(String username) throws IOException { String accessToken = parts[1]; String serverID = parts[2]; if (LogHelper.isDebugEnabled()) { - LogHelper.debug("[AuthHandler] Got username: " + username); - LogHelper.debug("[AuthHandler] Got accessToken: " + accessToken); - LogHelper.debug("[AuthHandler] Got serverID: " + serverID); - LogHelper.debug("[AuthHandler] Got UUID: " + uuid); + LogHelper.debug("[AuthHandler] Got username: " + username); + LogHelper.debug("[AuthHandler] Got accessToken: " + accessToken); + LogHelper.debug("[AuthHandler] Got serverID: " + serverID); + LogHelper.debug("[AuthHandler] Got UUID: " + uuid); } return new Entry(uuid, username, accessToken, serverID); } @Override protected boolean updateAuth(UUID uuid, String username, String accessToken) throws IOException { - String response = IOHelper.request(new URL(CommonHelper.replace(updateAuth, "user", IOHelper.urlEncode(username), "uuid", IOHelper.urlEncode(uuid.toString()), "token", IOHelper.urlEncode(accessToken)))); - if (LogHelper.isDebugEnabled()) { - LogHelper.debug("[AuthHandler] Set accessToken: " + accessToken); - LogHelper.debug("[AuthHandler] Set UUID: " + uuid); - LogHelper.debug("[AuthHandler] For this username: " + username); + String response = IOHelper.request(new URL(CommonHelper.replace(updateAuth, "user", IOHelper.urlEncode(username), "uuid", IOHelper.urlEncode(uuid.toString()), "token", IOHelper.urlEncode(accessToken)))); + if (LogHelper.isDebugEnabled()) { + LogHelper.debug("[AuthHandler] Set accessToken: " + accessToken); + LogHelper.debug("[AuthHandler] Set UUID: " + uuid); + LogHelper.debug("[AuthHandler] For this username: " + username); } return goodResponse.equals(response); } @Override protected boolean updateServerID(UUID uuid, String serverID) throws IOException { - String response = IOHelper.request(new URL(CommonHelper.replace(updateAuth, "serverid", IOHelper.urlEncode(serverID), "uuid", IOHelper.urlEncode(uuid.toString())))); - if (LogHelper.isDebugEnabled()) { - LogHelper.debug("[AuthHandler] Set serverID: " + serverID); - LogHelper.debug("[AuthHandler] For this UUID: " + uuid); + String response = IOHelper.request(new URL(CommonHelper.replace(updateAuth, "serverid", IOHelper.urlEncode(serverID), "uuid", IOHelper.urlEncode(uuid.toString())))); + if (LogHelper.isDebugEnabled()) { + LogHelper.debug("[AuthHandler] Set serverID: " + serverID); + LogHelper.debug("[AuthHandler] For this UUID: " + uuid); } return goodResponse.equals(response); } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/protect/ProtectHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/protect/ProtectHandler.java index 61759f2f..47665989 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/protect/ProtectHandler.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/protect/ProtectHandler.java @@ -8,7 +8,6 @@ public abstract class ProtectHandler { private static boolean registredHandl = false; - public static void registerHandlers() { if (!registredHandl) { providers.register("none", NoProtectHandler.class); @@ -19,7 +18,9 @@ public static void registerHandlers() { public abstract String generateSecureToken(AuthResponse.AuthContext context); //Генерация токена для передачи его в LauncherGuardInterface public abstract String generateClientSecureToken(); + public abstract boolean verifyClientSecureToken(String token, String secureKey); + public abstract boolean allowGetAccessToken(AuthResponse.AuthContext context); public abstract void checkLaunchServerLicense(); //Выдает SecurityException при ошибке проверки лицензии diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/AuthProvider.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/AuthProvider.java index 1901c186..f9c30c9d 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/AuthProvider.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/AuthProvider.java @@ -29,7 +29,6 @@ public static void registerProviders() { public abstract AuthProviderResult auth(String login, String password, String ip) throws Exception; public void preAuth(String login, String password, String customText, String ip) { - return; } @Override diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/LauncherBinary.java b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/LauncherBinary.java index 1e37d764..ec3320c1 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/LauncherBinary.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/LauncherBinary.java @@ -45,8 +45,8 @@ public final boolean sync() throws IOException { return exists; } - - public static final Path resolve(LaunchServer server, String ext) { - return server.config.copyBinaries ? server.updatesDir.resolve(server.config.binaryName + ext) : server.dir.resolve(server.config.binaryName + ext); + + public static Path resolve(LaunchServer server, String ext) { + return server.config.copyBinaries ? server.updatesDir.resolve(server.config.binaryName + ext) : server.dir.resolve(server.config.binaryName + ext); } } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/AdditionalFixesApplyTask.java b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/AdditionalFixesApplyTask.java index 732c3e40..75bc47a2 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/AdditionalFixesApplyTask.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/AdditionalFixesApplyTask.java @@ -35,28 +35,28 @@ public String getName() { public Path process(Path inputFile) throws IOException { Path out = server.launcherBinary.nextPath("post-fixed"); try (ZipOutputStream output = new ZipOutputStream(IOHelper.newOutput(out))) { - apply(inputFile, inputFile, output, server, (e) -> false); + apply(inputFile, inputFile, output, server, (e) -> false); } return out; } public static void apply(Path inputFile, Path addFile, ZipOutputStream output, LaunchServer srv, Predicate excluder) throws IOException { - try (ClassMetadataReader reader = new ClassMetadataReader()) { + try (ClassMetadataReader reader = new ClassMetadataReader()) { reader.getCp().add(new JarFile(inputFile.toFile())); List libs = srv.launcherBinary.coreLibs.stream().map(e -> { - try { - return new JarFile(e.toFile()); - } catch (IOException e1) { - throw new RuntimeException(e1); - } - }).collect(Collectors.toList()); + try { + return new JarFile(e.toFile()); + } catch (IOException e1) { + throw new RuntimeException(e1); + } + }).collect(Collectors.toList()); libs.addAll(srv.launcherBinary.addonLibs.stream().map(e -> { - try { - return new JarFile(e.toFile()); - } catch (IOException e1) { - throw new RuntimeException(e1); - } - }).collect(Collectors.toList())); + try { + return new JarFile(e.toFile()); + } catch (IOException e1) { + throw new RuntimeException(e1); + } + }).collect(Collectors.toList())); try (ZipInputStream input = IOHelper.newZipInput(addFile)) { ZipEntry e = input.getNextEntry(); while (e != null) { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/RadonBuildTask.java b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/RadonBuildTask.java index 9649a004..0a9c0561 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/RadonBuildTask.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/RadonBuildTask.java @@ -40,8 +40,8 @@ public Path process(Path inputFile) throws IOException { SessionInfo info = p.createSessionFromConfig(); info.setInput(inputFile.toFile()); info.setOutput(outputFile.toFile()); - List libs = srv.launcherBinary.coreLibs.stream().map(e -> e.toFile()).collect(Collectors.toList()); - libs.addAll(srv.launcherBinary.addonLibs.stream().map(e -> e.toFile()).collect(Collectors.toList())); + List libs = srv.launcherBinary.coreLibs.stream().map(Path::toFile).collect(Collectors.toList()); + libs.addAll(srv.launcherBinary.addonLibs.stream().map(Path::toFile).collect(Collectors.toList())); info.setLibraries(libs); Radon r = new Radon(info); r.run(); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/TaskUtil.java b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/TaskUtil.java index b5f99f16..7be46ff0 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/TaskUtil.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/TaskUtil.java @@ -8,13 +8,13 @@ public final class TaskUtil { public static void addCounted(List tasks, int count, Predicate pred, LauncherBuildTask taskAdd) { List indexes = new ArrayList<>(); - tasks.stream().filter(pred).forEach(e -> indexes.add(e)); + tasks.stream().filter(pred).forEach(indexes::add); indexes.forEach(e -> tasks.add(tasks.indexOf(e) + count, taskAdd)); } public static void replaceCounted(List tasks, int count, Predicate pred, LauncherBuildTask taskRep) { List indexes = new ArrayList<>(); - tasks.stream().filter(pred).forEach(e -> indexes.add(e)); + tasks.stream().filter(pred).forEach(indexes::add); indexes.forEach(e -> tasks.set(tasks.indexOf(e) + count, taskRep)); } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/auth/GetHWIDCommand.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/auth/GetHWIDCommand.java index f8d1711e..f9bee554 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/auth/GetHWIDCommand.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/auth/GetHWIDCommand.java @@ -26,10 +26,8 @@ public String getUsageDescription() { public void invoke(String... args) throws Exception { verifyArgs(args, 1); List target = server.config.hwidHandler.getHwid(args[0]); - for(HWID hwid : target) - { - if(hwid == null) - { + for (HWID hwid : target) { + if (hwid == null) { LogHelper.error("HWID %s: null", args[0]); continue; } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/TestCommand.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/TestCommand.java index 0864fb8e..2437e7f0 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/TestCommand.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/TestCommand.java @@ -35,8 +35,7 @@ public void invoke(String... args) throws Exception { if (args[0].equals("stop")) { handler.close(); } - if (args[0].equals("eventAll")) - { + if (args[0].equals("eventAll")) { WebSocketFrameHandler.service.sendObjectAll(new PingEvent()); } } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/handler/CommandHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/handler/CommandHandler.java index b64b9252..47829d21 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/handler/CommandHandler.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/handler/CommandHandler.java @@ -38,7 +38,7 @@ public static void registerCommands(ru.gravit.utils.command.CommandHandler handl basic.registerCommand("loadModule", new LoadModuleCommand(server)); basic.registerCommand("modules", new ModulesCommand(server)); basic.registerCommand("test", new TestCommand(server)); - Category basicCategory = new Category(basic,"basic", "Base LaunchServer commands"); + Category basicCategory = new Category(basic, "basic", "Base LaunchServer commands"); handler.registerCategory(basicCategory); // Register sync commands @@ -50,7 +50,7 @@ public static void registerCommands(ru.gravit.utils.command.CommandHandler handl updates.registerCommand("syncBinaries", new SyncBinariesCommand(server)); updates.registerCommand("syncUpdates", new SyncUpdatesCommand(server)); updates.registerCommand("syncProfiles", new SyncProfilesCommand(server)); - Category updatesCategory = new Category(updates,"updates", "Update and Sync Management"); + Category updatesCategory = new Category(updates, "updates", "Update and Sync Management"); handler.registerCategory(updatesCategory); // Register auth commands @@ -61,14 +61,14 @@ public static void registerCommands(ru.gravit.utils.command.CommandHandler handl auth.registerCommand("ban", new BanCommand(server)); auth.registerCommand("unban", new UnbanCommand(server)); auth.registerCommand("getHWID", new GetHWIDCommand(server)); - Category authCategory = new Category(auth,"auth", "User Management"); + Category authCategory = new Category(auth, "auth", "User Management"); handler.registerCategory(authCategory); //Register dump commands BaseCommandCategory dump = new BaseCommandCategory(); dump.registerCommand("dumpSessions", new DumpSessionsCommand(server)); dump.registerCommand("dumpEntryCache", new DumpEntryCacheCommand(server)); - Category dumpCategory = new Category(dump,"dump", "Dump runtime data"); + Category dumpCategory = new Category(dump, "dump", "Dump runtime data"); handler.registerCategory(dumpCategory); //Register service commands @@ -86,7 +86,7 @@ public static void registerCommands(ru.gravit.utils.command.CommandHandler handl service.registerCommand("component", new ComponentCommand(server)); service.registerCommand("givePermission", new GivePermissionsCommand(server)); service.registerCommand("getPermissions", new GetPermissionsCommand(server)); - Category serviceCategory = new Category(service,"service", "Managing LaunchServer Components"); + Category serviceCategory = new Category(service, "service", "Managing LaunchServer Components"); handler.registerCategory(serviceCategory); } } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/service/ServerStatusCommand.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/service/ServerStatusCommand.java index 5404a956..b95640ec 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/service/ServerStatusCommand.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/service/ServerStatusCommand.java @@ -35,8 +35,7 @@ public void invoke(String... args) { LogHelper.info("Uptime: %d days %d hours %d minutes %d seconds", days, hour, min, second); LogHelper.info("Uptime (double): %f", (double) JVMHelper.RUNTIME_MXBEAN.getUptime() / 1000); int commands = server.commandHandler.getBaseCategory().commandsMap().size(); - for(CommandHandler.Category category : server.commandHandler.getCategories()) - { + for (CommandHandler.Category category : server.commandHandler.getCategories()) { commands += category.category.commandsMap().size(); } LogHelper.info("Sessions: %d | Modules: %d | Commands: %d(%d categories)", server.sessionManager.getSessions().size(), server.modulesManager.modules.size(), commands, server.commandHandler.getCategories().size() + 1); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/config/LaunchServerRuntimeConfig.java b/LaunchServer/src/main/java/ru/gravit/launchserver/config/LaunchServerRuntimeConfig.java index 19d22034..c46ffadf 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/config/LaunchServerRuntimeConfig.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/config/LaunchServerRuntimeConfig.java @@ -5,12 +5,12 @@ public class LaunchServerRuntimeConfig { public String clientToken; - public void verify() - { - if(clientToken == null) LogHelper.error("[RuntimeConfig] clientToken must not be null"); + + public void verify() { + if (clientToken == null) LogHelper.error("[RuntimeConfig] clientToken must not be null"); } - public void reset() - { + + public void reset() { clientToken = SecurityHelper.randomStringToken(); } } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/legacy/Response.java b/LaunchServer/src/main/java/ru/gravit/launchserver/legacy/Response.java index e3d48b4e..697f23c3 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/legacy/Response.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/legacy/Response.java @@ -82,7 +82,7 @@ protected final void debug(String message, Object... args) { public abstract void reply() throws Exception; - protected static final void writeNoError(HOutput output) throws IOException { + protected static void writeNoError(HOutput output) throws IOException { output.writeString("", 0); } } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/ReconfigurableManager.java b/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/ReconfigurableManager.java index e6247b0a..66817aeb 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/ReconfigurableManager.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/ReconfigurableManager.java @@ -14,8 +14,8 @@ public void registerReconfigurable(String name, Reconfigurable reconfigurable) { VerifyHelper.putIfAbsent(RECONFIGURABLE, name.toLowerCase(), Objects.requireNonNull(reconfigurable, "adapter"), String.format("Reloadable has been already registered: '%s'", name)); } - public Reconfigurable unregisterReconfigurable(String name) - { + + public Reconfigurable unregisterReconfigurable(String name) { return RECONFIGURABLE.remove(name); } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/ReloadManager.java b/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/ReloadManager.java index ff56467f..fce8ea1e 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/ReloadManager.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/ReloadManager.java @@ -14,8 +14,8 @@ public void registerReloadable(String name, Reloadable reloadable) { VerifyHelper.putIfAbsent(RELOADABLES, name.toLowerCase(), Objects.requireNonNull(reloadable, "adapter"), String.format("Reloadable has been already registered: '%s'", name.toLowerCase())); } - public Reloadable unregisterReloadable(String name) - { + + public Reloadable unregisterReloadable(String name) { return RELOADABLES.remove(name); } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/LauncherNettyServer.java b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/LauncherNettyServer.java index 9da937b3..1cc9735a 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/LauncherNettyServer.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/LauncherNettyServer.java @@ -40,17 +40,20 @@ public LauncherNettyServer() { @Override public void initChannel(NioSocketChannel ch) { ChannelPipeline pipeline = ch.pipeline(); + NettyConnectContext context = new NettyConnectContext(); //p.addLast(new LoggingHandler(LogLevel.INFO)); pipeline.addLast(new HttpServerCodec()); pipeline.addLast(new HttpObjectAggregator(65536)); + if (LaunchServer.server.config.netty.ipForwarding) + pipeline.addLast(new NettyIpForwardHandler(context)); pipeline.addLast(new WebSocketServerCompressionHandler()); pipeline.addLast(new WebSocketServerProtocolHandler(WEBSOCKET_PATH, null, true)); - if (LaunchServer.server.config.netty.fileServerEnabled) pipeline.addLast(new FileServerHandler(LaunchServer.server.updatesDir, true)); - pipeline.addLast(new WebSocketFrameHandler()); + if (LaunchServer.server.config.netty.fileServerEnabled) + pipeline.addLast(new FileServerHandler(LaunchServer.server.updatesDir, true)); + pipeline.addLast(new WebSocketFrameHandler(context)); } }); - if(config.proxy != null && config.proxy.enabled) - { + if (config.proxy != null && config.proxy.enabled) { LogHelper.info("Connect to main server %s"); Request.service = StandartClientWebSocketService.initWebSockets(config.proxy.address, false); AuthRequest authRequest = new AuthRequest(config.proxy.login, config.proxy.password, config.proxy.auth_id, AuthRequest.ConnectTypes.PROXY); @@ -62,8 +65,8 @@ public void initChannel(NioSocketChannel ch) { } } } - public ChannelFuture bind(InetSocketAddress address) - { + + public ChannelFuture bind(InetSocketAddress address) { return serverBootstrap.bind(address); } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/NettyConnectContext.java b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/NettyConnectContext.java new file mode 100644 index 00000000..c1a66c8a --- /dev/null +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/NettyConnectContext.java @@ -0,0 +1,5 @@ +package ru.gravit.launchserver.websocket; + +public class NettyConnectContext { + public String ip = null; +} diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/NettyIpForwardHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/NettyIpForwardHandler.java new file mode 100644 index 00000000..380aeb50 --- /dev/null +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/NettyIpForwardHandler.java @@ -0,0 +1,43 @@ +package ru.gravit.launchserver.websocket; + +import io.netty.channel.ChannelHandlerContext; +import io.netty.handler.codec.MessageToMessageDecoder; +import io.netty.handler.codec.http.HttpHeaders; +import io.netty.handler.codec.http.HttpRequest; +import io.netty.util.ReferenceCounted; +import ru.gravit.utils.helper.LogHelper; + +import java.util.List; + +public class NettyIpForwardHandler extends MessageToMessageDecoder { + private NettyConnectContext context; + + public NettyIpForwardHandler(NettyConnectContext context) { + super(); + this.context = context; + } + + @Override + protected void decode(ChannelHandlerContext ctx, HttpRequest msg, List out) throws Exception { + if (msg instanceof ReferenceCounted) { + ((ReferenceCounted) msg).retain(); + } + if (context.ip != null) { + out.add(msg); + return; + } + HttpHeaders headers = msg.headers(); + String realIP = null; + if (headers.contains("X-Forwarded-For")) { + realIP = headers.get("X-Forwarded-For"); + } + if (headers.contains("X-Real-IP")) { + realIP = headers.get("X-Real-IP"); + } + if (realIP != null) { + LogHelper.dev("Real IP address %s", realIP); + context.ip = realIP; + } else LogHelper.error("IpForwarding error. Headers not found"); + out.add(msg); + } +} diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/NettyServerSocketHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/NettyServerSocketHandler.java index d33ef123..7e49dfbf 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/NettyServerSocketHandler.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/NettyServerSocketHandler.java @@ -100,13 +100,12 @@ public void run() { } catch (IOException e) { e.printStackTrace(); }*/ - LogHelper.info("Starting server socket thread"); + LogHelper.info("Starting netty server socket thread"); //SSLEngine engine = sc.createSSLEngine(); //engine.setUseClientMode(false); WebSocketFrameHandler.server = LaunchServer.server; nettyServer = new LauncherNettyServer(); - for(LaunchServer.NettyBindAddress address : LaunchServer.server.config.netty.binds) - { + for (LaunchServer.NettyBindAddress address : LaunchServer.server.config.netty.binds) { nettyServer.bind(new InetSocketAddress(address.address, address.port)); } /* diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/WebSocketFrameHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/WebSocketFrameHandler.java index 01d88376..ac226eaf 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/WebSocketFrameHandler.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/WebSocketFrameHandler.java @@ -17,13 +17,19 @@ public class WebSocketFrameHandler extends SimpleChannelInboundHandler list = new ArrayList<>(); - for(AuthProviderPair pair : LaunchServer.server.config.auth) - { + for (AuthProviderPair pair : LaunchServer.server.config.auth) { list.add(new GetAvailabilityAuthRequestEvent.AuthAvailability(pair.name, pair.displayName)); } sendResult(new GetAvailabilityAuthRequestEvent(list)); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/auth/JoinServerResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/auth/JoinServerResponse.java index 989b0f12..c222d6cc 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/auth/JoinServerResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/auth/JoinServerResponse.java @@ -18,17 +18,16 @@ public class JoinServerResponse extends SimpleResponse { public String getType() { return "joinServer"; } + @Override public void execute(ChannelHandlerContext ctx, Client client) { boolean success; try { server.authHookManager.joinServerHook.hook(this, client); - if(client.auth == null) - { + if (client.auth == null) { LogHelper.warning("Client auth is null. Using default."); success = LaunchServer.server.config.getAuthProviderPair().handler.joinServer(username, accessToken, serverID); - } - else success = client.auth.handler.joinServer(username, accessToken, serverID); + } else success = client.auth.handler.joinServer(username, accessToken, serverID); LogHelper.debug("joinServer: %s accessToken: %s serverID: %s", username, accessToken, serverID); } catch (AuthException | HookException e) { sendError(e.getMessage()); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/auth/RestoreSessionResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/auth/RestoreSessionResponse.java index 6ba2827e..713e3084 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/auth/RestoreSessionResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/auth/RestoreSessionResponse.java @@ -11,6 +11,7 @@ public class RestoreSessionResponse extends SimpleResponse { @LauncherNetworkAPI public long session; + @Override public String getType() { return "restoreSession"; @@ -19,8 +20,7 @@ public String getType() { @Override public void execute(ChannelHandlerContext ctx, Client client) { Client rClient = LaunchServer.server.sessionManager.getClient(session); - if(rClient == null) - { + if (rClient == null) { sendError("Session invalid"); } WebSocketFrameHandler frameHandler = ctx.pipeline().get(WebSocketFrameHandler.class); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/auth/SetProfileResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/auth/SetProfileResponse.java index c1de900f..be13da91 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/auth/SetProfileResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/auth/SetProfileResponse.java @@ -26,8 +26,7 @@ public void execute(ChannelHandlerContext ctx, Client client) { } try { server.authHookManager.setProfileHook.hook(this, client); - } catch (HookException e) - { + } catch (HookException e) { sendError(e.getMessage()); } Collection profiles = LaunchServer.server.getProfiles(); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/profile/BatchProfileByUsername.java b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/profile/BatchProfileByUsername.java index 471fbd2a..9df09489 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/profile/BatchProfileByUsername.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/profile/BatchProfileByUsername.java @@ -29,12 +29,10 @@ public void execute(ChannelHandlerContext ctx, Client client) throws Exception { result.playerProfiles = new PlayerProfile[list.length]; for (int i = 0; i < list.length; ++i) { UUID uuid; - if(client.auth == null) - { + if (client.auth == null) { LogHelper.warning("Client auth is null. Using default."); uuid = LaunchServer.server.config.getAuthProviderPair().handler.usernameToUUID(list[i].username); - } - else uuid = client.auth.handler.usernameToUUID(list[i].username); + } else uuid = client.auth.handler.usernameToUUID(list[i].username); result.playerProfiles[i] = ProfileByUUIDResponse.getProfile(LaunchServer.server, uuid, list[i].username, list[i].client, client.auth.textureProvider); } sendResult(result); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/profile/ProfileByUUIDResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/profile/ProfileByUUIDResponse.java index 7caa4c65..d8ac236d 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/profile/ProfileByUUIDResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/profile/ProfileByUUIDResponse.java @@ -48,12 +48,10 @@ public String getType() { @Override public void execute(ChannelHandlerContext ctx, Client client) throws Exception { String username; - if(client.auth == null) - { + if (client.auth == null) { LogHelper.warning("Client auth is null. Using default."); username = LaunchServer.server.config.getAuthProviderPair().handler.uuidToUsername(uuid); - } - else username = client.auth.handler.uuidToUsername(uuid); + } else username = client.auth.handler.uuidToUsername(uuid); sendResult(new ProfileByUUIDRequestEvent(getProfile(LaunchServer.server, uuid, username, this.client, client.auth.textureProvider))); } } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/profile/ProfileByUsername.java b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/profile/ProfileByUsername.java index acb3ec20..604f1b6c 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/profile/ProfileByUsername.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/profile/ProfileByUsername.java @@ -23,12 +23,10 @@ public String getType() { @Override public void execute(ChannelHandlerContext ctx, Client client) throws Exception { UUID uuid; - if(client.auth == null) - { + if (client.auth == null) { LogHelper.warning("Client auth is null. Using default."); uuid = LaunchServer.server.config.getAuthProviderPair().handler.usernameToUUID(username); - } - else uuid = client.auth.handler.usernameToUUID(username); + } else uuid = client.auth.handler.usernameToUUID(username); sendResult(new ProfileByUsernameRequestEvent(getProfile(LaunchServer.server, uuid, username, this.client, client.auth.textureProvider))); } } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/secure/VerifySecureTokenResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/secure/VerifySecureTokenResponse.java index 534c477d..0098cde0 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/secure/VerifySecureTokenResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/secure/VerifySecureTokenResponse.java @@ -17,7 +17,7 @@ public String getType() { @Override public void execute(ChannelHandlerContext ctx, Client client) { boolean success = LaunchServer.server.config.protectHandler.verifyClientSecureToken(secureToken, client.verifyToken); - if(success) client.isSecure = true; + if (success) client.isSecure = true; sendResult(new VerifySecureTokenRequestEvent(success)); } } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/update/UpdateResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/update/UpdateResponse.java index 6b28b24f..34d75c14 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/update/UpdateResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/update/UpdateResponse.java @@ -34,13 +34,12 @@ public void execute(ChannelHandlerContext ctx, Client client) { } } SignedObjectHolder dir = LaunchServer.server.updatesDirMap.get(dirName); - if(dir == null) - { + if (dir == null) { service.sendObject(ctx, new ErrorRequestEvent(String.format("Directory %s not found", dirName))); return; } - String url = LaunchServer.server.config.netty.downloadURL.replace("%dirname%",dirName); - if(server.config.netty.bindings.get(dirName) != null) url = server.config.netty.bindings.get(dirName); + String url = LaunchServer.server.config.netty.downloadURL.replace("%dirname%", dirName); + if (server.config.netty.bindings.get(dirName) != null) url = server.config.netty.bindings.get(dirName); service.sendObject(ctx, new UpdateRequestEvent(dir.object, url)); } } diff --git a/LaunchServerConsole/src/main/java/ru/gravit/launchserver/console/ConsoleMain.java b/LaunchServerConsole/src/main/java/ru/gravit/launchserver/console/ConsoleMain.java index db87c980..a11fabcb 100644 --- a/LaunchServerConsole/src/main/java/ru/gravit/launchserver/console/ConsoleMain.java +++ b/LaunchServerConsole/src/main/java/ru/gravit/launchserver/console/ConsoleMain.java @@ -20,7 +20,7 @@ public static void main(String[] args) throws IOException { LogHelper.warning("Permission canAdmin not found"); } try { - Class.forName("jline.Terminal"); + Class.forName("org.jline.terminal.Terminal"); // JLine2 available commandHandler = new JLineCommandHandler(); @@ -33,8 +33,8 @@ public static void main(String[] args) throws IOException { LogHelper.info("CommandHandler started. Use 'exit' to exit this console"); commandHandler.run(); } - public static void registerCommands() - { + + public static void registerCommands() { commandHandler.registerCommand("help", new HelpCommand(commandHandler)); commandHandler.registerCommand("exit", new ExitCommand()); commandHandler.registerCommand("logListener", new LogListenerCommand()); diff --git a/LaunchServerConsole/src/main/java/ru/gravit/launchserver/console/ExecCommand.java b/LaunchServerConsole/src/main/java/ru/gravit/launchserver/console/ExecCommand.java index f6ae564b..8717264e 100644 --- a/LaunchServerConsole/src/main/java/ru/gravit/launchserver/console/ExecCommand.java +++ b/LaunchServerConsole/src/main/java/ru/gravit/launchserver/console/ExecCommand.java @@ -19,6 +19,6 @@ public String getUsageDescription() { @Override public void invoke(String... args) throws Exception { ExecCommandRequestEvent request = new ExecCommandRequest(String.join(" ")).request(); - if(!request.success) LogHelper.error("Error executing command"); + if (!request.success) LogHelper.error("Error executing command"); } } diff --git a/LaunchServerConsole/src/main/java/ru/gravit/launchserver/console/LogListenerCommand.java b/LaunchServerConsole/src/main/java/ru/gravit/launchserver/console/LogListenerCommand.java index 02a68acf..1634efc6 100644 --- a/LaunchServerConsole/src/main/java/ru/gravit/launchserver/console/LogListenerCommand.java +++ b/LaunchServerConsole/src/main/java/ru/gravit/launchserver/console/LogListenerCommand.java @@ -8,8 +8,7 @@ import ru.gravit.utils.helper.LogHelper; public class LogListenerCommand extends Command { - public class LogListenerRequest implements RequestInterface - { + public class LogListenerRequest implements RequestInterface { @LauncherNetworkAPI public LogHelper.OutputTypes outputType; @@ -22,6 +21,7 @@ public String getType() { return "addLogListener"; } } + @Override public String getArgsDescription() { return null; @@ -38,8 +38,7 @@ public void invoke(String... args) throws Exception { Request.service.sendObject(new LogListenerRequest(LogHelper.JANSI ? LogHelper.OutputTypes.JANSI : LogHelper.OutputTypes.PLAIN)); LogHelper.info("Add log handler"); Request.service.registerHandler((result) -> { - if(result instanceof LogEvent) - { + if (result instanceof LogEvent) { System.out.println(((LogEvent) result).string); } }); diff --git a/Launcher/build.gradle b/Launcher/build.gradle index 208d74cf..f1e08d0d 100644 --- a/Launcher/build.gradle +++ b/Launcher/build.gradle @@ -28,11 +28,11 @@ } shadowJar { - classifier = null - relocate 'org.objectweb.asm', 'ru.gravit.repackage.org.objectweb.asm' - relocate 'io.netty', 'ru.gravit.repackage.io.netty' - configurations = [project.configurations.pack] - exclude 'module-info.class' + classifier = null + relocate 'org.objectweb.asm', 'ru.gravit.repackage.org.objectweb.asm' + relocate 'io.netty', 'ru.gravit.repackage.io.netty' + configurations = [project.configurations.pack] + exclude 'module-info.class' } dependencies { diff --git a/Launcher/runtime/dialog/dialog.js b/Launcher/runtime/dialog/dialog.js index cfc3a805..109112c2 100644 --- a/Launcher/runtime/dialog/dialog.js +++ b/Launcher/runtime/dialog/dialog.js @@ -1,10 +1,12 @@ -var authPane, dimPane, serverPane, bar, consoleBar, optionsPane, consolePane; +var authPane, dimPane, serverPane, bar, consoleBar, optionsPane, consolePane, loginPaneLayout, serverPaneLayout; var loginField, passwordField, savePasswordBox, authOptions; var serverList, serverInfo, serverDescription, serverEntrance, serverLabel, serverStatus; var profilesList = []; var movePoint = null; var pingers = {}; var loginData; +// Variable which contains all types of auth. Appending data at line 255 +var authTypes = {}; function initLauncher() { initLoginScene(); @@ -41,6 +43,9 @@ function initLoginScene() { var pane = loginPane.lookup("#authPane"); authPane = pane; + var loginLayout = loginPane.lookup("#layout"); + loginPaneLayout = loginLayout; + loginField = pane.lookup("#login"); loginField.setOnMouseMoved(function(event){rootPane.fireEvent(event)}); loginField.setOnAction(goAuth); @@ -59,12 +64,12 @@ function initLoginScene() { savePasswordBox = pane.lookup("#rememberchb"); savePasswordBox.setSelected(settings.login === null || settings.rsaPassword !== null); - authOptions = pane.lookup("#authOptions"); - var link = pane.lookup("#link"); link.setText(config.linkText); link.setOnAction(function(event) app.getHostServices().showDocument(config.linkURL.toURI())); + authOptions = pane.lookup("#authOptions"); + pane.lookup("#goAuth").setOnAction(goAuth); } @@ -91,6 +96,9 @@ function initMenuScene() { var pane = menuPane.lookup("#serverPane"); serverPane = pane; + var menuLayout = menuPane.lookup("#layout"); + serverPaneLayout = menuLayout; + pane.lookup("#clientSettings").setOnAction(goOptions); serverList = pane.lookup("#serverlist").getContent(); serverInfo = pane.lookup("#serverinfo").getContent(); @@ -187,25 +195,35 @@ function goAuth(event) { return; } - var rsaPassword = null; - if (!passwordField.isDisable()) { - var password = passwordField.getText(); - if (password !== null && !password.isEmpty()) { - rsaPassword = settingsOverlay.setPassword(password); - } else if (settings.rsaPassword !== null) { - rsaPassword = settings.rsaPassword; - } else { - return; - } - - settings.rsaPassword = savePasswordBox.isSelected() ? rsaPassword : null; + // Get auth + var auth = authOptions.getSelectionModel().getSelectedItem(); + if (auth === null) { + return; // No auth selected } - settings.login = login; - doAuth(login, rsaPassword); -} + var rsaPassword = null; + var auth = authOptions.getSelectionModel().getSelectedItem(); + if (auth === null) { + return; + } + if (!passwordField.isDisable()) { + var password = passwordField.getText(); + if (password !== null && !password.isEmpty()) { + rsaPassword = settingsOverlay.setPassword(password); + } else if (settings.rsaPassword !== null) { + rsaPassword = settings.rsaPassword; + } else { + return; + } -/* ======== Console ======== */ + settings.rsaPassword = savePasswordBox.isSelected() ? rsaPassword : null; + } + + settings.login = login; + doAuth(/*auth, */login, rsaPassword, authTypes[auth]); + } + + /* ======== Console ======== */ function goConsole(event) { setConsoleCurrentScene(consoleScene); } @@ -236,18 +254,25 @@ function verifyLauncher(e) { initOffline(); } overlay.swap(0, processing.overlay, function(event) makeAuthAvailabilityRequest(function(result) { - //result.list; - //result.list[0].name; - //result.list[0].displayName; + var iter = 0; + authTypes = {}; result.list.forEach(function(auth_type, i, arr) { - var serverAuth = new com.jfoenix.controls.JFXComboBox(); serverAuth.getStyleClass().add("authOptions"); - - (function() { - authOptions.getItems().add(auth_type.displayName); - })(); + // add display name to items and add name with iter to variable authTypes + authOptions.getItems().add(auth_type.displayName); + authTypes[auth_type.displayName] = auth_type.name; + iter++; }); + authOptions.getSelectionModel().select(0); + var sm = authOptions.getSelectionModel().selectedIndexProperty(); + // add listener to authOptions select + sm.addListener(new javafx.beans.value.ChangeListener({ + changed: function (observableValue, oldSelection, newSelection) { + // get auth name from authTypes + settings.auth = authTypes[authOptions.getSelectionModel().getSelectedItem()]; + } + })); overlay.swap(0, processing.overlay, function(event) makeProfilesRequest(function(result) { settings.lastProfiles = result.profiles; updateProfilesList(result.profiles); @@ -262,13 +287,14 @@ function verifyLauncher(e) { })); } -function doAuth(login, rsaPassword) { +function doAuth(login, rsaPassword, auth_type) { processing.resetOverlay(); overlay.show(processing.overlay, function (event) { FunctionalBridge.getHWID.join(); - makeAuthRequest(login, rsaPassword, function (result) { + makeAuthRequest(login, rsaPassword, auth_type, function (result) { FunctionalBridge.setAuthParams(result); - loginData = { pp: result.playerProfile , accessToken: result.accessToken, permissions: result.permissions}; + loginData = { pp: result.playerProfile , accessToken: result.accessToken, permissions: result.permissions, + auth_type: settings.auth}; overlay.hide(0, function () { setCurrentScene(menuScene); @@ -397,7 +423,8 @@ var overlay = { dimPane.setVisible(true); dimPane.toFront(); - + loginPaneLayout.setEffect(new javafx.scene.effect.GaussianBlur(55)); + serverPaneLayout.setEffect(new javafx.scene.effect.GaussianBlur(55)); fade(dimPane, 0.0, 0.0, 1.0, function(event) { dimPane.requestFocus(); dimPane.getChildren().add(newOverlay); @@ -417,7 +444,8 @@ var overlay = { authPane.setDisable(false); rootPane.requestFocus(); - + loginPaneLayout.setEffect(new javafx.scene.effect.GaussianBlur(0)); + serverPaneLayout.setEffect(new javafx.scene.effect.GaussianBlur(0)); overlay.current = null; if (onFinished !== null) { onFinished(); @@ -455,7 +483,7 @@ var serverHolder = { set: function(btn){ pingServer(btn); - serverLabel.setText("СЕРВЕР " + profilesList[btn]); + serverLabel.setText(profilesList[btn]); serverDescription.setText(profilesList[btn].info); btn.setSelected(true); btn.setDisable(true); diff --git a/Launcher/runtime/dialog/offline/offline.html b/Launcher/runtime/dialog/offline/offline.html index 59e71194..d81ea104 100644 --- a/Launcher/runtime/dialog/offline/offline.html +++ b/Launcher/runtime/dialog/offline/offline.html @@ -1,15 +1,16 @@ - - - Offline-режим - - - -

Offline-режим

- Лаунчер запущен в Offline-режиме. В этом режиме Вы можете запустить любой ранее загруженный клиент - с любым именем пользователя, при этом вход на серверы с авторизацией, а так же система скинов и плащей может не работать. - Скорее всего, проблема вызвана сбоем на сервере или неполадками в интернет-подключении. - Проверьте состояние интернет-подключения или обратитесь к администратору сервера. - + + + Offline-режим + + + +

Offline-режим

+Лаунчер запущен в Offline-режиме. В этом режиме Вы можете запустить любой ранее загруженный клиент +с любым именем пользователя, при этом вход на серверы с авторизацией, а так же система скинов и плащей может не + работать. +Скорее всего, проблема вызвана сбоем на сервере или неполадками в интернет-подключении. +Проверьте состояние интернет-подключения или обратитесь к администратору сервера. + \ No newline at end of file diff --git a/Launcher/runtime/dialog/overlay/debug/debug.css b/Launcher/runtime/dialog/overlay/debug/debug.css index 2187bdf0..4edf88b4 100644 --- a/Launcher/runtime/dialog/overlay/debug/debug.css +++ b/Launcher/runtime/dialog/overlay/debug/debug.css @@ -10,10 +10,6 @@ #background > #output { -fx-background-radius: 0; -fx-font-family: monospace; -fx-font-size: 8pt; - -fx-font-weight: regular; -} -#background > .textField { - -fx-font-weight: regular; } #overlay > #output .content, diff --git a/Launcher/runtime/dialog/overlay/debug/debug.fxml b/Launcher/runtime/dialog/overlay/debug/debug.fxml index 8411c831..89efbb21 100644 --- a/Launcher/runtime/dialog/overlay/debug/debug.fxml +++ b/Launcher/runtime/dialog/overlay/debug/debug.fxml @@ -8,17 +8,20 @@ - + - - + + - - - - - - + + + + + + + diff --git a/Launcher/runtime/dialog/overlay/processing/processing.fxml b/Launcher/runtime/dialog/overlay/processing/processing.fxml index 8d9a0beb..ad85211f 100644 --- a/Launcher/runtime/dialog/overlay/processing/processing.fxml +++ b/Launcher/runtime/dialog/overlay/processing/processing.fxml @@ -7,13 +7,15 @@ - - - - - - - + + + + + + + diff --git a/Launcher/runtime/dialog/overlay/processing/processing.js b/Launcher/runtime/dialog/overlay/processing/processing.js index f14a6638..568cc2ee 100644 --- a/Launcher/runtime/dialog/overlay/processing/processing.js +++ b/Launcher/runtime/dialog/overlay/processing/processing.js @@ -124,9 +124,9 @@ function makeSetProfileRequest(profile, callback) { startTask(task); } -function makeAuthRequest(login, rsaPassword, callback) { +function makeAuthRequest(login, rsaPassword, auth_type, callback) { var task = rsaPassword === null ? newTask(offlineAuthRequest(login)) : - newRequestTask(new AuthRequest(login, rsaPassword, FunctionalBridge.getHWID())); + newRequestTask(new AuthRequest(login, rsaPassword, FunctionalBridge.getHWID(), auth_type)); processing.setTaskProperties(task, callback, null, true); task.updateMessage("Авторизация на сервере"); startTask(task); diff --git a/Launcher/runtime/dialog/overlay/settings/settings.fxml b/Launcher/runtime/dialog/overlay/settings/settings.fxml index f4ca9fac..bfd1ae16 100644 --- a/Launcher/runtime/dialog/overlay/settings/settings.fxml +++ b/Launcher/runtime/dialog/overlay/settings/settings.fxml @@ -13,42 +13,60 @@ - - - - - - - - - - - - - - - - - - Выделение памяти: - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + Выделение памяти: + + + + + + + + + + + + + + + + + + + + diff --git a/Launcher/runtime/dialog/overlay/update/update.css b/Launcher/runtime/dialog/overlay/update/update.css index 90542c70..dff8e234 100644 --- a/Launcher/runtime/dialog/overlay/update/update.css +++ b/Launcher/runtime/dialog/overlay/update/update.css @@ -3,8 +3,6 @@ #overlay { -fx-background-color: transparent; -fx-background-size: cover; - -fx-pref-width: 693px; - -fx-pref-height: 450px; -fx-background-image: url('../../images/background.jpg'); } @@ -23,8 +21,6 @@ #overlay > #description.error { .downloadPane { -fx-background-color: rgba(0, 0, 0, 0.3); - -fx-pref-width: 693px; - -fx-pref-height: 450px; } /* Progress bar */ diff --git a/Launcher/runtime/dialog/overlay/update/update.fxml b/Launcher/runtime/dialog/overlay/update/update.fxml index 406bdd40..30ffcdb0 100644 --- a/Launcher/runtime/dialog/overlay/update/update.fxml +++ b/Launcher/runtime/dialog/overlay/update/update.fxml @@ -1,6 +1,5 @@ - @@ -9,22 +8,29 @@ - - - - - - - - - - + + + + + + + + + + + + + + diff --git a/Launcher/runtime/dialog/scenes/console/console.fxml b/Launcher/runtime/dialog/scenes/console/console.fxml index d7455885..738a5506 100644 --- a/Launcher/runtime/dialog/scenes/console/console.fxml +++ b/Launcher/runtime/dialog/scenes/console/console.fxml @@ -15,36 +15,40 @@ - + - + - + - + - + - + - + - + - - + + - - + + diff --git a/Launcher/runtime/dialog/scenes/login/login.fxml b/Launcher/runtime/dialog/scenes/login/login.fxml index fe5c2c58..4d1bfe05 100644 --- a/Launcher/runtime/dialog/scenes/login/login.fxml +++ b/Launcher/runtime/dialog/scenes/login/login.fxml @@ -14,47 +14,63 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Launcher/runtime/dialog/scenes/mainmenu/mainmenu.fxml b/Launcher/runtime/dialog/scenes/mainmenu/mainmenu.fxml index f124cd17..f48cca8f 100644 --- a/Launcher/runtime/dialog/scenes/mainmenu/mainmenu.fxml +++ b/Launcher/runtime/dialog/scenes/mainmenu/mainmenu.fxml @@ -13,101 +13,127 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Launcher/runtime/dialog/scenes/options/options.fxml b/Launcher/runtime/dialog/scenes/options/options.fxml index 9bbbdec1..90eebc82 100644 --- a/Launcher/runtime/dialog/scenes/options/options.fxml +++ b/Launcher/runtime/dialog/scenes/options/options.fxml @@ -12,48 +12,56 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Launcher/runtime/dialog/servers.css b/Launcher/runtime/dialog/servers.css index edb37b39..ce53884e 100644 --- a/Launcher/runtime/dialog/servers.css +++ b/Launcher/runtime/dialog/servers.css @@ -17,9 +17,7 @@ .server-button { } .server-button:selected { - -fx-border-width: 0 0 0 2; - -fx-border-style: none none none solid; - -fx-border-color: #323232; + -fx-effect: dropshadow(gaussian, rgba(23, 25, 29, 0.3), 15,0,0,3); } /** server-button- **/ diff --git a/Launcher/runtime/dialog/styles.css b/Launcher/runtime/dialog/styles.css index 03c7e2cd..574e979a 100644 --- a/Launcher/runtime/dialog/styles.css +++ b/Launcher/runtime/dialog/styles.css @@ -3,6 +3,7 @@ Button, CheckBox, ComboBox, RadioButton { -fx-cursor: hand; } + /* Backgrounds */ #layout { -fx-background-color: transparent; @@ -22,9 +23,6 @@ #background > #settingsTitle { #serverLabel{ -fx-text-fill: #323232; - -fx-padding: 0 0 0 14; - -fx-pref-width: 265px; - -fx-pref-height: 25px; } #serverStatus{ @@ -35,7 +33,7 @@ #serverStatus{ /* Mask */ #mask { - -fx-background-color: rgba(0, 0, 0, 0.5); + -fx-effect: DropShadow( gaussian , rgba(255,255,255,0.5) , 0,0,0,1 ); -fx-pref-width: 692px; -fx-pref-height: 450px; } @@ -66,7 +64,7 @@ #close { -fx-pref-width: 46px; -fx-pref-height: 45px; } -#hide, #back, #goConsole, #settings, #logout, #discord { +#hide, #back, #goConsole, #settings, #discord { -fx-background-position: center; -jfx-button-type: FLAT; -fx-background-radius: 0; @@ -74,6 +72,23 @@ #hide, #back, #goConsole, #settings, #logout, #discord { -fx-pref-height: 45px; } +#logout{ + -fx-text-fill:#323232; + -fx-font-size:12; + -fx-font-weight:normal; + -fx-border-color:#CE5757; + -fx-border-width:1; + -fx-background-color:transparent; + -fx-padding:0; +} +#logout:hover, +#logout:focus{ + -fx-text-fill:#ff6a5e; +} +#logout:pressed{ + -fx-border-color:#cb4d43; +} + #send { -fx-background-radius: 0; -fx-text-fill: black; diff --git a/Launcher/src/main/java/ru/gravit/launcher/ClientLauncherWrapper.java b/Launcher/src/main/java/ru/gravit/launcher/ClientLauncherWrapper.java index b1398d7b..f18db5f6 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/ClientLauncherWrapper.java +++ b/Launcher/src/main/java/ru/gravit/launcher/ClientLauncherWrapper.java @@ -27,27 +27,22 @@ public static void main(String[] arguments) throws IOException, InterruptedExcep EnvHelper.checkDangerousParams(); LauncherConfig config = Launcher.getConfig(); LogHelper.info("Launcher for project %s", config.projectname); - if(config.environment.equals(LauncherConfig.LauncherEnvironment.PROD)) - { - if(System.getProperty(LogHelper.DEBUG_PROPERTY) != null) - { + if (config.environment.equals(LauncherConfig.LauncherEnvironment.PROD)) { + if (System.getProperty(LogHelper.DEBUG_PROPERTY) != null) { LogHelper.warning("Found -Dlauncher.debug=true"); } - if(System.getProperty(LogHelper.STACKTRACE_PROPERTY) != null) - { + if (System.getProperty(LogHelper.STACKTRACE_PROPERTY) != null) { LogHelper.warning("Found -Dlauncher.stacktrace=true"); } LogHelper.info("Debug mode disabled (found env PRODUCTION)"); - } - else - { + } else { LogHelper.info("If need debug output use -Dlauncher.debug=true"); LogHelper.info("If need stacktrace output use -Dlauncher.stacktrace=true"); - if(LogHelper.isDebugEnabled()) waitProcess = true; + if (LogHelper.isDebugEnabled()) waitProcess = true; } LogHelper.info("Restart Launcher with JavaAgent..."); ProcessBuilder processBuilder = new ProcessBuilder(); - if(waitProcess) processBuilder.inheritIO(); + if (waitProcess) processBuilder.inheritIO(); Path javaBin = IOHelper.resolveJavaBin(Paths.get(System.getProperty("java.home"))); List args = new LinkedList<>(); args.add(javaBin.toString()); diff --git a/Launcher/src/main/java/ru/gravit/launcher/LauncherAgent.java b/Launcher/src/main/java/ru/gravit/launcher/LauncherAgent.java index 9946e584..164d9be4 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/LauncherAgent.java +++ b/Launcher/src/main/java/ru/gravit/launcher/LauncherAgent.java @@ -7,7 +7,6 @@ import org.objectweb.asm.tree.ClassNode; import org.objectweb.asm.tree.InsnNode; import org.objectweb.asm.tree.MethodNode; - import ru.gravit.launcher.utils.NativeJVMHalt; import ru.gravit.utils.helper.LogHelper; @@ -20,7 +19,8 @@ import java.util.List; import java.util.jar.JarFile; -import static org.objectweb.asm.Opcodes.*; +import static org.objectweb.asm.Opcodes.ACONST_NULL; +import static org.objectweb.asm.Opcodes.ARETURN; @LauncherAPI public final class LauncherAgent { @@ -37,28 +37,28 @@ public boolean isAgentStarted() { } public static void premain(String agentArgument, Instrumentation instrumentation) { - System.out.println("Launcher Agent"); + System.out.println("Launcher Agent"); inst = instrumentation; - SafeExitJVMLegacy.class.getName(); - SafeExitJVM.class.getName(); - NativeJVMHalt.class.getName(); + SafeExitJVMLegacy.class.getName(); + SafeExitJVM.class.getName(); + NativeJVMHalt.class.getName(); NativeJVMHalt.initFunc(); isAgentStarted = true; boolean pb = true; boolean rt = true; if (agentArgument != null) { - String trimmedArg = agentArgument.trim(); - if (!trimmedArg.isEmpty()) { - if (trimmedArg.contains("p")) pb = false; - if (trimmedArg.contains("r")) rt = false; - } + String trimmedArg = agentArgument.trim(); + if (!trimmedArg.isEmpty()) { + if (trimmedArg.contains("p")) pb = false; + if (trimmedArg.contains("r")) rt = false; + } } try { - if (ManagementFactory.getOperatingSystemMXBean().getName().startsWith("Windows")) replaceClasses(pb, rt); - else replaceClasses(false, false); + if (ManagementFactory.getOperatingSystemMXBean().getName().startsWith("Windows")) replaceClasses(pb, rt); + else replaceClasses(false, false); } catch (Error e) { - NativeJVMHalt.haltA(294); - throw e; + NativeJVMHalt.haltA(294); + throw e; } } @@ -67,109 +67,112 @@ public static boolean isStarted() { } private static void replaceClasses(boolean pb, boolean rt) { - java.awt.Robot.class.getName(); - List defs = new ArrayList<>(); - if(rt) { - try { - defs.add(new java.lang.instrument.ClassDefinition(java.lang.Runtime.class, transformClass(java.lang.Runtime.class.getName(), getClassFile(java.lang.Runtime.class)))); - } catch(Exception e) { - throw new Error(e); - } - } - if(pb) { - try { - defs.add(new java.lang.instrument.ClassDefinition(java.lang.ProcessBuilder.class, transformClass(java.lang.ProcessBuilder.class.getName(), getClassFile(java.lang.ProcessBuilder.class)))); - } catch(Exception e) { - throw new Error(e); - } - } - try { - defs.add(new java.lang.instrument.ClassDefinition(java.awt.Robot.class, transformClass(java.awt.Robot.class.getName(), getClassFile(java.awt.Robot.class)))); - } catch(Exception e) { - throw new Error(e); - } - try { - inst.redefineClasses(defs.toArray(new java.lang.instrument.ClassDefinition[0])); - } catch(Exception e) { - throw new Error(e); - } - } - - /** + java.awt.Robot.class.getName(); + List defs = new ArrayList<>(); + if (rt) { + try { + defs.add(new java.lang.instrument.ClassDefinition(java.lang.Runtime.class, transformClass(java.lang.Runtime.class.getName(), getClassFile(java.lang.Runtime.class)))); + } catch (Exception e) { + throw new Error(e); + } + } + if (pb) { + try { + defs.add(new java.lang.instrument.ClassDefinition(java.lang.ProcessBuilder.class, transformClass(java.lang.ProcessBuilder.class.getName(), getClassFile(java.lang.ProcessBuilder.class)))); + } catch (Exception e) { + throw new Error(e); + } + } + try { + defs.add(new java.lang.instrument.ClassDefinition(java.awt.Robot.class, transformClass(java.awt.Robot.class.getName(), getClassFile(java.awt.Robot.class)))); + } catch (Exception e) { + throw new Error(e); + } + try { + inst.redefineClasses(defs.toArray(new java.lang.instrument.ClassDefinition[0])); + } catch (Exception e) { + throw new Error(e); + } + } + + /** * @author https://github.com/Konloch/JVM-Sandbox - * Use ASM to modify the byte array - */ - private static byte[] transformClass(String className, byte[] classBytes) { - if (className.equals("java.lang.Runtime")) { - ClassReader cr=new ClassReader(classBytes); - ClassNode cn=new ClassNode(); - cr.accept(cn,ClassReader.EXPAND_FRAMES); - - for (Object o : cn.methods.toArray()) { - MethodNode m = (MethodNode) o; - if(m.name.equals("exec")) { - m.instructions.insert(new InsnNode(ARETURN)); - m.instructions.insert(new InsnNode(ACONST_NULL)); - } - } - ClassWriter cw=new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS); - cn.accept(cw); - return cw.toByteArray(); - } else if (className.equals("java.lang.ProcessBuilder")) { - ClassReader cr=new ClassReader(classBytes); - ClassNode cn=new ClassNode(); - cr.accept(cn,ClassReader.EXPAND_FRAMES); - - for (Object o : cn.methods.toArray()) { - MethodNode m = (MethodNode) o; - if(m.name.equals("start")) { - m.instructions.insert(new InsnNode(ARETURN)); - m.instructions.insert(new InsnNode(ACONST_NULL)); - } - } - ClassWriter cw=new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS); - cn.accept(cw); - return cw.toByteArray(); - } else if (className.equals("java.awt.Robot")) { - ClassReader cr=new ClassReader(classBytes); - ClassNode cn=new ClassNode(); - cr.accept(cn,ClassReader.EXPAND_FRAMES); - - for (Object o : cn.methods.toArray()) { - MethodNode m = (MethodNode) o; - if( m.name.equals("createScreenCapture") || m.name.equals("getPixelColor") || - m.name.equals("keyPress") || m.name.equals("keyRelease") || - m.name.equals("mouseMove") || m.name.equals("mousePress") || - m.name.equals("mouseWheel")) - { - m.instructions.insert(new InsnNode(ARETURN)); - m.instructions.insert(new InsnNode(ACONST_NULL)); - } - } - ClassWriter cw=new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS); - cn.accept(cw); - return cw.toByteArray(); - } - return classBytes; - } - - /** + * Use ASM to modify the byte array + */ + private static byte[] transformClass(String className, byte[] classBytes) { + switch (className) { + case "java.lang.Runtime": { + ClassReader cr = new ClassReader(classBytes); + ClassNode cn = new ClassNode(); + cr.accept(cn, ClassReader.EXPAND_FRAMES); + + for (Object o : cn.methods.toArray()) { + MethodNode m = (MethodNode) o; + if (m.name.equals("exec")) { + m.instructions.insert(new InsnNode(ARETURN)); + m.instructions.insert(new InsnNode(ACONST_NULL)); + } + } + ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS); + cn.accept(cw); + return cw.toByteArray(); + } + case "java.lang.ProcessBuilder": { + ClassReader cr = new ClassReader(classBytes); + ClassNode cn = new ClassNode(); + cr.accept(cn, ClassReader.EXPAND_FRAMES); + + for (Object o : cn.methods.toArray()) { + MethodNode m = (MethodNode) o; + if (m.name.equals("start")) { + m.instructions.insert(new InsnNode(ARETURN)); + m.instructions.insert(new InsnNode(ACONST_NULL)); + } + } + ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS); + cn.accept(cw); + return cw.toByteArray(); + } + case "java.awt.Robot": { + ClassReader cr = new ClassReader(classBytes); + ClassNode cn = new ClassNode(); + cr.accept(cn, ClassReader.EXPAND_FRAMES); + + for (Object o : cn.methods.toArray()) { + MethodNode m = (MethodNode) o; + if (m.name.equals("createScreenCapture") || m.name.equals("getPixelColor") || + m.name.equals("keyPress") || m.name.equals("keyRelease") || + m.name.equals("mouseMove") || m.name.equals("mousePress") || + m.name.equals("mouseWheel")) { + m.instructions.insert(new InsnNode(ARETURN)); + m.instructions.insert(new InsnNode(ACONST_NULL)); + } + } + ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS); + cn.accept(cw); + return cw.toByteArray(); + } + } + return classBytes; + } + + /** + * @param clazz + * @return array, respending this class in bytecode. + * @throws IOException * @author https://github.com/Konloch/JVM-Sandbox * Do not remove this method. Do not to cause classloading! - * Grab the byte array from the loaded Class object - * @param clazz - * @return array, respending this class in bytecode. - * @throws IOException - */ - private static byte[] getClassFile(Class clazz) throws IOException { - try (InputStream is = clazz.getResourceAsStream( "/" + clazz.getName().replace('.', '/') + ".class"); - ByteArrayOutputStream baos = new ByteArrayOutputStream()) { - int r = 0; - byte[] buffer = new byte[8192]; - while((r=is.read(buffer))>=0) { - baos.write(buffer, 0, r); - } - return baos.toByteArray(); - } - } + * Grab the byte array from the loaded Class object + */ + private static byte[] getClassFile(Class clazz) throws IOException { + try (InputStream is = clazz.getResourceAsStream("/" + clazz.getName().replace('.', '/') + ".class"); + ByteArrayOutputStream baos = new ByteArrayOutputStream()) { + int r = 0; + byte[] buffer = new byte[8192]; + while ((r = is.read(buffer)) >= 0) { + baos.write(buffer, 0, r); + } + return baos.toByteArray(); + } + } } diff --git a/Launcher/src/main/java/ru/gravit/launcher/LauncherEngine.java b/Launcher/src/main/java/ru/gravit/launcher/LauncherEngine.java index 0d0a657a..9fcf3a0d 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/LauncherEngine.java +++ b/Launcher/src/main/java/ru/gravit/launcher/LauncherEngine.java @@ -33,9 +33,8 @@ public static void main(String... args) throws Throwable { initGson(); ConsoleManager.initConsole(); LauncherConfig config = Launcher.getConfig(); - if(config.environment.equals(LauncherConfig.LauncherEnvironment.PROD)) - { - if(!LauncherAgent.isStarted()) throw new SecurityException("LauncherAgent must started"); + if (config.environment.equals(LauncherConfig.LauncherEnvironment.PROD)) { + if (!LauncherAgent.isStarted()) throw new SecurityException("LauncherAgent must started"); } long startTime = System.currentTimeMillis(); try { @@ -73,8 +72,7 @@ public void start(String... args) throws Throwable { if (runtimeProvider == null) runtimeProvider = new JSRuntimeProvider(); runtimeProvider.init(false); runtimeProvider.preLoad(); - if(Request.service == null) - { + if (Request.service == null) { String address = Launcher.getConfig().address; LogHelper.debug("Start async connection to %s", address); Request.service = StandartClientWebSocketService.initWebSockets(address, true); diff --git a/Launcher/src/main/java/ru/gravit/launcher/NewLauncherSettings.java b/Launcher/src/main/java/ru/gravit/launcher/NewLauncherSettings.java index dacf9ed6..ffd15b08 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/NewLauncherSettings.java +++ b/Launcher/src/main/java/ru/gravit/launcher/NewLauncherSettings.java @@ -11,6 +11,8 @@ public class NewLauncherSettings { @LauncherAPI public String login; @LauncherAPI + public String auth; + @LauncherAPI public byte[] rsaPassword; @LauncherAPI public int profile; @@ -35,8 +37,8 @@ public class NewLauncherSettings { public List lastProfiles = new LinkedList<>(); @LauncherAPI public Map userSettings = new HashMap<>(); - public static class HashedStoreEntry - { + + public static class HashedStoreEntry { @LauncherAPI public HashedDir hdir; @LauncherAPI @@ -50,15 +52,15 @@ public HashedStoreEntry(HashedDir hdir, String name, String fullPath) { this.fullPath = fullPath; } } + @LauncherAPI public transient List lastHDirs = new ArrayList<>(16); + @LauncherAPI - public void putHDir(String name, Path path, HashedDir dir) - { + public void putHDir(String name, Path path, HashedDir dir) { String fullPath = path.toAbsolutePath().toString(); - for(HashedStoreEntry e : lastHDirs) - { - if(e.fullPath.equals(fullPath) && e.name.equals(name)) return; + for (HashedStoreEntry e : lastHDirs) { + if (e.fullPath.equals(fullPath) && e.name.equals(name)) return; } lastHDirs.add(new HashedStoreEntry(dir, name, fullPath)); } diff --git a/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java b/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java index 721ac7a6..64c155ca 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java +++ b/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java @@ -541,8 +541,7 @@ public static void verifyHDir(Path dir, HashedDir hdir, FileNameMatcher matcher, // Hash directory and compare (ignore update-only matcher entries, it will break offline-mode) HashedDir currentHDir = new HashedDir(dir, matcher, true, digest); HashedDir.Diff diff = hdir.diff(currentHDir, matcher); - if (!diff.isSame()) - { + if (!diff.isSame()) { /*AtomicBoolean isFoundFile = new AtomicBoolean(false); diff.extra.walk(File.separator, (e,k,v) -> { if(v.getType().equals(HashedEntry.Type.FILE)) { LogHelper.error("Extra file %s", e); isFoundFile.set(true); } diff --git a/Launcher/src/main/java/ru/gravit/launcher/client/DirBridge.java b/Launcher/src/main/java/ru/gravit/launcher/client/DirBridge.java index 9a5fad87..16996fd6 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/client/DirBridge.java +++ b/Launcher/src/main/java/ru/gravit/launcher/client/DirBridge.java @@ -68,19 +68,19 @@ public static Path getAppDataDir() throws IOException { public static Path getLauncherDir(String projectname) throws IOException { return getAppDataDir().resolve(projectname); } + @LauncherAPI - public static Path getStoreDir(String projectname) throws IOException - { - if(JVMHelper.OS_TYPE == JVMHelper.OS.LINUX) + public static Path getStoreDir(String projectname) throws IOException { + if (JVMHelper.OS_TYPE == JVMHelper.OS.LINUX) return getAppDataDir().resolve("store"); - else if(JVMHelper.OS_TYPE == JVMHelper.OS.MUSTDIE) + else if (JVMHelper.OS_TYPE == JVMHelper.OS.MUSTDIE) return getAppDataDir().resolve("GravitLauncherStore"); else return getAppDataDir().resolve("minecraftStore"); } + @LauncherAPI - public static Path getProjectStoreDir(String projectname) throws IOException - { + public static Path getProjectStoreDir(String projectname) throws IOException { return getStoreDir(projectname).resolve(projectname); } diff --git a/Launcher/src/main/java/ru/gravit/launcher/client/FunctionalBridge.java b/Launcher/src/main/java/ru/gravit/launcher/client/FunctionalBridge.java index 57f7334c..d7da0a43 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/client/FunctionalBridge.java +++ b/Launcher/src/main/java/ru/gravit/launcher/client/FunctionalBridge.java @@ -29,7 +29,7 @@ public class FunctionalBridge { public static AtomicReference hwid = new AtomicReference<>(); @LauncherAPI public static Thread getHWID = null; - + private static long cachedMemorySize = -1; @LauncherAPI @@ -57,8 +57,8 @@ public static HWID getHWID() { @LauncherAPI public static int getTotalMemory() { - if (cachedMemorySize > 0) return (int)cachedMemorySize; - return (int)(cachedMemorySize = hwidProvider.getTotalMemory() >> 20); + if (cachedMemorySize > 0) return (int) cachedMemorySize; + return (int) (cachedMemorySize = hwidProvider.getTotalMemory() >> 20); } @LauncherAPI @@ -79,21 +79,20 @@ public static int getJVMTotalMemory() { public static HasherStore getDefaultHasherStore() { return HasherManager.getDefaultStore(); } + @LauncherAPI - public static void registerUserSettings(String typename, Class clazz) - { + public static void registerUserSettings(String typename, Class clazz) { UserSettings.providers.register(typename, clazz); } + @LauncherAPI - public static void close() throws Exception - { + public static void close() throws Exception { threadPool.awaitTermination(2, TimeUnit.SECONDS); } @LauncherAPI public static void setAuthParams(AuthRequestEvent event) { - if(event.session != 0) - { + if (event.session != 0) { Request.setSession(event.session); } LauncherGuardManager.guard.setProtectToken(event.protectToken); @@ -105,13 +104,12 @@ public interface HashedDirRunnable { } @LauncherAPI - public static void evalCommand(String cmd) - { + public static void evalCommand(String cmd) { ConsoleManager.handler.eval(cmd, false); } + @LauncherAPI - public static void addPlainOutput(LogHelper.Output output) - { + public static void addPlainOutput(LogHelper.Output output) { LogHelper.addOutput(output, LogHelper.OutputTypes.PLAIN); } } diff --git a/Launcher/src/main/java/ru/gravit/launcher/console/UnlockCommand.java b/Launcher/src/main/java/ru/gravit/launcher/console/UnlockCommand.java index e3943dc9..0a9b5b73 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/console/UnlockCommand.java +++ b/Launcher/src/main/java/ru/gravit/launcher/console/UnlockCommand.java @@ -18,14 +18,11 @@ public String getUsageDescription() { @Override public void invoke(String... args) throws Exception { verifyArgs(args, 1); - if(ConsoleManager.checkUnlockKey(args[0])) - { + if (ConsoleManager.checkUnlockKey(args[0])) { LogHelper.info("Unlock successful"); ConsoleManager.unlock(); ConsoleManager.handler.unregisterCommand("unlock"); - } - else - { + } else { LogHelper.error("Unlock key incorrect"); } } diff --git a/Launcher/src/main/java/ru/gravit/launcher/console/admin/ExecCommand.java b/Launcher/src/main/java/ru/gravit/launcher/console/admin/ExecCommand.java index d4b9a7b4..42520594 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/console/admin/ExecCommand.java +++ b/Launcher/src/main/java/ru/gravit/launcher/console/admin/ExecCommand.java @@ -19,6 +19,6 @@ public String getUsageDescription() { @Override public void invoke(String... args) throws Exception { ExecCommandRequestEvent request = new ExecCommandRequest(String.join(" ", args)).request(); - if(!request.success) LogHelper.error("Error executing command"); + if (!request.success) LogHelper.error("Error executing command"); } } diff --git a/Launcher/src/main/java/ru/gravit/launcher/console/admin/LogListenerCommand.java b/Launcher/src/main/java/ru/gravit/launcher/console/admin/LogListenerCommand.java index a32b71ce..32228c12 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/console/admin/LogListenerCommand.java +++ b/Launcher/src/main/java/ru/gravit/launcher/console/admin/LogListenerCommand.java @@ -8,8 +8,7 @@ import ru.gravit.utils.helper.LogHelper; public class LogListenerCommand extends Command { - public class LogListenerRequest implements RequestInterface - { + public class LogListenerRequest implements RequestInterface { @LauncherNetworkAPI public LogHelper.OutputTypes outputType; @@ -22,6 +21,7 @@ public String getType() { return "addLogListener"; } } + @Override public String getArgsDescription() { return null; @@ -38,15 +38,8 @@ public void invoke(String... args) throws Exception { Request.service.sendObject(new LogListenerRequest(LogHelper.JANSI ? LogHelper.OutputTypes.JANSI : LogHelper.OutputTypes.PLAIN)); LogHelper.info("Add log handler"); Request.service.registerHandler((result) -> { - if(result instanceof LogEvent) - { - LogHelper.rawLog(() -> { - return ((LogEvent) result).string; - }, () -> { - return ((LogEvent) result).string; - }, () -> { - return ((LogEvent) result).string; - }); + if (result instanceof LogEvent) { + LogHelper.rawLog(() -> ((LogEvent) result).string, () -> ((LogEvent) result).string, () -> ((LogEvent) result).string); } }); } diff --git a/Launcher/src/main/java/ru/gravit/launcher/guard/LauncherGuardManager.java b/Launcher/src/main/java/ru/gravit/launcher/guard/LauncherGuardManager.java index 87ef489c..e636dd0d 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/guard/LauncherGuardManager.java +++ b/Launcher/src/main/java/ru/gravit/launcher/guard/LauncherGuardManager.java @@ -10,20 +10,16 @@ public class LauncherGuardManager { public static void initGuard(boolean clientInstance) { LauncherConfig config = Launcher.getConfig(); - switch (config.guardType) - { - case "wrapper": - { + switch (config.guardType) { + case "wrapper": { guard = new LauncherWrapperGuard(); - break; + break; } - case "java": - { + case "java": { guard = new LauncherJavaGuard(); - break; + break; } - default: - { + default: { guard = new LauncherNoGuard(); } } diff --git a/Launcher/src/main/java/ru/gravit/launcher/hwid/OshiHWIDProvider.java b/Launcher/src/main/java/ru/gravit/launcher/hwid/OshiHWIDProvider.java index 5e75d632..3b5ec228 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/hwid/OshiHWIDProvider.java +++ b/Launcher/src/main/java/ru/gravit/launcher/hwid/OshiHWIDProvider.java @@ -83,7 +83,7 @@ public String getMacAddr() { } public long getTotalMemory() { - if (noHWID) return 1024<<20; + if (noHWID) return 1024 << 20; if (hardware == null) hardware = systemInfo.getHardware(); return hardware.getMemory().getTotal(); } diff --git a/Launcher/src/main/java/ru/gravit/launcher/managers/ConsoleManager.java b/Launcher/src/main/java/ru/gravit/launcher/managers/ConsoleManager.java index f34c9de0..0324de64 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/managers/ConsoleManager.java +++ b/Launcher/src/main/java/ru/gravit/launcher/managers/ConsoleManager.java @@ -1,15 +1,15 @@ package ru.gravit.launcher.managers; +import ru.gravit.launcher.console.UnlockCommand; import ru.gravit.launcher.console.admin.ExecCommand; import ru.gravit.launcher.console.admin.LogListenerCommand; import ru.gravit.utils.command.BaseCommandCategory; -import ru.gravit.utils.command.basic.ClearCommand; -import ru.gravit.utils.command.basic.DebugCommand; -import ru.gravit.utils.command.basic.GCCommand; -import ru.gravit.launcher.console.UnlockCommand; import ru.gravit.utils.command.CommandHandler; import ru.gravit.utils.command.JLineCommandHandler; import ru.gravit.utils.command.StdCommandHandler; +import ru.gravit.utils.command.basic.ClearCommand; +import ru.gravit.utils.command.basic.DebugCommand; +import ru.gravit.utils.command.basic.GCCommand; import ru.gravit.utils.command.basic.HelpCommand; import ru.gravit.utils.helper.CommonHelper; import ru.gravit.utils.helper.LogHelper; @@ -19,11 +19,11 @@ public class ConsoleManager { public static CommandHandler handler; public static Thread thread; - public static void initConsole() throws IOException - { + + public static void initConsole() throws IOException { CommandHandler localCommandHandler; try { - Class.forName("jline.Terminal"); + Class.forName("org.jline.terminal.Terminal"); // JLine2 available localCommandHandler = new JLineCommandHandler(); @@ -37,19 +37,19 @@ public static void initConsole() throws IOException thread = CommonHelper.newThread("Launcher Console", true, handler); thread.start(); } - public static void registerCommands() - { + + public static void registerCommands() { handler.registerCommand("help", new HelpCommand(handler)); handler.registerCommand("gc", new GCCommand()); handler.registerCommand("clear", new ClearCommand(handler)); handler.registerCommand("unlock", new UnlockCommand()); } - public static boolean checkUnlockKey(String key) - { + + public static boolean checkUnlockKey(String key) { return true; } - public static void unlock() - { + + public static void unlock() { handler.registerCommand("debug", new DebugCommand()); BaseCommandCategory admin = new BaseCommandCategory(); admin.registerCommand("exec", new ExecCommand()); diff --git a/Launcher/src/main/java/ru/gravit/launcher/managers/SettingsManager.java b/Launcher/src/main/java/ru/gravit/launcher/managers/SettingsManager.java index 180f7da5..61d05238 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/managers/SettingsManager.java +++ b/Launcher/src/main/java/ru/gravit/launcher/managers/SettingsManager.java @@ -3,10 +3,10 @@ import ru.gravit.launcher.LauncherAPI; import ru.gravit.launcher.NewLauncherSettings; import ru.gravit.launcher.client.DirBridge; +import ru.gravit.launcher.config.JsonConfigurable; import ru.gravit.launcher.hasher.HashedDir; import ru.gravit.launcher.serialize.HInput; import ru.gravit.launcher.serialize.HOutput; -import ru.gravit.launcher.config.JsonConfigurable; import ru.gravit.utils.helper.IOHelper; import java.io.IOException; @@ -18,10 +18,8 @@ public class SettingsManager extends JsonConfigurable { public class StoreFileVisitor extends SimpleFileVisitor { @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) - throws IOException - { - try(HInput input = new HInput(IOHelper.newInput(file))) - { + throws IOException { + try (HInput input = new HInput(IOHelper.newInput(file))) { String dirName = input.readString(128); String fullPath = input.readString(1024); HashedDir dir = new HashedDir(input); @@ -31,61 +29,63 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) } } + @LauncherAPI public static NewLauncherSettings settings; public SettingsManager() { super(NewLauncherSettings.class, DirBridge.dir.resolve("settings.json")); } + @LauncherAPI @Override public NewLauncherSettings getConfig() { - if(settings.updatesDir != null) - settings.updatesDirPath = settings.updatesDir.toString(); + if (settings.updatesDir != null) + settings.updatesDirPath = settings.updatesDir.toString(); return settings; } + @LauncherAPI @Override public NewLauncherSettings getDefaultConfig() { return new NewLauncherSettings(); } + @LauncherAPI @Override public void setConfig(NewLauncherSettings config) { settings = config; - if(settings.updatesDirPath != null) - settings.updatesDir = Paths.get(settings.updatesDirPath); + if (settings.updatesDirPath != null) + settings.updatesDir = Paths.get(settings.updatesDirPath); } + @LauncherAPI - public void loadHDirStore(Path storePath) throws IOException - { + public void loadHDirStore(Path storePath) throws IOException { Files.createDirectories(storePath); IOHelper.walk(storePath, new StoreFileVisitor(), false); } + @LauncherAPI - public void saveHDirStore(Path storeProjectPath) throws IOException - { + public void saveHDirStore(Path storeProjectPath) throws IOException { Files.createDirectories(storeProjectPath); - for(NewLauncherSettings.HashedStoreEntry e : settings.lastHDirs) - { + for (NewLauncherSettings.HashedStoreEntry e : settings.lastHDirs) { Path file = storeProjectPath.resolve(e.name.concat(".bin")); - if(!Files.exists(file)) Files.createFile(file); - try(HOutput output = new HOutput(IOHelper.newOutput(file))) - { + if (!Files.exists(file)) Files.createFile(file); + try (HOutput output = new HOutput(IOHelper.newOutput(file))) { output.writeString(e.name, 128); output.writeString(e.fullPath, 1024); e.hdir.write(output); } } } + @LauncherAPI - public void loadHDirStore() throws IOException - { + public void loadHDirStore() throws IOException { loadHDirStore(DirBridge.dirStore); } + @LauncherAPI - public void saveHDirStore() throws IOException - { + public void saveHDirStore() throws IOException { saveHDirStore(DirBridge.dirProjectStore); } diff --git a/Launcher/src/main/java/ru/gravit/launcher/utils/DirWatcher.java b/Launcher/src/main/java/ru/gravit/launcher/utils/DirWatcher.java index 9c0e30bf..ed608f7d 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/utils/DirWatcher.java +++ b/Launcher/src/main/java/ru/gravit/launcher/utils/DirWatcher.java @@ -4,8 +4,8 @@ import ru.gravit.launcher.hasher.FileNameMatcher; import ru.gravit.launcher.hasher.HashedDir; import ru.gravit.launcher.hasher.HashedEntry; -import ru.gravit.launcher.hasher.HashedFile; import ru.gravit.launcher.hasher.HashedEntry.Type; +import ru.gravit.launcher.hasher.HashedFile; import ru.gravit.utils.helper.IOHelper; import ru.gravit.utils.helper.JVMHelper; import ru.gravit.utils.helper.JVMHelper.OS; diff --git a/Launcher/src/main/java/ru/gravit/launcher/utils/NativeJVMHalt.java b/Launcher/src/main/java/ru/gravit/launcher/utils/NativeJVMHalt.java index 4401ceb1..bb215ee7 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/utils/NativeJVMHalt.java +++ b/Launcher/src/main/java/ru/gravit/launcher/utils/NativeJVMHalt.java @@ -14,26 +14,26 @@ public NativeJVMHalt(int haltCode) { public native void aaabbb38C_D(); @SuppressWarnings("null") - private boolean aaabBooleanC_D() { - return (boolean) (Boolean) (Object) null; + private boolean aaabBooleanC_D() { + return (boolean) (Boolean) null; } - + public static void haltA(int code) { NativeJVMHalt halt = new NativeJVMHalt(code); try { - SafeExitJVMLegacy.exit(code); - } catch(Throwable ignored) { - } + SafeExitJVMLegacy.exit(code); + } catch (Throwable ignored) { + } try { - SafeExitJVM.exit(code); - } catch(Throwable ignored) { - } - halt.aaabbb38C_D(); + SafeExitJVM.exit(code); + } catch (Throwable ignored) { + } + halt.aaabbb38C_D(); boolean a = halt.aaabBooleanC_D(); - System.out.println(Boolean.toString(a)); + System.out.println(a); } - + public static boolean initFunc() { - return true; + return true; } } diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/config/JsonConfigurable.java b/LauncherAPI/src/main/java/ru/gravit/launcher/config/JsonConfigurable.java index 0a58295b..5e1883e0 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/config/JsonConfigurable.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/config/JsonConfigurable.java @@ -13,25 +13,30 @@ public abstract class JsonConfigurable { private Type type; protected Path configPath; + @LauncherAPI public void saveConfig() throws IOException { saveConfig(configPath); } + @LauncherAPI public void loadConfig() throws IOException { loadConfig(configPath); } + @LauncherAPI public JsonConfigurable(Type type, Path configPath) { this.type = type; this.configPath = configPath; } + @LauncherAPI public void saveConfig(Path configPath) throws IOException { try (BufferedWriter writer = IOHelper.newWriter(configPath)) { Launcher.gsonManager.gson.toJson(getConfig(), type, writer); } } + @LauncherAPI public void loadConfig(Path configPath) throws IOException { if (generateConfigIfNotExists(configPath)) return; @@ -39,16 +44,19 @@ public void loadConfig(Path configPath) throws IOException { setConfig(Launcher.gsonManager.gson.fromJson(reader, type)); } } + @LauncherAPI public void resetConfig() throws IOException { setConfig(getDefaultConfig()); saveConfig(); } + @LauncherAPI public void resetConfig(Path newPath) throws IOException { setConfig(getDefaultConfig()); saveConfig(newPath); } + @LauncherAPI public boolean generateConfigIfNotExists(Path path) throws IOException { if (IOHelper.isFile(path)) @@ -56,6 +64,7 @@ public boolean generateConfigIfNotExists(Path path) throws IOException { resetConfig(path); return true; } + @LauncherAPI public boolean generateConfigIfNotExists() throws IOException { if (IOHelper.isFile(configPath)) @@ -63,14 +72,17 @@ public boolean generateConfigIfNotExists() throws IOException { resetConfig(); return true; } - protected void setType(Type type) - { + + protected void setType(Type type) { this.type = type; } + @LauncherAPI public abstract T getConfig(); + @LauncherAPI public abstract T getDefaultConfig(); + @LauncherAPI public abstract void setConfig(T config); } diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/downloader/ListDownloader.java b/LauncherAPI/src/main/java/ru/gravit/launcher/downloader/ListDownloader.java index 2b56f0f4..b5350d8d 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/downloader/ListDownloader.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/downloader/ListDownloader.java @@ -1,7 +1,6 @@ package ru.gravit.launcher.downloader; import org.apache.http.HttpResponse; -import org.apache.http.client.ClientProtocolException; import org.apache.http.client.ResponseHandler; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.CloseableHttpClient; @@ -22,17 +21,16 @@ public class ListDownloader { @FunctionalInterface - public interface DownloadCallback - { - void stateChanged(String filename,long downloadedSize, long size); + public interface DownloadCallback { + void stateChanged(String filename, long downloadedSize, long size); } + @FunctionalInterface - public interface DownloadTotalCallback - { + public interface DownloadTotalCallback { void addTotal(long size); } - public static class DownloadTask - { + + public static class DownloadTask { public String apply; public long size; @@ -41,6 +39,7 @@ public DownloadTask(String apply, long size) { this.size = size; } } + public void download(String base, List applies, Path dstDirFile, DownloadCallback callback, DownloadTotalCallback totalCallback) throws IOException, URISyntaxException { try (CloseableHttpClient httpclient = HttpClients.custom() .setRedirectStrategy(new LaxRedirectStrategy()) @@ -49,7 +48,7 @@ public void download(String base, List applies, Path dstDirFile, D HttpGet get = null; for (DownloadTask apply : applies) { URI u = new URL(base.concat(IOHelper.urlEncode(apply.apply).replace("%2F", "/"))).toURI(); - callback.stateChanged(apply.apply,0L, apply.size); + callback.stateChanged(apply.apply, 0L, apply.size); LogHelper.debug("Download URL: %s", u.toString()); if (get == null) get = new HttpGet(u); else { @@ -61,8 +60,7 @@ public void download(String base, List applies, Path dstDirFile, D } } - public void downloadOne(String url, Path target) throws IOException, URISyntaxException - { + public void downloadOne(String url, Path target) throws IOException, URISyntaxException { try (CloseableHttpClient httpclient = HttpClients.custom() .setRedirectStrategy(new LaxRedirectStrategy()) .build()) { @@ -96,20 +94,18 @@ public FileDownloadResponseHandler(Path target, DownloadTask task, DownloadCallb } @Override - public Path handleResponse(HttpResponse response) throws ClientProtocolException, IOException { + public Path handleResponse(HttpResponse response) throws IOException { InputStream source = response.getEntity().getContent(); - if(callback != null && task != null) - { + if (callback != null && task != null) { callback.stateChanged(task.apply, 0, task.size); transfer(source, this.target, task.apply, task.size, callback, totalCallback); - } - else + } else IOHelper.transfer(source, this.target); return this.target; } } - public static void transfer(InputStream input, Path file, String filename, long size, DownloadCallback callback, DownloadTotalCallback totalCallback) throws IOException - { + + public static void transfer(InputStream input, Path file, String filename, long size, DownloadCallback callback, DownloadTotalCallback totalCallback) throws IOException { try (OutputStream fileOutput = IOHelper.newOutput(file)) { long downloaded = 0L; diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/events/request/ErrorRequestEvent.java b/LauncherAPI/src/main/java/ru/gravit/launcher/events/request/ErrorRequestEvent.java index e5101a12..b84584df 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/events/request/ErrorRequestEvent.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/events/request/ErrorRequestEvent.java @@ -12,6 +12,7 @@ public class ErrorRequestEvent extends RequestEvent implements EventInterface { public ErrorRequestEvent(String error) { this.error = error; } + @LauncherNetworkAPI public final String error; diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/events/request/ExecCommandRequestEvent.java b/LauncherAPI/src/main/java/ru/gravit/launcher/events/request/ExecCommandRequestEvent.java index e75d5bad..de6e686c 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/events/request/ExecCommandRequestEvent.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/events/request/ExecCommandRequestEvent.java @@ -8,6 +8,7 @@ public class ExecCommandRequestEvent extends RequestEvent { public String getType() { return "cmdExec"; } + @LauncherNetworkAPI public boolean success; diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/events/request/GetAvailabilityAuthRequestEvent.java b/LauncherAPI/src/main/java/ru/gravit/launcher/events/request/GetAvailabilityAuthRequestEvent.java index af3f068e..8b00427f 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/events/request/GetAvailabilityAuthRequestEvent.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/events/request/GetAvailabilityAuthRequestEvent.java @@ -6,8 +6,7 @@ import java.util.List; public class GetAvailabilityAuthRequestEvent extends RequestEvent { - public static class AuthAvailability - { + public static class AuthAvailability { @LauncherNetworkAPI public String name; @LauncherNetworkAPI @@ -18,6 +17,7 @@ public AuthAvailability(String name, String displayName) { this.displayName = displayName; } } + @LauncherNetworkAPI public List list; diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/events/request/GetSecureTokenRequestEvent.java b/LauncherAPI/src/main/java/ru/gravit/launcher/events/request/GetSecureTokenRequestEvent.java index 936cae82..4b1dd940 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/events/request/GetSecureTokenRequestEvent.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/events/request/GetSecureTokenRequestEvent.java @@ -6,6 +6,7 @@ public class GetSecureTokenRequestEvent extends RequestEvent { @LauncherNetworkAPI public String secureToken; + @Override public String getType() { return "GetSecureToken"; diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/events/request/JoinServerRequestEvent.java b/LauncherAPI/src/main/java/ru/gravit/launcher/events/request/JoinServerRequestEvent.java index d0a88141..6b2c0c38 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/events/request/JoinServerRequestEvent.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/events/request/JoinServerRequestEvent.java @@ -12,6 +12,7 @@ public class JoinServerRequestEvent extends RequestEvent implements EventInterfa public JoinServerRequestEvent(boolean allow) { this.allow = allow; } + @LauncherNetworkAPI public boolean allow; diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/events/request/LauncherRequestEvent.java b/LauncherAPI/src/main/java/ru/gravit/launcher/events/request/LauncherRequestEvent.java index 72efc8a6..958790fd 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/events/request/LauncherRequestEvent.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/events/request/LauncherRequestEvent.java @@ -19,6 +19,7 @@ public LauncherRequestEvent(boolean needUpdate, String url) { this.needUpdate = needUpdate; this.url = url; } + @LauncherNetworkAPI public boolean needUpdate; diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/events/request/LogEvent.java b/LauncherAPI/src/main/java/ru/gravit/launcher/events/request/LogEvent.java index a4de064c..c207eb72 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/events/request/LogEvent.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/events/request/LogEvent.java @@ -8,6 +8,7 @@ public class LogEvent implements ResultInterface { public String getType() { return "log"; } + @LauncherNetworkAPI public String string; diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/events/request/VerifySecureTokenRequestEvent.java b/LauncherAPI/src/main/java/ru/gravit/launcher/events/request/VerifySecureTokenRequestEvent.java index 6eb67e15..bb616d37 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/events/request/VerifySecureTokenRequestEvent.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/events/request/VerifySecureTokenRequestEvent.java @@ -6,6 +6,7 @@ public class VerifySecureTokenRequestEvent extends RequestEvent { @LauncherAPI public boolean success; + @Override public String getType() { return "verifySecureToken"; diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/managers/ConfigManager.java b/LauncherAPI/src/main/java/ru/gravit/launcher/managers/ConfigManager.java index 9ade8c6c..251efb48 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/managers/ConfigManager.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/managers/ConfigManager.java @@ -11,7 +11,7 @@ @SuppressWarnings("rawtypes") public class ConfigManager { - private final HashMap CONFIGURABLE = new HashMap<>(); + private final HashMap CONFIGURABLE = new HashMap<>(); public void registerConfigurable(String name, JsonConfigurable reconfigurable) { VerifyHelper.putIfAbsent(CONFIGURABLE, name.toLowerCase(), Objects.requireNonNull(reconfigurable, "adapter"), diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/profiles/ClientProfile.java b/LauncherAPI/src/main/java/ru/gravit/launcher/profiles/ClientProfile.java index 62d66cfc..38d5ab29 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/profiles/ClientProfile.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/profiles/ClientProfile.java @@ -259,7 +259,7 @@ public void unmarkOptional(OptionalFile file) { file.mark = false; if (file.dependenciesCount != null) { for (OptionalFile f : file.dependenciesCount) { - if(f.isPreset) continue; + if (f.isPreset) continue; unmarkOptional(f); } file.dependenciesCount.clear(); diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/Request.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/Request.java index eb98f3a7..0570ba41 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/Request.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/Request.java @@ -35,9 +35,11 @@ public static void requestError(String message) throws RequestException { public R request() throws Exception { if (!started.compareAndSet(false, true)) throw new IllegalStateException("Request already started"); - if(service == null) service = StandartClientWebSocketService.initWebSockets(Launcher.getConfig().address, false); + if (service == null) + service = StandartClientWebSocketService.initWebSockets(Launcher.getConfig().address, false); return requestDo(service); } + @LauncherAPI public R request(StandartClientWebSocketService service) throws Exception { if (!started.compareAndSet(false, true)) @@ -46,8 +48,7 @@ public R request(StandartClientWebSocketService service) throws Exception { } @SuppressWarnings("unchecked") - protected R requestDo(StandartClientWebSocketService service) throws Exception - { + protected R requestDo(StandartClientWebSocketService service) throws Exception { return (R) service.sendRequest(this); } diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/AuthRequest.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/AuthRequest.java index e694a7b8..899281ba 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/AuthRequest.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/AuthRequest.java @@ -81,6 +81,7 @@ public AuthRequest(String login, byte[] encryptedPassword, String auth_id, Conne this.customText = ""; this.getSession = false; } + public AuthRequest(String login, String password, String auth_id, ConnectTypes authType) { this.login = login; this.password = password; diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/RestoreSessionRequest.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/RestoreSessionRequest.java index 56a93d5f..2b49838d 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/RestoreSessionRequest.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/RestoreSessionRequest.java @@ -5,7 +5,7 @@ import ru.gravit.launcher.request.Request; import ru.gravit.launcher.request.websockets.RequestInterface; -public class RestoreSessionRequest extends Request implements RequestInterface { +public class RestoreSessionRequest extends Request implements RequestInterface { @LauncherNetworkAPI public long session; diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/LauncherRequest.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/LauncherRequest.java index 8980d008..dc0c4ee2 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/LauncherRequest.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/LauncherRequest.java @@ -53,8 +53,7 @@ public static void update(LauncherRequestEvent result) throws IOException { try { ListDownloader downloader = new ListDownloader(); downloader.downloadOne(result.url, BINARY_PATH); - } catch(Throwable e) - { + } catch (Throwable e) { LogHelper.error(e); } } diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/UpdateRequest.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/UpdateRequest.java index c12c4ab9..f7eb00f4 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/UpdateRequest.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/UpdateRequest.java @@ -175,13 +175,11 @@ public UpdateRequestEvent requestDo(StandartClientWebSocketService service) thro HashedDir.Diff diff = e.hdir.diff(localDir, matcher); final List adds = new ArrayList<>(); diff.mismatch.walk(IOHelper.CROSS_SEPARATOR, (path, name, entry) -> { - if(entry.getType().equals(HashedEntry.Type.FILE)) { + if (entry.getType().equals(HashedEntry.Type.FILE)) { HashedFile file = (HashedFile) entry; totalSize += file.size; adds.add(new ListDownloader.DownloadTask(path, file.size)); - } - else if(entry.getType().equals(HashedEntry.Type.DIR)) - { + } else if (entry.getType().equals(HashedEntry.Type.DIR)) { try { Files.createDirectories(dir.resolve(path)); } catch (IOException ex) { @@ -193,9 +191,7 @@ else if(entry.getType().equals(HashedEntry.Type.DIR)) startTime = Instant.now(); updateState("UnknownFile", 0L, 100); ListDownloader listDownloader = new ListDownloader(); - listDownloader.download(e.url, adds, dir, this::updateState, (add) -> { - totalDownloaded += add; - }); + listDownloader.download(e.url, adds, dir, this::updateState, (add) -> totalDownloaded += add); deleteExtraDir(dir, diff.extra, diff.extra.flag); LogHelper.debug("Update success"); return e; diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/uuid/BatchProfileByUsernameRequest.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/uuid/BatchProfileByUsernameRequest.java index 5fe332c3..433e7aaa 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/uuid/BatchProfileByUsernameRequest.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/uuid/BatchProfileByUsernameRequest.java @@ -18,14 +18,14 @@ class Entry { @LauncherNetworkAPI String client; } + @LauncherNetworkAPI private final Entry[] list; @LauncherAPI public BatchProfileByUsernameRequest(String... usernames) throws IOException { this.list = new Entry[usernames.length]; - for(int i=0;i cls = service.getRequestClass(typename); - if(cls == null) - { + if (cls == null) { LogHelper.error("Request type %s not found", typename); } diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/JsonResultAdapter.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/JsonResultAdapter.java index 0eea6a7b..a1f4c6e2 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/JsonResultAdapter.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/JsonResultAdapter.java @@ -18,8 +18,7 @@ public JsonResultAdapter(ClientWebSocketService service) { public ResultInterface deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { String typename = json.getAsJsonObject().getAsJsonPrimitive(PROP_NAME).getAsString(); Class cls = service.getResultClass(typename); - if(cls == null) - { + if (cls == null) { LogHelper.error("Result type %s not found", typename); } diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/StandartClientWebSocketService.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/StandartClientWebSocketService.java index 54ac6940..a5372c44 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/StandartClientWebSocketService.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/StandartClientWebSocketService.java @@ -16,20 +16,20 @@ public class StandartClientWebSocketService extends ClientWebSocketService { public WaitEventHandler waitEventHandler = new WaitEventHandler(); + public StandartClientWebSocketService(GsonBuilder gsonBuilder, String address, int i) throws SSLException { super(gsonBuilder, address, i); } - public class RequestFuture implements Future - { + + public class RequestFuture implements Future { public final WaitEventHandler.ResultEvent event; public boolean isCanceled = false; @SuppressWarnings("rawtypes") - public RequestFuture(RequestInterface request) throws IOException { + public RequestFuture(RequestInterface request) throws IOException { event = new WaitEventHandler.ResultEvent(); event.type = request.getType(); - if(request instanceof Request) - { + if (request instanceof Request) { event.uuid = ((Request) request).requestUUID; } waitEventHandler.requests.add(event); @@ -55,7 +55,7 @@ public boolean isDone() { @Override public ResultInterface get() throws InterruptedException, ExecutionException { - if(isCanceled) return null; + if (isCanceled) return null; while (!event.ready) { synchronized (event) { event.wait(); @@ -72,7 +72,7 @@ public ResultInterface get() throws InterruptedException, ExecutionException { @Override public ResultInterface get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException { - if(isCanceled) return null; + if (isCanceled) return null; while (!event.ready) { synchronized (event) { event.wait(timeout); @@ -87,6 +87,7 @@ public ResultInterface get(long timeout, TimeUnit unit) throws InterruptedExcept return result; } } + public ResultInterface sendRequest(RequestInterface request) throws IOException, InterruptedException { RequestFuture future = new RequestFuture(request); ResultInterface result; @@ -97,6 +98,7 @@ public ResultInterface sendRequest(RequestInterface request) throws IOException, } return result; } + public RequestFuture asyncSendRequest(RequestInterface request) throws IOException { return new RequestFuture(request); } @@ -112,17 +114,14 @@ public static StandartClientWebSocketService initWebSockets(String address, bool service.registerResults(); service.registerRequests(); service.registerHandler(service.waitEventHandler); - if(!async) - { + if (!async) { try { service.open(); LogHelper.debug("Connect to %s", address); } catch (Exception e) { e.printStackTrace(); } - } - else - { + } else { try { service.open(); } catch (Exception e) { diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/WaitEventHandler.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/WaitEventHandler.java index 862aef60..4bcf3835 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/WaitEventHandler.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/WaitEventHandler.java @@ -14,17 +14,16 @@ public class WaitEventHandler implements ClientWebSocketService.EventHandler { public void process(ResultInterface result) { LogHelper.debug("Processing event %s type", result.getType()); UUID checkUUID = null; - if(result instanceof RequestEvent) - { + if (result instanceof RequestEvent) { RequestEvent event = (RequestEvent) result; checkUUID = event.requestUUID; - if(checkUUID != null) - LogHelper.debug("Event UUID: %s found", checkUUID.toString()); + if (checkUUID != null) + LogHelper.debug("Event UUID: %s found", checkUUID.toString()); } for (ResultEvent r : requests) { - if(r.uuid != null) + if (r.uuid != null) LogHelper.debug("Request UUID found: %s", r.uuid.toString()); - if( (r.uuid != null && r.uuid.equals(checkUUID)) || ( checkUUID == null && (r.type.equals(result.getType()) || result.getType().equals("error") )) ) { + if ((r.uuid != null && r.uuid.equals(checkUUID)) || (checkUUID == null && (r.type.equals(result.getType()) || result.getType().equals("error")))) { LogHelper.debug("Event %s type", r.type); synchronized (r) { r.result = result; diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/WebSocketClientHandler.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/WebSocketClientHandler.java index 7d185225..1f21cc48 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/WebSocketClientHandler.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/WebSocketClientHandler.java @@ -1,19 +1,11 @@ package ru.gravit.launcher.request.websockets; -import io.netty.channel.Channel; -import io.netty.channel.ChannelFuture; -import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelPromise; -import io.netty.channel.SimpleChannelInboundHandler; +import io.netty.channel.*; import io.netty.handler.codec.http.FullHttpResponse; -import io.netty.handler.codec.http.websocketx.BinaryWebSocketFrame; -import io.netty.handler.codec.http.websocketx.CloseWebSocketFrame; -import io.netty.handler.codec.http.websocketx.PongWebSocketFrame; -import io.netty.handler.codec.http.websocketx.TextWebSocketFrame; -import io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker; -import io.netty.handler.codec.http.websocketx.WebSocketFrame; +import io.netty.handler.codec.http.websocketx.*; import io.netty.util.CharsetUtil; import ru.gravit.utils.helper.LogHelper; + public class WebSocketClientHandler extends SimpleChannelInboundHandler { private final WebSocketClientHandshaker handshaker; diff --git a/LauncherTest/build.gradle b/LauncherTest/build.gradle index 28530075..26dd0c86 100644 --- a/LauncherTest/build.gradle +++ b/LauncherTest/build.gradle @@ -1,6 +1,6 @@ apply from: '../test_support.gradle' dependencies { - compile project(':LaunchServer') + compile project(':LaunchServer') } diff --git a/LauncherTest/src/test/java/ru/gravit/launcher/StartTest.java b/LauncherTest/src/test/java/ru/gravit/launcher/StartTest.java index 8b546a8c..2cc2273a 100644 --- a/LauncherTest/src/test/java/ru/gravit/launcher/StartTest.java +++ b/LauncherTest/src/test/java/ru/gravit/launcher/StartTest.java @@ -1,36 +1,35 @@ package ru.gravit.launcher; -import java.io.IOException; -import java.nio.file.Path; -import java.security.spec.InvalidKeySpecException; - import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; - import ru.gravit.launcher.test.utils.EXENonWarningLauncherBinary; import ru.gravit.launchserver.LaunchServer; import ru.gravit.utils.helper.LogHelper; +import java.io.IOException; +import java.nio.file.Path; +import java.security.spec.InvalidKeySpecException; + public class StartTest { @TempDir public Path dir; @BeforeAll public static void prepare() { - LogHelper.removeStdOutput(); - LaunchServer.defaultLauncherEXEBinaryClass = EXENonWarningLauncherBinary.class; + LogHelper.removeStdOutput(); + LaunchServer.defaultLauncherEXEBinaryClass = EXENonWarningLauncherBinary.class; + } + + @Test + public void checkLaunchServerStarts() { + try { + LaunchServer srv = new LaunchServer(dir, true, new String[]{"checkInstall"}); + srv.run(); + srv.commandHandler.eval(new String[]{"checkInstall"}, false); + srv.close(); + } catch (InvalidKeySpecException | IOException e) { + throw new RuntimeException(e); + } } - - @Test - public void checkLaunchServerStarts() { - try { - LaunchServer srv = new LaunchServer(dir, true, new String[] { "checkInstall" }); - srv.run(); - srv.commandHandler.eval(new String[] { "checkInstall" }, false); - srv.close(); - } catch (InvalidKeySpecException | IOException e) { - throw new RuntimeException(e); - } - } } diff --git a/Radon b/Radon index 6410af80..60fa1c66 160000 --- a/Radon +++ b/Radon @@ -1 +1 @@ -Subproject commit 6410af8044e7346e06f546dc04636b631fa7584c +Subproject commit 60fa1c6694b570dda50056b1e2fe18fcdb0f8be0 diff --git a/ServerWrapper/build.gradle b/ServerWrapper/build.gradle index 323147c2..130f0c57 100644 --- a/ServerWrapper/build.gradle +++ b/ServerWrapper/build.gradle @@ -4,8 +4,8 @@ String mainAgentName = "ru.gravit.launcher.server.ServerAgent" configurations { - pack - compile.extendsFrom pack + pack + compile.extendsFrom pack } repositories { @@ -18,7 +18,7 @@ targetCompatibility = '1.8' jar { - classifier = 'clean' + classifier = 'clean' manifest.attributes("Main-Class": mainClassName, "Premain-Class": mainAgentName, "Can-Redefine-Classes": "true", @@ -28,17 +28,17 @@ dependencies { pack project(':LauncherAuthlib') - pack 'org.apache.httpcomponents:httpclient:4.5.7' - pack 'io.netty:netty-all:4.1.36.Final' + pack 'org.apache.httpcomponents:httpclient:4.5.7' + pack 'io.netty:netty-all:4.1.36.Final' } shadowJar { - classifier = null - relocate 'io.netty', 'ru.gravit.repackage.io.netty' - configurations = [project.configurations.pack] - exclude 'module-info.class' - } - + classifier = null + relocate 'io.netty', 'ru.gravit.repackage.io.netty' + configurations = [project.configurations.pack] + exclude 'module-info.class' +} - build.dependsOn tasks.shadowJar + +build.dependsOn tasks.shadowJar \ No newline at end of file diff --git a/ServerWrapper/src/main/java/ru/gravit/launcher/server/ServerWrapper.java b/ServerWrapper/src/main/java/ru/gravit/launcher/server/ServerWrapper.java index abc1f8ef..9665347b 100644 --- a/ServerWrapper/src/main/java/ru/gravit/launcher/server/ServerWrapper.java +++ b/ServerWrapper/src/main/java/ru/gravit/launcher/server/ServerWrapper.java @@ -3,6 +3,7 @@ import ru.gravit.launcher.ClientPermissions; import ru.gravit.launcher.Launcher; import ru.gravit.launcher.LauncherConfig; +import ru.gravit.launcher.config.JsonConfigurable; import ru.gravit.launcher.events.request.ProfilesRequestEvent; import ru.gravit.launcher.profiles.ClientProfile; import ru.gravit.launcher.request.Request; @@ -11,7 +12,6 @@ import ru.gravit.launcher.request.update.ProfilesRequest; import ru.gravit.launcher.server.setup.ServerWrapperSetup; import ru.gravit.utils.PublicURLClassLoader; -import ru.gravit.launcher.config.JsonConfigurable; import ru.gravit.utils.helper.CommonHelper; import ru.gravit.utils.helper.IOHelper; import ru.gravit.utils.helper.LogHelper; @@ -157,8 +157,7 @@ public void run(String... args) throws Throwable { else mainClass = Class.forName(classname); MethodHandle mainMethod = MethodHandles.publicLookup().findStatic(mainClass, "main", MethodType.methodType(void.class, String[].class)); modulesManager.postInitModules(); - if(config.websocket.enabled) - { + if (config.websocket.enabled) { Request.service.reconnectCallback = () -> { LogHelper.debug("WebSocket connect closed. Try reconnect"); @@ -194,8 +193,7 @@ public void updateLauncherConfig() { LauncherConfig cfg = null; try { cfg = new LauncherConfig(config.websocket.address, SecurityHelper.toPublicRSAKey(IOHelper.read(publicKeyFile)), new HashMap<>(), config.projectname); - if(config.websocket != null && config.websocket.enabled) - { + if (config.websocket != null && config.websocket.enabled) { cfg.isNettyEnabled = true; cfg.address = config.websocket.address; } @@ -261,8 +259,8 @@ public static final class Config { public String auth_id = ""; public LauncherConfig.LauncherEnvironment env; } - public static final class WebSocketConf - { + + public static final class WebSocketConf { public boolean enabled; public String address; } diff --git a/ServerWrapper/src/main/java/ru/gravit/launcher/server/setup/ServerWrapperCommands.java b/ServerWrapper/src/main/java/ru/gravit/launcher/server/setup/ServerWrapperCommands.java index b0f51e17..015b22b0 100644 --- a/ServerWrapper/src/main/java/ru/gravit/launcher/server/setup/ServerWrapperCommands.java +++ b/ServerWrapper/src/main/java/ru/gravit/launcher/server/setup/ServerWrapperCommands.java @@ -22,7 +22,7 @@ public ServerWrapperCommands() throws IOException { // Set command handler CommandHandler localCommandHandler; try { - Class.forName("jline.Terminal"); + Class.forName("org.jline.terminal.Terminal"); // JLine2 available localCommandHandler = new JLineCommandHandler(); diff --git a/ServerWrapper/src/main/java/ru/gravit/launcher/server/setup/ServerWrapperSetup.java b/ServerWrapper/src/main/java/ru/gravit/launcher/server/setup/ServerWrapperSetup.java index 195d49ab..1f3d4713 100644 --- a/ServerWrapper/src/main/java/ru/gravit/launcher/server/setup/ServerWrapperSetup.java +++ b/ServerWrapper/src/main/java/ru/gravit/launcher/server/setup/ServerWrapperSetup.java @@ -25,14 +25,14 @@ public void run() throws IOException { Path jarPath = Paths.get(jarName); String mainClassName = null; try (JarFile file = new JarFile(jarPath.toFile())) { - URL jarURL = jarPath.toUri().toURL(); - urlClassLoader = new PublicURLClassLoader(new URL[]{jarURL}); - LogHelper.info("Check jar MainClass"); - mainClassName = file.getManifest().getMainAttributes().getValue("Main-Class"); - if (mainClassName == null) { - LogHelper.error("Main-Class not found in MANIFEST"); - return; - } + URL jarURL = jarPath.toUri().toURL(); + urlClassLoader = new PublicURLClassLoader(new URL[]{jarURL}); + LogHelper.info("Check jar MainClass"); + mainClassName = file.getManifest().getMainAttributes().getValue("Main-Class"); + if (mainClassName == null) { + LogHelper.error("Main-Class not found in MANIFEST"); + return; + } try { Class.forName(mainClassName, false, urlClassLoader); } catch (ClassNotFoundException e) { diff --git a/build.gradle b/build.gradle index e74d1eab..a14b4905 100644 --- a/build.gradle +++ b/build.gradle @@ -3,33 +3,33 @@ } configure(subprojects.findAll { it.name != 'modules' && it.name != 'Radon' }) { - apply plugin: 'idea' - apply plugin: 'eclipse' - apply plugin: 'java' + apply plugin: 'idea' + apply plugin: 'eclipse' + apply plugin: 'java' group = 'ru.gravit' - repositories { - mavenCentral() - maven { url 'http://oss.sonatype.org/content/groups/public' } - maven { - url "http://clojars.org/repo/" - } - } + repositories { + mavenCentral() + maven { url 'http://oss.sonatype.org/content/groups/public' } + maven { + url "http://clojars.org/repo/" + } + } - configurations { - apt - aptCompileOnly - aptOnly - aptOnly.extendsFrom apt, aptCompileOnly - compile.extendsFrom apt - compileOnly.extendsFrom aptCompileOnly - } + configurations { + apt + aptCompileOnly + aptOnly + aptOnly.extendsFrom apt, aptCompileOnly + compile.extendsFrom apt + compileOnly.extendsFrom aptCompileOnly + } - tasks.withType(JavaCompile) { - options.encoding = "UTF-8" - options.annotationProcessorPath = configurations.aptOnly - } + tasks.withType(JavaCompile) { + options.encoding = "UTF-8" + options.annotationProcessorPath = configurations.aptOnly + } } subprojects { @@ -39,7 +39,7 @@ } wrapper { - distributionType = Wrapper.DistributionType.ALL + distributionType = Wrapper.DistributionType.ALL } defaultTasks 'build' diff --git a/libLauncher/build.gradle b/libLauncher/build.gradle index e5db09f7..d143c15a 100644 --- a/libLauncher/build.gradle +++ b/libLauncher/build.gradle @@ -2,7 +2,9 @@ targetCompatibility = '1.8' dependencies { - compileOnly 'org.fusesource.jansi:jansi:1.17.1' - compileOnly 'jline:jline:2.14.6' - compile 'com.google.code.gson:gson:2.8.5' + compileOnly 'org.fusesource.jansi:jansi:1.18' + compileOnly 'org.jline:jline:3.11.0' + compileOnly 'org.jline:jline-reader:3.11.0' + compileOnly 'org.jline:jline-terminal:3.11.0' + compile 'com.google.code.gson:gson:2.8.5' } diff --git a/libLauncher/src/main/java/ru/gravit/launcher/hasher/HashedDir.java b/libLauncher/src/main/java/ru/gravit/launcher/hasher/HashedDir.java index 699f9474..5db3d36f 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/hasher/HashedDir.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/hasher/HashedDir.java @@ -101,6 +101,7 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IO return super.visitFile(file, attrs); } } + @LauncherNetworkAPI private final Map map = new HashMap<>(32); @@ -336,35 +337,31 @@ public void write(HOutput output) throws IOException { entry.write(output); } } - public void walk(CharSequence separator, WalkCallback callback) - { + + public void walk(CharSequence separator, WalkCallback callback) { String append = ""; - walk(append,separator, callback, true); + walk(append, separator, callback, true); } + @FunctionalInterface - public interface WalkCallback - { + public interface WalkCallback { void walked(String path, String name, HashedEntry entry); } - private void walk(String append, CharSequence separator, WalkCallback callback , boolean noSeparator) - { - for(Map.Entry entry : map.entrySet()) - { + + private void walk(String append, CharSequence separator, WalkCallback callback, boolean noSeparator) { + for (Map.Entry entry : map.entrySet()) { HashedEntry e = entry.getValue(); - if(e.getType() == Type.FILE) - { - if(noSeparator) + if (e.getType() == Type.FILE) { + if (noSeparator) callback.walked(append + entry.getKey(), entry.getKey(), e); else callback.walked(append + separator + entry.getKey(), entry.getKey(), e); - } - else - { + } else { String newAppend; - if(noSeparator) newAppend = append + entry.getKey(); + if (noSeparator) newAppend = append + entry.getKey(); else newAppend = append + separator + entry.getKey(); callback.walked(newAppend, entry.getKey(), e); - ((HashedDir)e).walk(newAppend, separator, callback, false); + ((HashedDir) e).walk(newAppend, separator, callback, false); } } } diff --git a/libLauncher/src/main/java/ru/gravit/launcher/managers/GsonManager.java b/libLauncher/src/main/java/ru/gravit/launcher/managers/GsonManager.java index a8331679..bf89bb33 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/managers/GsonManager.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/managers/GsonManager.java @@ -10,8 +10,8 @@ public class GsonManager { public Gson gson; public GsonBuilder configGsonBuilder; public Gson configGson; - public void initGson() - { + + public void initGson() { gsonBuilder = new GsonBuilder(); configGsonBuilder = new GsonBuilder(); configGsonBuilder.setPrettyPrinting(); @@ -22,16 +22,16 @@ public void initGson() gson = gsonBuilder.create(); configGson = configGsonBuilder.create(); } - public void registerAdapters(GsonBuilder builder) - { + + public void registerAdapters(GsonBuilder builder) { builder.registerTypeAdapter(HashedEntry.class, new HashedEntryAdapter()); } - public void preConfigGson(GsonBuilder gsonBuilder) - { + + public void preConfigGson(GsonBuilder gsonBuilder) { //skip } - public void preGson(GsonBuilder gsonBuilder) - { + + public void preGson(GsonBuilder gsonBuilder) { //skip } } diff --git a/libLauncher/src/main/java/ru/gravit/launcher/modules/Module.java b/libLauncher/src/main/java/ru/gravit/launcher/modules/Module.java index 4d39b41a..da44ff2f 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/modules/Module.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/modules/Module.java @@ -18,5 +18,5 @@ public interface Module extends AutoCloseable { default void finish(ModuleContext context) { // NOP - }; + } } diff --git a/libLauncher/src/main/java/ru/gravit/utils/BiHookSet.java b/libLauncher/src/main/java/ru/gravit/utils/BiHookSet.java index 012483ba..f204b10d 100644 --- a/libLauncher/src/main/java/ru/gravit/utils/BiHookSet.java +++ b/libLauncher/src/main/java/ru/gravit/utils/BiHookSet.java @@ -3,26 +3,25 @@ import java.util.HashSet; import java.util.Set; -public class BiHookSet { - public Set> list = new HashSet<>(); +public class BiHookSet { + public Set> list = new HashSet<>(); + @FunctionalInterface - public interface Hook - { + public interface Hook { boolean hook(V object, R context) throws HookException; } - public void registerHook(Hook hook) - { + + public void registerHook(Hook hook) { list.add(hook); } - public boolean unregisterHook(Hook hook) - { + + public boolean unregisterHook(Hook hook) { return list.remove(hook); } - public boolean hook(V context, R object) throws HookException - { - for(Hook hook : list) - { - if(hook.hook(context, object)) return true; + + public boolean hook(V context, R object) throws HookException { + for (Hook hook : list) { + if (hook.hook(context, object)) return true; } return false; } diff --git a/libLauncher/src/main/java/ru/gravit/utils/HTTPRequest.java b/libLauncher/src/main/java/ru/gravit/utils/HTTPRequest.java index 60ff2b44..cb8fc713 100644 --- a/libLauncher/src/main/java/ru/gravit/utils/HTTPRequest.java +++ b/libLauncher/src/main/java/ru/gravit/utils/HTTPRequest.java @@ -3,6 +3,7 @@ import com.google.gson.JsonElement; import com.google.gson.JsonParser; import ru.gravit.utils.helper.IOHelper; +import ru.gravit.utils.helper.LogHelper; import java.io.IOException; import java.io.InputStreamReader; @@ -61,6 +62,10 @@ public static JsonElement jsonRequest(JsonElement request, URL url) throws IOExc try { return parser.parse(reader); } catch (Exception e) { + if (200 > statusCode || statusCode > 300) { + LogHelper.error("JsonRequest failed. Server response code %d", statusCode); + throw new IOException(e); + } return null; } } diff --git a/libLauncher/src/main/java/ru/gravit/utils/HookException.java b/libLauncher/src/main/java/ru/gravit/utils/HookException.java index 07841f39..3fa56a8b 100644 --- a/libLauncher/src/main/java/ru/gravit/utils/HookException.java +++ b/libLauncher/src/main/java/ru/gravit/utils/HookException.java @@ -1,7 +1,7 @@ package ru.gravit.utils; public class HookException extends RuntimeException { - private static final long serialVersionUID = -529141998961943161L; + private static final long serialVersionUID = -529141998961943161L; public HookException(String message) { super(message); diff --git a/libLauncher/src/main/java/ru/gravit/utils/HookSet.java b/libLauncher/src/main/java/ru/gravit/utils/HookSet.java index 38053667..cd15470b 100644 --- a/libLauncher/src/main/java/ru/gravit/utils/HookSet.java +++ b/libLauncher/src/main/java/ru/gravit/utils/HookSet.java @@ -5,24 +5,23 @@ public class HookSet { public Set> list = new HashSet<>(); + @FunctionalInterface - public interface Hook - { + public interface Hook { boolean hook(R context) throws HookException; } - public void registerHook(Hook hook) - { + + public void registerHook(Hook hook) { list.add(hook); } - public boolean unregisterHook(Hook hook) - { + + public boolean unregisterHook(Hook hook) { return list.remove(hook); } - public boolean hook(R context) throws HookException - { - for(Hook hook : list) - { - if(hook.hook(context)) return true; + + public boolean hook(R context) throws HookException { + for (Hook hook : list) { + if (hook.hook(context)) return true; } return false; } diff --git a/libLauncher/src/main/java/ru/gravit/utils/HttpDownloader.java b/libLauncher/src/main/java/ru/gravit/utils/HttpDownloader.java index 504f8f3f..efb58d97 100644 --- a/libLauncher/src/main/java/ru/gravit/utils/HttpDownloader.java +++ b/libLauncher/src/main/java/ru/gravit/utils/HttpDownloader.java @@ -41,7 +41,7 @@ public synchronized String getFilename() { public void downloadFile(URL url, String file) throws IOException { try (BufferedInputStream in = new BufferedInputStream(url.openStream()); FileOutputStream fout = new FileOutputStream(file)) { - final byte data[] = new byte[BUFER_SIZE]; + final byte[] data = new byte[BUFER_SIZE]; int count; long timestamp = System.currentTimeMillis(); int writed_local = 0; diff --git a/libLauncher/src/main/java/ru/gravit/utils/ProviderMap.java b/libLauncher/src/main/java/ru/gravit/utils/ProviderMap.java index 4d806dab..2b744cb6 100644 --- a/libLauncher/src/main/java/ru/gravit/utils/ProviderMap.java +++ b/libLauncher/src/main/java/ru/gravit/utils/ProviderMap.java @@ -18,8 +18,8 @@ public ProviderMap(String name) { public ProviderMap() { this.name = "Unnamed"; } - public String getName() - { + + public String getName() { return name; } @@ -39,8 +39,8 @@ public String getName(Class clazz) { } return null; } - public Class unregister(String name) - { + + public Class unregister(String name) { return PROVIDERS.remove(name); } } diff --git a/libLauncher/src/main/java/ru/gravit/utils/Version.java b/libLauncher/src/main/java/ru/gravit/utils/Version.java index ade6065a..5f5da60f 100644 --- a/libLauncher/src/main/java/ru/gravit/utils/Version.java +++ b/libLauncher/src/main/java/ru/gravit/utils/Version.java @@ -18,8 +18,8 @@ public final class Version { public static final int MAJOR = 5; public static final int MINOR = 0; public static final int PATCH = 0; - public static final int BUILD = 6; - public static final Version.Type RELEASE = Version.Type.BETA; + public static final int BUILD = 7; + public static final Version.Type RELEASE = Version.Type.STABLE; @LauncherAPI public Version(int major, int minor, int patch) { diff --git a/libLauncher/src/main/java/ru/gravit/utils/command/BaseCommandCategory.java b/libLauncher/src/main/java/ru/gravit/utils/command/BaseCommandCategory.java index c501f926..41d1d157 100644 --- a/libLauncher/src/main/java/ru/gravit/utils/command/BaseCommandCategory.java +++ b/libLauncher/src/main/java/ru/gravit/utils/command/BaseCommandCategory.java @@ -8,6 +8,7 @@ public class BaseCommandCategory implements CommandCategory { private final Map commands = new ConcurrentHashMap<>(32); + @Override public void registerCommand(String name, Command command) { VerifyHelper.verifyIDName(name); diff --git a/libLauncher/src/main/java/ru/gravit/utils/command/CommandCategory.java b/libLauncher/src/main/java/ru/gravit/utils/command/CommandCategory.java index 4566493c..6f4754e1 100644 --- a/libLauncher/src/main/java/ru/gravit/utils/command/CommandCategory.java +++ b/libLauncher/src/main/java/ru/gravit/utils/command/CommandCategory.java @@ -4,7 +4,10 @@ public interface CommandCategory { void registerCommand(String name, Command command); + Command unregisterCommand(String name); + Command findCommand(String name); + Map commandsMap(); } diff --git a/libLauncher/src/main/java/ru/gravit/utils/command/CommandHandler.java b/libLauncher/src/main/java/ru/gravit/utils/command/CommandHandler.java index f5373c81..c25bfe6b 100644 --- a/libLauncher/src/main/java/ru/gravit/utils/command/CommandHandler.java +++ b/libLauncher/src/main/java/ru/gravit/utils/command/CommandHandler.java @@ -7,13 +7,13 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.Map; public abstract class CommandHandler implements Runnable { private final List categories = new ArrayList<>(); private final CommandCategory baseCategory = new BaseCommandCategory(); - public static class Category - { + public static class Category { public CommandCategory category; public String name; public String description; @@ -77,15 +77,13 @@ public Command lookup(String name) throws CommandException { throw new CommandException(String.format("Unknown command: '%s'", name)); return command; } - public Command findCommand(String name) - { + + public Command findCommand(String name) { Command cmd = baseCategory.findCommand(name); - if(cmd == null) - { - for(Category entry : categories) - { + if (cmd == null) { + for (Category entry : categories) { cmd = entry.category.findCommand(name); - if(cmd != null) return cmd; + if (cmd != null) return cmd; } } return cmd; @@ -104,17 +102,16 @@ public void registerCommand(String name, Command command) { baseCategory.registerCommand(name, command); } - public void registerCategory(Category category) - { + public void registerCategory(Category category) { categories.add(category); } - public boolean unregisterCategory(Category category) - { + + public boolean unregisterCategory(Category category) { return categories.remove(category); } - public Category findCategory(String name) - { - for(Category category : categories) if(category.name.equals(name)) return category; + + public Category findCategory(String name) { + for (Category category : categories) if (category.name.equals(name)) return category; return null; } @@ -131,6 +128,20 @@ public void run() { } } + @FunctionalInterface + public interface CommandWalk { + void walk(Category category, String name, Command command); + } + + public void walk(CommandWalk callback) { + for (CommandHandler.Category category : getCategories()) { + for (Map.Entry entry : category.category.commandsMap().entrySet()) + callback.walk(category, entry.getKey(), entry.getValue()); + } + for (Map.Entry entry : getBaseCategory().commandsMap().entrySet()) + callback.walk(null, entry.getKey(), entry.getValue()); + } + public CommandCategory getBaseCategory() { return baseCategory; } diff --git a/libLauncher/src/main/java/ru/gravit/utils/command/JLineCommandHandler.java b/libLauncher/src/main/java/ru/gravit/utils/command/JLineCommandHandler.java index 504393b7..33f678ed 100644 --- a/libLauncher/src/main/java/ru/gravit/utils/command/JLineCommandHandler.java +++ b/libLauncher/src/main/java/ru/gravit/utils/command/JLineCommandHandler.java @@ -1,13 +1,15 @@ package ru.gravit.utils.command; -import jline.console.ConsoleReader; -import ru.gravit.utils.helper.LogHelper; -import ru.gravit.utils.helper.LogHelper.Output; +import org.jline.reader.*; +import org.jline.terminal.Terminal; +import org.jline.terminal.TerminalBuilder; +import org.jline.utils.InfoCmp; import java.io.IOException; +import java.util.List; public class JLineCommandHandler extends CommandHandler { - private final class JLineOutput implements Output { + /*private final class JLineOutput implements Output { @Override public void println(String message) { try { @@ -18,34 +20,62 @@ public void println(String message) { // Ignored } } - } + }*/ - private final ConsoleReader reader; + private final Terminal terminal; + private final TerminalBuilder terminalBuilder; + private final Completer completer; + private final LineReader reader; + + public class JLineConsoleCompleter implements Completer { + @Override + public void complete(LineReader reader, ParsedLine line, List candidates) { + String completeWord = line.word(); + if (line.wordIndex() != 0) return; + walk((category, name, command) -> { + if (name.startsWith(completeWord)) { + candidates.add(new Candidate(name)); + } + }); + } + } public JLineCommandHandler() throws IOException { super(); + terminalBuilder = TerminalBuilder.builder(); + terminal = terminalBuilder.build(); + completer = new JLineConsoleCompleter(); + reader = LineReaderBuilder.builder() + .terminal(terminal) + .completer(completer) + .build(); // Set reader - reader = new ConsoleReader(); - reader.setExpandEvents(false); + //reader = new ConsoleReader(); + //reader.setExpandEvents(false); // Replace writer - LogHelper.removeStdOutput(); - LogHelper.addOutput(new JLineOutput(), LogHelper.OutputTypes.JANSI); + //LogHelper.removeStdOutput(); + //LogHelper.addOutput(new JLineOutput(), LogHelper.OutputTypes.JANSI); } @Override public void bell() throws IOException { - reader.beep(); + terminal.puts(InfoCmp.Capability.bell); + //reader.beep(); } @Override public void clear() throws IOException { - reader.clearScreen(); + terminal.puts(InfoCmp.Capability.clear_screen); } @Override public String readLine() throws IOException { - return reader.readLine(); + try { + return reader.readLine(); + } catch (UserInterruptException e) { + return null; + } } } diff --git a/libLauncher/src/main/java/ru/gravit/utils/command/basic/ClearCommand.java b/libLauncher/src/main/java/ru/gravit/utils/command/basic/ClearCommand.java index 014238de..54443c99 100644 --- a/libLauncher/src/main/java/ru/gravit/utils/command/basic/ClearCommand.java +++ b/libLauncher/src/main/java/ru/gravit/utils/command/basic/ClearCommand.java @@ -6,6 +6,7 @@ public final class ClearCommand extends Command { private CommandHandler handler; + public ClearCommand(CommandHandler handler) { this.handler = handler; } diff --git a/libLauncher/src/main/java/ru/gravit/utils/command/basic/HelpCommand.java b/libLauncher/src/main/java/ru/gravit/utils/command/basic/HelpCommand.java index 08d6afba..eb759e79 100644 --- a/libLauncher/src/main/java/ru/gravit/utils/command/basic/HelpCommand.java +++ b/libLauncher/src/main/java/ru/gravit/utils/command/basic/HelpCommand.java @@ -11,6 +11,7 @@ public final class HelpCommand extends Command { private CommandHandler handler; + private static void printCommand(String name, Command command) { String args = command.getArgsDescription(); //LogHelper.subInfo("%s %s - %s", name, args == null ? "[nothing]" : args, command.getUsageDescription()); @@ -19,7 +20,7 @@ private static void printCommand(String name, Command command) { ansi.fgBright(Ansi.Color.GREEN); ansi.a(name + " "); ansi.fgBright(Ansi.Color.CYAN); - ansi.a(args == null ? "[nothing]": args); + ansi.a(args == null ? "[nothing]" : args); ansi.reset(); ansi.a(" - "); ansi.fgBright(Ansi.Color.YELLOW); @@ -29,9 +30,8 @@ private static void printCommand(String name, Command command) { }, () -> LogHelper.htmlFormatLog(LogHelper.Level.INFO, LogHelper.getDataTime(), String.format("%s %s - %s", name, args == null ? "[nothing]" : args, command.getUsageDescription()), true)); } - private static void printCategory(String name, String description) - { - if(description != null) LogHelper.info("Category: %s - %s", name, description); + private static void printCategory(String name, String description) { + if (description != null) LogHelper.info("Category: %s - %s", name, description); else LogHelper.info("Category: %s", name); } @@ -65,8 +65,7 @@ private void printCommand(String name) throws CommandException { } private void printCommands() { - for(CommandHandler.Category category : handler.getCategories()) - { + for (CommandHandler.Category category : handler.getCategories()) { printCategory(category.name, category.description); for (Entry entry : category.category.commandsMap().entrySet()) printCommand(entry.getKey(), entry.getValue()); diff --git a/libLauncher/src/main/java/ru/gravit/utils/helper/FormatHelper.java b/libLauncher/src/main/java/ru/gravit/utils/helper/FormatHelper.java index 6ec9d685..b8d244cb 100644 --- a/libLauncher/src/main/java/ru/gravit/utils/helper/FormatHelper.java +++ b/libLauncher/src/main/java/ru/gravit/utils/helper/FormatHelper.java @@ -11,8 +11,7 @@ * Поэтому rawAnsiFormat вынесен в отдельный Helper */ public class FormatHelper { - public static Ansi rawAnsiFormat(LogHelper.Level level, String dateTime, boolean sub) - { + public static Ansi rawAnsiFormat(LogHelper.Level level, String dateTime, boolean sub) { Ansi.Color levelColor; boolean bright = level != LogHelper.Level.DEBUG; switch (level) { @@ -73,8 +72,7 @@ static String ansiFormatLicense(String product) { reset().toString(); // To file } - public static String rawFormat(LogHelper.Level level, String dateTime, boolean sub) - { + public static String rawFormat(LogHelper.Level level, String dateTime, boolean sub) { return dateTime + " [" + level.name + (sub ? "] " : "] "); } diff --git a/libLauncher/src/main/java/ru/gravit/utils/helper/JarHelper.java b/libLauncher/src/main/java/ru/gravit/utils/helper/JarHelper.java index 99d4c5c4..032c86ca 100644 --- a/libLauncher/src/main/java/ru/gravit/utils/helper/JarHelper.java +++ b/libLauncher/src/main/java/ru/gravit/utils/helper/JarHelper.java @@ -9,74 +9,68 @@ public class JarHelper { @FunctionalInterface - public interface ZipWalkCallback - { + public interface ZipWalkCallback { void process(ZipInputStream input, ZipEntry e); } + @FunctionalInterface - public interface JarWalkCallback - { + public interface JarWalkCallback { void process(ZipInputStream input, ZipEntry e, String fullClassName, String clazz); } - public static void zipWalk(ZipInputStream input, ZipWalkCallback callback) throws IOException - { + + public static void zipWalk(ZipInputStream input, ZipWalkCallback callback) throws IOException { ZipEntry e = input.getNextEntry(); - while (e != null) - { + while (e != null) { callback.process(input, e); e = input.getNextEntry(); } } - public static void jarWalk(ZipInputStream input, JarWalkCallback callback) throws IOException - { + + public static void jarWalk(ZipInputStream input, JarWalkCallback callback) throws IOException { ZipEntry e = input.getNextEntry(); - while (e != null) - { + while (e != null) { String filename = e.getName(); - if(filename.endsWith(".class")) - { + if (filename.endsWith(".class")) { String classFull = filename.replaceAll("/", ".").substring(0, filename.length() - ".class".length()); - String clazz = classFull.substring(classFull.lastIndexOf('.')+1); - callback.process(input,e, classFull, clazz); + String clazz = classFull.substring(classFull.lastIndexOf('.') + 1); + callback.process(input, e, classFull, clazz); } e = input.getNextEntry(); } } - public static Map jarMap(ZipInputStream input, boolean overwrite) throws IOException - { + + public static Map jarMap(ZipInputStream input, boolean overwrite) throws IOException { Map map = new HashMap<>(); jarMap(input, map, overwrite); return map; } - public static void jarMap(ZipInputStream input, Map map, boolean overwrite) throws IOException - { + + public static void jarMap(ZipInputStream input, Map map, boolean overwrite) throws IOException { jarWalk(input, (in, e, classFull, clazz) -> { - if(overwrite) map.put(clazz, classFull); + if (overwrite) map.put(clazz, classFull); else map.putIfAbsent(clazz, classFull); }); } - public static Map jarMap(Path file, boolean overwrite) throws IOException - { - try(ZipInputStream inputStream = IOHelper.newZipInput(file)) - { - return jarMap(inputStream,overwrite); + + public static Map jarMap(Path file, boolean overwrite) throws IOException { + try (ZipInputStream inputStream = IOHelper.newZipInput(file)) { + return jarMap(inputStream, overwrite); } } - public static void jarMap(Path file, Map map, boolean overwrite) throws IOException - { - try(ZipInputStream inputStream = IOHelper.newZipInput(file)) - { - jarMap(inputStream, map,overwrite); + + public static void jarMap(Path file, Map map, boolean overwrite) throws IOException { + try (ZipInputStream inputStream = IOHelper.newZipInput(file)) { + jarMap(inputStream, map, overwrite); } } - public static Map jarMap(Class clazz, boolean overwrite) throws IOException - { + + public static Map jarMap(Class clazz, boolean overwrite) throws IOException { Path file = IOHelper.getCodeSource(clazz); return jarMap(file, overwrite); } - public static void jarMap(Class clazz, Map map, boolean overwrite) throws IOException - { + + public static void jarMap(Class clazz, Map map, boolean overwrite) throws IOException { Path file = IOHelper.getCodeSource(clazz); jarMap(file, map, overwrite); } diff --git a/libLauncher/src/main/java/ru/gravit/utils/helper/LogHelper.java b/libLauncher/src/main/java/ru/gravit/utils/helper/LogHelper.java index efc8fde8..3d75e87c 100644 --- a/libLauncher/src/main/java/ru/gravit/utils/helper/LogHelper.java +++ b/libLauncher/src/main/java/ru/gravit/utils/helper/LogHelper.java @@ -70,7 +70,7 @@ public static void addOutput(OutputEnity output) { @LauncherAPI public static void addExcCallback(Consumer output) { - EXCEPTIONS_CALLBACKS.add(Objects.requireNonNull(output, "output")); + EXCEPTIONS_CALLBACKS.add(Objects.requireNonNull(output, "output")); } @LauncherAPI @@ -118,7 +118,7 @@ public static void dev(String format, Object... args) { @LauncherAPI public static void error(Throwable exc) { - EXCEPTIONS_CALLBACKS.forEach(e -> e.accept(exc)); + EXCEPTIONS_CALLBACKS.forEach(e -> e.accept(exc)); error(isStacktraceEnabled() ? toString(exc) : exc.toString()); } @@ -172,8 +172,7 @@ public static void setDevEnabled(boolean stacktraceEnabled) { DEV_ENABLED.set(stacktraceEnabled); } - public static String getDataTime() - { + public static String getDataTime() { return DATE_TIME_FORMATTER.format(LocalDateTime.now()); } @@ -209,14 +208,14 @@ public static void log(Level level, String message, boolean sub) { } } } + @LauncherAPI - public static void rawLog(Supplier plainStr, Supplier jansiStr) - { + public static void rawLog(Supplier plainStr, Supplier jansiStr) { rawLog(plainStr, jansiStr, null); } + @LauncherAPI - public static void rawLog(Supplier plainStr, Supplier jansiStr, Supplier htmlStr) - { + public static void rawLog(Supplier plainStr, Supplier jansiStr, Supplier htmlStr) { String jansiString = null, plainString = null, htmlString = null; for (OutputEnity output : OUTPUTS) { if (output.type == OutputTypes.JANSI && JANSI) { @@ -368,8 +367,7 @@ private static String ansiFormatLog(Level level, String dateTime, String message return ansi.reset().toString(); } - public static String htmlFormatLog(Level level, String dateTime, String message, boolean sub) - { + public static String htmlFormatLog(Level level, String dateTime, String message, boolean sub) { String levelColor; switch (level) { case WARNING: @@ -391,7 +389,7 @@ public static String htmlFormatLog(Level level, String dateTime, String message, levelColor = "gravitlauncher-log-unknown"; break; } - if(sub) levelColor += " gravitlauncher-log-sub"; + if (sub) levelColor += " gravitlauncher-log-sub"; return String.format("%s [%s] %s", dateTime, levelColor, level.toString(), sub ? ' ' + message : message); } diff --git a/module.gradle b/module.gradle index 95cf1915..3ca31604 100644 --- a/module.gradle +++ b/module.gradle @@ -1,8 +1,8 @@ dependencies { - compileOnly project(':LaunchServer') + compileOnly project(':LaunchServer') } jar { - from { configurations.runtime.collect { it.isDirectory() ? it : zipTree(it) } } + from { configurations.runtime.collect { it.isDirectory() ? it : zipTree(it) } } } diff --git a/modules b/modules index 3f7cf22f..b5995176 160000 --- a/modules +++ b/modules @@ -1 +1 @@ -Subproject commit 3f7cf22f4270dcdf6baa5c74dd00673b2b4ffc9e +Subproject commit b599517693c9d1c9a9045982ffa8068e1ed620c4 diff --git a/test_support.gradle b/test_support.gradle index 5cfb0a46..dd1b9319 100644 --- a/test_support.gradle +++ b/test_support.gradle @@ -1,11 +1,11 @@ dependencies { - testCompile 'org.junit.jupiter:junit-jupiter:5.4.1' + testCompile 'org.junit.jupiter:junit-jupiter:5.4.1' } test { - useJUnitPlatform() - testLogging { - events "passed", "skipped", "failed" - } + useJUnitPlatform() + testLogging { + events "passed", "skipped", "failed" + } }