diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java index ee5b1b17..f1466399 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java @@ -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,8 +224,7 @@ 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); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/StarterAgent.java b/LaunchServer/src/main/java/ru/gravit/launchserver/StarterAgent.java index dc8b7457..d62d37c2 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/StarterAgent.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/StarterAgent.java @@ -33,7 +33,7 @@ private StarterVisitor() { try { Files.deleteIfExists(filef); Files.createFile(filef); - } catch (Throwable t) { } + } catch (Throwable ignored) { } } } 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..a6acb131 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/LauncherBinary.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/LauncherBinary.java @@ -46,7 +46,7 @@ public final boolean sync() throws IOException { return exists; } - public static final Path resolve(LaunchServer server, String 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/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/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/Launcher/src/main/java/ru/gravit/launcher/LauncherAgent.java b/Launcher/src/main/java/ru/gravit/launcher/LauncherAgent.java index da468862..4278aa13 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/LauncherAgent.java +++ b/Launcher/src/main/java/ru/gravit/launcher/LauncherAgent.java @@ -100,56 +100,59 @@ private static void replaceClasses(boolean pb, boolean rt) { * 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(); - } + 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; } 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..7d004c4c 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 @@ -40,13 +40,7 @@ public void invoke(String... args) throws Exception { Request.service.registerHandler((result) -> { if(result instanceof LogEvent) { - LogHelper.rawLog(() -> { - return ((LogEvent) result).string; - }, () -> { - return ((LogEvent) result).string; - }, () -> { - return ((LogEvent) result).string; - }); + LogHelper.rawLog(() -> ((LogEvent) result).string, () -> ((LogEvent) result).string, () -> ((LogEvent) result).string); } }); } 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..45191085 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 @@ -193,9 +193,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/Radon b/Radon index 6410af80..b288a56a 160000 --- a/Radon +++ b/Radon @@ -1 +1 @@ -Subproject commit 6410af8044e7346e06f546dc04636b631fa7584c +Subproject commit b288a56a2d6577c247b80ebd213599482aa17d20 diff --git a/modules b/modules index 3f7cf22f..ba8ebcc0 160000 --- a/modules +++ b/modules @@ -1 +1 @@ -Subproject commit 3f7cf22f4270dcdf6baa5c74dd00673b2b4ffc9e +Subproject commit ba8ebcc06dbc5847210e10928725e8254e47a1d9