diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java index fc50a453..6963cb9c 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java @@ -65,7 +65,11 @@ import ru.gravit.launchserver.config.HWIDHandlerAdapter; import ru.gravit.launchserver.config.PermissionsHandlerAdapter; import ru.gravit.launchserver.config.TextureProviderAdapter; -import ru.gravit.launchserver.manangers.*; +import ru.gravit.launchserver.manangers.MirrorManager; +import ru.gravit.launchserver.manangers.ModulesManager; +import ru.gravit.launchserver.manangers.ReconfigurableManager; +import ru.gravit.launchserver.manangers.ReloadManager; +import ru.gravit.launchserver.manangers.SessionManager; import ru.gravit.launchserver.manangers.hook.AuthHookManager; import ru.gravit.launchserver.manangers.hook.BuildHookManager; import ru.gravit.launchserver.manangers.hook.SocketHookManager; @@ -82,7 +86,7 @@ public final class LaunchServer implements Runnable { public static final class Config { - public int port; + public int port; private String address; @@ -127,7 +131,6 @@ public static final class Config { public String authRejectString; - public String whitelistRejectString; public boolean genMappings; @@ -136,6 +139,7 @@ public static final class Config { public boolean isWarningMissArchJava; public boolean enabledProGuard; + public boolean stripLineNumbers; public String startScript; @@ -264,7 +268,8 @@ public static void main(String... args) throws Throwable { public final Path privateKeyFile; public final Path updatesDir; - public static LaunchServer server; + + public static LaunchServer server = null; public final Path profilesDir; // Server config @@ -277,7 +282,7 @@ public static void main(String... args) throws Throwable { public final RSAPrivateKey privateKey; // Launcher binary - public final LauncherBinary launcherBinary; + public final JARLauncherBinary launcherBinary; public final LauncherBinary launcherEXEBinary; // HWID ban + anti-brutforce @@ -572,8 +577,8 @@ private void generateConfigIfNotExists() throws IOException { newConfig.threadCoreCount = 0; // on your own newConfig.enabledProGuard = true; + newConfig.stripLineNumbers = false; newConfig.threadCount = JVMHelper.OPERATING_SYSTEM_MXBEAN.getAvailableProcessors() >= 4 ? JVMHelper.OPERATING_SYSTEM_MXBEAN.getAvailableProcessors() / 2 : JVMHelper.OPERATING_SYSTEM_MXBEAN.getAvailableProcessors(); - // Set server address LogHelper.println("LaunchServer address: "); newConfig.setAddress(commandHandler.readLine()); @@ -587,8 +592,6 @@ private void generateConfigIfNotExists() throws IOException { } } - - @SuppressWarnings("ReturnOfCollectionOrArrayField") public Collection getProfiles() { return profilesList; } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/asm/ClassMetadataReader.java b/LaunchServer/src/main/java/ru/gravit/launchserver/asm/ClassMetadataReader.java index c1f07859..fd6e8ca5 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/asm/ClassMetadataReader.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/asm/ClassMetadataReader.java @@ -1,5 +1,6 @@ package ru.gravit.launchserver.asm; +import java.io.Closeable; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; @@ -17,7 +18,7 @@ * Позволяет искать методы внутри незагруженных классов и общие суперклассы для * чего угодно. Работает через поиск class-файлов в classpath. */ -public class ClassMetadataReader { +public class ClassMetadataReader implements Closeable { private class CheckSuperClassVisitor extends ClassVisitor { String superClassName; @@ -96,4 +97,10 @@ public ArrayList getSuperClasses(String type) { return superclasses; } + @Override + public void close() throws IOException { + cp.stream().forEach(IOHelper::close); + cp.clear(); + } + } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/hwid/JsonHWIDHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/hwid/JsonHWIDHandler.java index 7fb92075..b218d1f2 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/hwid/JsonHWIDHandler.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/hwid/JsonHWIDHandler.java @@ -17,11 +17,9 @@ public final class JsonHWIDHandler extends HWIDHandler { private static final Gson gson = new Gson(); - @SuppressWarnings("unused") private URL url; private URL urlBan; private URL urlUnBan; - @SuppressWarnings("unused") private URL urlGet; public class banRequest { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/permissions/JsonFilePermissionsHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/permissions/JsonFilePermissionsHandler.java index b779b882..72aa37ca 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/permissions/JsonFilePermissionsHandler.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/permissions/JsonFilePermissionsHandler.java @@ -11,9 +11,9 @@ import com.google.gson.reflect.TypeToken; +import ru.gravit.launcher.ClientPermissions; import ru.gravit.launcher.Launcher; import ru.gravit.launchserver.Reloadable; -import ru.gravit.launcher.ClientPermissions; import ru.gravit.utils.helper.IOHelper; import ru.gravit.utils.helper.LogHelper; 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 3607206e..87d08685 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 @@ -13,8 +13,6 @@ public abstract class AuthProvider implements AutoCloseable { private static final Map> AUTH_PROVIDERS = new ConcurrentHashMap<>(8); private static boolean registredProv = false; - protected transient LaunchServer server = LaunchServer.server; - public static AuthProviderResult authError(String message) throws AuthException { throw new AuthException(message); @@ -42,7 +40,7 @@ public static void registerProviders() { } public AuthHandler getAccociateHandler(int this_position) { - return server.config.authHandler; + return LaunchServer.server.config.authHandler; } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/AuthProviderResult.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/AuthProviderResult.java index f89f3c33..4d8ec016 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/AuthProviderResult.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/AuthProviderResult.java @@ -1,7 +1,7 @@ package ru.gravit.launchserver.auth.provider; -import ru.gravit.launchserver.LaunchServer; import ru.gravit.launcher.ClientPermissions; +import ru.gravit.launchserver.LaunchServer; public class AuthProviderResult { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/MySQLAuthProvider.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/MySQLAuthProvider.java index 48be4086..b3554bd5 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/MySQLAuthProvider.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/MySQLAuthProvider.java @@ -5,8 +5,8 @@ import java.sql.ResultSet; import java.sql.SQLException; -import ru.gravit.launchserver.auth.AuthException; import ru.gravit.launcher.ClientPermissions; +import ru.gravit.launchserver.auth.AuthException; import ru.gravit.launchserver.auth.MySQLSourceConfig; import ru.gravit.utils.helper.CommonHelper; import ru.gravit.utils.helper.SecurityHelper; diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/RejectAuthProvider.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/RejectAuthProvider.java index 16ca7081..efe8af0a 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/RejectAuthProvider.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/RejectAuthProvider.java @@ -1,12 +1,12 @@ package ru.gravit.launchserver.auth.provider; +import java.util.ArrayList; + import ru.gravit.launchserver.Reconfigurable; import ru.gravit.launchserver.auth.AuthException; import ru.gravit.utils.helper.LogHelper; import ru.gravit.utils.helper.SecurityHelper; -import java.util.ArrayList; - public final class RejectAuthProvider extends AuthProvider implements Reconfigurable { public RejectAuthProvider() { } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JARLauncherBinary.java b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JARLauncherBinary.java index 00dccfe0..a0caa387 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JARLauncherBinary.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JARLauncherBinary.java @@ -4,28 +4,36 @@ import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; + +import ru.gravit.launcher.Launcher; import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.binary.tasks.LauncherBuildTask; import ru.gravit.launchserver.binary.tasks.MainBuildTask; import ru.gravit.launchserver.binary.tasks.ProGuardBuildTask; +import ru.gravit.launchserver.binary.tasks.StripLineNumbersTask; import ru.gravit.launchserver.binary.tasks.UnpackBuildTask; import ru.gravit.utils.helper.IOHelper; import ru.gravit.utils.helper.LogHelper; public final class JARLauncherBinary extends LauncherBinary { public ArrayList tasks; + public final Path runtimeDir; + public final Path guardDir; + public JARLauncherBinary(LaunchServer server) throws IOException { super(server); tasks = new ArrayList<>(); - tasks.add(new UnpackBuildTask()); - tasks.add(new MainBuildTask()); - if(server.config.enabledProGuard) tasks.add(new ProGuardBuildTask()); + tasks.add(new UnpackBuildTask(server)); + tasks.add(new MainBuildTask(server)); + if(server.config.enabledProGuard) tasks.add(new ProGuardBuildTask(server)); + if(server.config.stripLineNumbers) tasks.add(new StripLineNumbersTask(server)); syncBinaryFile = server.dir.resolve(server.config.binaryName + ".jar"); + runtimeDir = server.dir.resolve(Launcher.RUNTIME_DIR); + guardDir = server.dir.resolve(Launcher.GUARD_DIR); } @Override public void build() throws IOException { - // Build launcher binary LogHelper.info("Building launcher binary file"); Path thisPath = null; boolean isNeedDelete = false; @@ -39,7 +47,7 @@ public void build() throws IOException { long time_task_end = System.currentTimeMillis(); long time_task = time_task_end - time_this; time_this = time_task_end; - if(isNeedDelete) Files.delete(oldPath); + if (isNeedDelete) Files.delete(oldPath); isNeedDelete = task.allowDelete(); LogHelper.subInfo("Task %s processed from %d millis",task.getName(), time_task); } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/MainBuildTask.java b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/MainBuildTask.java index 7848ecb8..27d7f654 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/MainBuildTask.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/MainBuildTask.java @@ -1,21 +1,7 @@ package ru.gravit.launchserver.binary.tasks; -import javassist.CannotCompileException; -import javassist.NotFoundException; -import ru.gravit.launcher.AutogenConfig; -import ru.gravit.launcher.Launcher; -import ru.gravit.launcher.LauncherConfig; -import ru.gravit.launcher.serialize.HOutput; -import ru.gravit.launchserver.LaunchServer; -import ru.gravit.launchserver.binary.BuildContext; -import ru.gravit.launchserver.binary.JAConfigurator; -import ru.gravit.launchserver.binary.JARLauncherBinary; -import ru.gravit.utils.helper.IOHelper; -import ru.gravit.utils.helper.LogHelper; -import ru.gravit.utils.helper.SecurityHelper; -import ru.gravit.utils.helper.UnpackHelper; +import static ru.gravit.utils.helper.IOHelper.newZipEntry; -import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.nio.file.FileVisitResult; @@ -24,17 +10,31 @@ import java.nio.file.attribute.BasicFileAttributes; import java.util.HashMap; import java.util.Map; +import java.util.jar.JarFile; import java.util.zip.ZipEntry; import java.util.zip.ZipException; import java.util.zip.ZipInputStream; import java.util.zip.ZipOutputStream; -import static ru.gravit.utils.helper.IOHelper.newZipEntry; +import javassist.CannotCompileException; +import javassist.NotFoundException; +import ru.gravit.launcher.AutogenConfig; +import ru.gravit.launcher.Launcher; +import ru.gravit.launcher.LauncherConfig; +import ru.gravit.launcher.serialize.HOutput; +import ru.gravit.launchserver.LaunchServer; +import ru.gravit.launchserver.asm.ClassMetadataReader; +import ru.gravit.launchserver.binary.BuildContext; +import ru.gravit.launchserver.binary.JAConfigurator; +import ru.gravit.utils.helper.IOHelper; +import ru.gravit.utils.helper.LogHelper; +import ru.gravit.utils.helper.SecurityHelper; public class MainBuildTask implements LauncherBuildTask { - public static LaunchServer server = LaunchServer.server; public final Path binaryFile; public Path cleanJar; + private final LaunchServer server; + public final ClassMetadataReader reader; private final class RuntimeDirVisitor extends SimpleFileVisitor { private final ZipOutputStream output; private final Map runtime; @@ -46,14 +46,14 @@ private RuntimeDirVisitor(ZipOutputStream output, Map runtime) { @Override public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException { - String dirName = IOHelper.toString(UnpackBuildTask.runtimeDir.relativize(dir)); + String dirName = IOHelper.toString(server.launcherBinary.runtimeDir.relativize(dir)); output.putNextEntry(newEntry(dirName + '/')); return super.preVisitDirectory(dir, attrs); } @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { - String fileName = IOHelper.toString(UnpackBuildTask.runtimeDir.relativize(file)); + String fileName = IOHelper.toString(server.launcherBinary.runtimeDir.relativize(file)); runtime.put(fileName, SecurityHelper.digest(SecurityHelper.DigestAlgorithm.MD5, file)); // Create zip entry and transfer contents @@ -65,8 +65,6 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IO } } - // TODO: new native security wrapper and library... - @SuppressWarnings("unused") private final class GuardDirVisitor extends SimpleFileVisitor { private final ZipOutputStream output; private final Map guard; @@ -78,14 +76,14 @@ private GuardDirVisitor(ZipOutputStream output, Map guard) { @Override public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException { - String dirName = IOHelper.toString(UnpackBuildTask.guardDir.relativize(dir)); + String dirName = IOHelper.toString(server.launcherBinary.guardDir.relativize(dir)); output.putNextEntry(newGuardEntry(dirName + '/')); return super.preVisitDirectory(dir, attrs); } @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { - String fileName = IOHelper.toString(UnpackBuildTask.guardDir.relativize(file)); + String fileName = IOHelper.toString(server.launcherBinary.guardDir.relativize(file)); guard.put(fileName, SecurityHelper.digest(SecurityHelper.DigestAlgorithm.MD5, file)); // Create zip entry and transfer contents @@ -104,8 +102,11 @@ private static ZipEntry newEntry(String fileName) { private static ZipEntry newGuardEntry(String fileName) { return newZipEntry(Launcher.GUARD_DIR + IOHelper.CROSS_SEPARATOR + fileName); } - public MainBuildTask() { + + public MainBuildTask(LaunchServer srv) { + server = srv; binaryFile = server.dir.resolve(server.config.binaryName + "-main.jar"); + reader = new ClassMetadataReader(); } @Override @@ -120,7 +121,7 @@ public Path process(Path cleanJar) throws IOException { JAConfigurator jaConfigurator = new JAConfigurator(AutogenConfig.class.getName(), this)) { jaConfigurator.pool.insertClassPath(cleanJar.toFile().getAbsolutePath()); BuildContext context = new BuildContext(output, jaConfigurator, this); - server.buildHookManager.preHook(context); + server.buildHookManager.hook(context); jaConfigurator.setAddress(server.config.getAddress()); jaConfigurator.setPort(server.config.port); jaConfigurator.setProjectName(server.config.projectName); @@ -130,6 +131,7 @@ public Path process(Path cleanJar) throws IOException { jaConfigurator.setDownloadJava(server.config.isDownloadJava); jaConfigurator.setEnv(server.config.env); server.buildHookManager.registerAllClientModuleClass(jaConfigurator); + reader.getCp().add(new JarFile(cleanJar.toFile())); try (ZipInputStream input = new ZipInputStream(IOHelper.newInput(cleanJar))) { ZipEntry e = input.getNextEntry(); while (e != null) { @@ -145,7 +147,7 @@ public Path process(Path cleanJar) throws IOException { e = input.getNextEntry(); continue; } - /*if (filename.endsWith(".class")) { + if (filename.endsWith(".class")) { String classname = filename.replace('/', '.').substring(0, filename.length() - ".class".length()); byte[] bytes; @@ -154,10 +156,8 @@ public Path process(Path cleanJar) throws IOException { bytes = outputStream.toByteArray(); } bytes = server.buildHookManager.classTransform(bytes, classname, this); - try (ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes)) { - IOHelper.transfer(inputStream, output); - } - } else */ + output.write(bytes); + } else IOHelper.transfer(input, output); context.fileList.add(filename); e = input.getNextEntry(); @@ -172,8 +172,8 @@ public Path process(Path cleanJar) throws IOException { Map runtime = new HashMap<>(256); if (server.buildHookManager.buildRuntime()) { // Write launcher guard dir - IOHelper.walk(UnpackBuildTask.runtimeDir, new RuntimeDirVisitor(output, runtime), false); - // IOHelper.walk(guardDir, new GuardDirVisitor(output, runtime), false); + IOHelper.walk(server.launcherBinary.runtimeDir, new RuntimeDirVisitor(output, runtime), false); + IOHelper.walk(server.launcherBinary.guardDir, new GuardDirVisitor(output, runtime), false); } // Create launcher config file byte[] launcherConfigBytes; @@ -192,10 +192,10 @@ public Path process(Path cleanJar) throws IOException { output.putNextEntry(e); jaConfigurator.compile(); output.write(jaConfigurator.getBytecode()); - server.buildHookManager.postHook(context); } catch (CannotCompileException | NotFoundException e) { LogHelper.error(e); } + reader.close(); return binaryFile; } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/ProGuardBuildTask.java b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/ProGuardBuildTask.java index 73ebd9c3..72366ea2 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/ProGuardBuildTask.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/ProGuardBuildTask.java @@ -1,17 +1,22 @@ package ru.gravit.launchserver.binary.tasks; +import java.io.IOException; +import java.nio.file.Path; + import proguard.Configuration; import proguard.ConfigurationParser; import proguard.ParseException; import proguard.ProGuard; import ru.gravit.launchserver.LaunchServer; -import java.io.IOException; -import java.nio.file.Path; - public class ProGuardBuildTask implements LauncherBuildTask { - public static LaunchServer server = LaunchServer.server; - @Override + private final LaunchServer server; + + public ProGuardBuildTask(LaunchServer server) { + this.server = server; + } + + @Override public String getName() { return "ProGuard"; } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/StripLineNumbersTask.java b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/StripLineNumbersTask.java new file mode 100644 index 00000000..d8baa571 --- /dev/null +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/StripLineNumbersTask.java @@ -0,0 +1,70 @@ +package ru.gravit.launchserver.binary.tasks; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.nio.file.Path; +import java.util.jar.JarFile; +import java.util.zip.ZipEntry; +import java.util.zip.ZipInputStream; +import java.util.zip.ZipOutputStream; + +import org.objectweb.asm.ClassReader; +import org.objectweb.asm.ClassWriter; + +import ru.gravit.launchserver.LaunchServer; +import ru.gravit.launchserver.asm.ClassMetadataReader; +import ru.gravit.launchserver.asm.SafeClassWriter; +import ru.gravit.utils.helper.IOHelper; + +public class StripLineNumbersTask implements LauncherBuildTask { + private final LaunchServer server; + + public StripLineNumbersTask(LaunchServer server) { + this.server = server; + } + + @Override + public String getName() { + return "Strip debug task"; + } + + @Override + public Path process(Path inputFile) throws IOException { + Path out = server.dir.resolve(server.config.projectName + "-stripped.jar"); + try (ClassMetadataReader reader = new ClassMetadataReader()) { + reader.getCp().add(new JarFile(inputFile.toFile())); + try (ZipInputStream input = IOHelper.newZipInput(inputFile); + ZipOutputStream output = new ZipOutputStream(IOHelper.newOutput(out))) { + ZipEntry e = input.getNextEntry(); + while (e != null) { + String filename = e.getName(); + output.putNextEntry(IOHelper.newZipEntry(e)); + if (filename.endsWith(".class")) { + byte[] bytes = null; + try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream(2048)) { + IOHelper.transfer(input, outputStream); + bytes = outputStream.toByteArray(); + } + output.write(classFix(bytes, reader)); + } else + IOHelper.transfer(input, output); + e = input.getNextEntry(); + } + } + } + return out; + } + + private static byte[] classFix(byte[] bytes, ClassMetadataReader reader) { + ClassReader cr = new ClassReader(bytes); + ClassWriter cw = new SafeClassWriter(reader, ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS); + cr.accept(cw, ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES); + return cw.toByteArray(); + } + + @Override + public boolean allowDelete() { + return true; + } + +} diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/UnpackBuildTask.java b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/UnpackBuildTask.java index 22999d31..b4919b1a 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/UnpackBuildTask.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/UnpackBuildTask.java @@ -1,19 +1,21 @@ package ru.gravit.launchserver.binary.tasks; -import ru.gravit.launcher.Launcher; import ru.gravit.launchserver.LaunchServer; import ru.gravit.utils.helper.IOHelper; import ru.gravit.utils.helper.LogHelper; import ru.gravit.utils.helper.UnpackHelper; import java.io.IOException; -import java.net.URL; import java.nio.file.Path; public class UnpackBuildTask implements LauncherBuildTask { - public static final Path runtimeDir = LaunchServer.server.dir.resolve(Launcher.RUNTIME_DIR); - public static final Path guardDir = LaunchServer.server.dir.resolve(Launcher.GUARD_DIR); - public static LaunchServer server = LaunchServer.server; + private final LaunchServer server; + private final Path result; + + public UnpackBuildTask(LaunchServer server) { + this.server = server; + result = server.dir.resolve(server.config.binaryName + "-clean.jar"); + } @Override public String getName() { @@ -22,9 +24,8 @@ public String getName() { @Override public Path process(Path inputFile) throws IOException { - Path result = server.dir.resolve(server.config.binaryName + "-clean.jar"); - URL url = IOHelper.getResourceURL("Launcher.jar"); - UnpackHelper.unpack(url, result); + UnpackHelper.unpack(IOHelper.getResourceURL("Launcher.jar"), result); + tryUnpack(); return result; } @@ -35,7 +36,7 @@ public boolean allowDelete() { public void tryUnpack() throws IOException { LogHelper.info("Unpacking launcher native guard files and runtime"); - UnpackHelper.unpackZipNoCheck("guard.zip", guardDir); - UnpackHelper.unpackZipNoCheck("runtime.zip", runtimeDir); + UnpackHelper.unpackZipNoCheck("guard.zip", server.launcherBinary.guardDir); + UnpackHelper.unpackZipNoCheck("runtime.zip", server.launcherBinary.runtimeDir); } } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/RestartCommand.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/RestartCommand.java index 4af32282..34fbdb3e 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/RestartCommand.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/RestartCommand.java @@ -19,7 +19,6 @@ public String getUsageDescription() { } @Override - @SuppressWarnings("CallToSystemExit") public void invoke(String... args) { server.fullyRestart(); } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/StopCommand.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/StopCommand.java index ddb75200..bb1983ac 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/StopCommand.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/StopCommand.java @@ -20,7 +20,6 @@ public String getUsageDescription() { } @Override - @SuppressWarnings("CallToSystemExit") public void invoke(String... args) { JVMHelper.RUNTIME.exit(0); } 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 c80a19fb..da213930 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 @@ -36,7 +36,7 @@ public void invoke(String... args) throws Exception { } if (args[0].equals("profile")) { ClientProfile profile = new ClientProfile("1.7.10","asset1.7.10",0,"Test1.7.10","localhost",25565,true,false,"net.minecraft.launchwrapper.Launch"); - try(Writer writer = IOHelper.newWriter(LaunchServer.server.dir.resolve("profiles").resolve("Test.cfg"))) + try(Writer writer = IOHelper.newWriter(server.dir.resolve("profiles").resolve("Test.cfg"))) { LaunchServer.gson.toJson(profile,writer); } 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 885fcdc3..3858c826 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 @@ -44,7 +44,13 @@ import ru.gravit.launchserver.command.hash.UnindexAssetCommand; import ru.gravit.launchserver.command.modules.LoadModuleCommand; import ru.gravit.launchserver.command.modules.ModulesCommand; -import ru.gravit.launchserver.command.service.*; +import ru.gravit.launchserver.command.service.ConfigCommand; +import ru.gravit.launchserver.command.service.ConfigHelpCommand; +import ru.gravit.launchserver.command.service.ConfigListCommand; +import ru.gravit.launchserver.command.service.ReloadAllCommand; +import ru.gravit.launchserver.command.service.ReloadCommand; +import ru.gravit.launchserver.command.service.ReloadListCommand; +import ru.gravit.launchserver.command.service.SwapAuthProviderCommand; import ru.gravit.utils.helper.LogHelper; import ru.gravit.utils.helper.VerifyHelper; 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 3f0f5a0a..36a7cddd 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/ReconfigurableManager.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/ReconfigurableManager.java @@ -1,12 +1,12 @@ package ru.gravit.launchserver.manangers; +import java.util.HashMap; +import java.util.Objects; + import ru.gravit.launchserver.Reconfigurable; import ru.gravit.utils.helper.LogHelper; import ru.gravit.utils.helper.VerifyHelper; -import java.util.HashMap; -import java.util.Objects; - public class ReconfigurableManager { private final HashMap RECONFIGURABLE = new HashMap<>(); public void registerReconfigurable(String name, Reconfigurable reconfigurable) diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/hook/AuthHookManager.java b/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/hook/AuthHookManager.java index 729ae1f6..273e2437 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/hook/AuthHookManager.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/hook/AuthHookManager.java @@ -1,11 +1,11 @@ package ru.gravit.launchserver.manangers.hook; -import ru.gravit.launchserver.response.auth.AuthResponse; -import ru.gravit.launchserver.socket.Client; - import java.util.HashSet; import java.util.Set; +import ru.gravit.launchserver.response.auth.AuthResponse; +import ru.gravit.launchserver.socket.Client; + public class AuthHookManager { private Set PRE_HOOKS = new HashSet<>(); private Set POST_HOOKS = new HashSet<>(); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/hook/BuildHookManager.java b/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/hook/BuildHookManager.java index c3d40fae..00bd4e05 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/hook/BuildHookManager.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/hook/BuildHookManager.java @@ -4,7 +4,6 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; -import java.util.zip.ZipOutputStream; import ru.gravit.launcher.AutogenConfig; import ru.gravit.launcher.modules.TestClientModule; @@ -13,10 +12,6 @@ import ru.gravit.launchserver.binary.tasks.MainBuildTask; public class BuildHookManager { - @FunctionalInterface - public interface ZipBuildHook { - void build(ZipOutputStream context); - } @FunctionalInterface public interface BuildHook { @@ -29,22 +24,14 @@ public interface Transformer { } private boolean BUILDRUNTIME; - private final Set POST_HOOKS; - private final Set POST_PROGUARDRUN_HOOKS; - private final Set POST_PROGUARD_HOOKS; - private final Set PRE_HOOKS; - private final Set POST_PROGUARD_BUILDHOOKS; + private final Set HOOKS; private final Set CLASS_TRANSFORMER; private final Set CLASS_BLACKLIST; private final Set MODULE_CLASS; private final Map INCLUDE_CLASS; public BuildHookManager() { - POST_HOOKS = new HashSet<>(4); - POST_PROGUARDRUN_HOOKS = new HashSet<>(4); - POST_PROGUARD_HOOKS = new HashSet<>(4); - PRE_HOOKS = new HashSet<>(4); - POST_PROGUARD_BUILDHOOKS = new HashSet<>(4); + HOOKS = new HashSet<>(4); CLASS_BLACKLIST = new HashSet<>(4); MODULE_CLASS = new HashSet<>(4); INCLUDE_CLASS = new HashMap<>(4); @@ -57,22 +44,6 @@ public BuildHookManager() { registerClientModuleClass(TestClientModule.class.getName()); } - public Set getProguardBuildHooks() { - return POST_PROGUARD_BUILDHOOKS; - } - - public Set getPostProguardRunHooks() { - return POST_PROGUARDRUN_HOOKS; - } - - public void addPostProguardRunHook(Runnable hook) { - POST_PROGUARDRUN_HOOKS.add(hook); - } - - public void addPostProguardRunHook(ZipBuildHook hook) { - POST_PROGUARD_BUILDHOOKS.add(hook); - } - public void autoRegisterIgnoredClass(String clazz) { CLASS_BLACKLIST.add(clazz.replace('.', '/').concat(".class")); } @@ -87,12 +58,6 @@ public byte[] classTransform(byte[] clazz, String classname, MainBuildTask reade return result; } - public byte[] proGuardClassTransform(byte[] clazz, String classname, MainBuildTask reader) { - byte[] result = clazz; - for (Transformer transformer : POST_PROGUARD_HOOKS) result = transformer.transform(result, classname, reader); - return result; - } - public void registerIncludeClass(String classname, byte[] classdata) { INCLUDE_CLASS.put(classname, classdata); } @@ -108,12 +73,8 @@ public boolean isContainsBlacklist(String clazz) { return false; } - public void postHook(BuildContext context) { - for (BuildHook hook : POST_HOOKS) hook.build(context); - } - - public void preHook(BuildContext context) { - for (BuildHook hook : PRE_HOOKS) hook.build(context); + public void hook(BuildContext context) { + for (BuildHook hook : HOOKS) hook.build(context); } public void registerAllClientModuleClass(JAConfigurator cfg) { @@ -132,20 +93,8 @@ public void registerIgnoredClass(String clazz) { CLASS_BLACKLIST.add(clazz); } - public void registerPostHook(BuildHook hook) { - POST_HOOKS.add(hook); - } - - public void registerProGuardHook(Transformer hook) { - POST_PROGUARD_HOOKS.add(hook); - } - - public boolean isNeedPostProguardHook() { - return POST_PROGUARD_HOOKS.size() > 1 || !POST_PROGUARDRUN_HOOKS.isEmpty() || !POST_PROGUARD_BUILDHOOKS.isEmpty(); - } - - public void registerPreHook(BuildHook hook) { - PRE_HOOKS.add(hook); + public void registerHook(BuildHook hook) { + HOOKS.add(hook); } public void setBuildRuntime(boolean runtime) { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/hook/SocketHookManager.java b/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/hook/SocketHookManager.java index 87699daf..ecba8769 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/hook/SocketHookManager.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/hook/SocketHookManager.java @@ -1,12 +1,12 @@ package ru.gravit.launchserver.manangers.hook; -import ru.gravit.launcher.request.RequestException; -import ru.gravit.launchserver.socket.SocketContext; - import java.net.Socket; import java.util.HashSet; import java.util.Set; +import ru.gravit.launcher.request.RequestException; +import ru.gravit.launchserver.socket.SocketContext; + public class SocketHookManager { @FunctionalInterface public interface SocketPreHook diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/response/Response.java b/LaunchServer/src/main/java/ru/gravit/launchserver/response/Response.java index 4abd5a2a..cc1784d6 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/response/Response.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/response/Response.java @@ -104,8 +104,7 @@ protected final void debug(String message, Object... args) { public abstract void reply() throws Exception; - @SuppressWarnings("MethodMayBeStatic") // Intentionally not static - protected final void writeNoError(HOutput output) throws IOException { + protected static final void writeNoError(HOutput output) throws IOException { output.writeString("", 0); } } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/Client.java b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/Client.java index 8799e3e9..40346ddc 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/Client.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/Client.java @@ -1,7 +1,7 @@ package ru.gravit.launchserver.socket; -import ru.gravit.launcher.profiles.ClientProfile; import ru.gravit.launcher.ClientPermissions; +import ru.gravit.launcher.profiles.ClientProfile; public class Client { public long session; diff --git a/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/config.cfg b/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/config.cfg index dff8f626..32a03972 100644 --- a/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/config.cfg +++ b/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/config.cfg @@ -1,14 +1,22 @@ { "port": 7240, - "authHandler": { - "type": "memory" - }, + "address": "xx.xx", + "bindAddress": "0.0.0.0", + "projectName": "XXX", + "mirrors": [ + "http://mirror.gravitlauncher.ml/" + ], + "binaryName": "Launcher", + "env": "STD", "authProvider": [ { "message": "Настройте authProvider", "type": "reject" } ], + "authHandler": { + "type": "memory" + }, "permissionsHandler": { "filename": "permissions.json", "type": "json" @@ -21,12 +29,14 @@ "hwidHandler": { "type": "accept" }, - "threadCount": 0, + "threadCount": 2, "threadCoreCount": 0, "launch4j": { "enabled": false, - "fileDesc": "GravitLauncher 4.1.0", - "fileVer": "4.1.0", + "productName": "GravitLauncher", + "productVer": "4.2.0.0", + "fileDesc": "GravitLauncher 4.2.0", + "fileVer": "4.2.0.0", "internalName": "Launcher", "copyright": "© GravitLauncher Team", "trademarks": "This product is licensed under GPLv3", @@ -44,12 +54,8 @@ "genMappings": false, "isUsingWrapper": false, "isDownloadJava": false, - "mirrors": [ - "http://mirror.gravitlauncher.ml/" - ], - "binaryName": "Launcher", - "address": "localhost", - "bindAddress": "0.0.0.0", - "env": "STD", - "isWarningMissArchJava": false + "isWarningMissArchJava": false, + "enabledProGuard": true, + "stripLineNumbers": true, + "startScript": ".\\start.sh" } \ No newline at end of file diff --git a/Launcher/src/main/java/ru/gravit/launcher/JSApplication.java b/Launcher/src/main/java/ru/gravit/launcher/JSApplication.java index b2c5721d..eb7f8010 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/JSApplication.java +++ b/Launcher/src/main/java/ru/gravit/launcher/JSApplication.java @@ -4,7 +4,6 @@ import java.util.concurrent.atomic.AtomicReference; -@SuppressWarnings("AbstractClassNeverImplemented") public abstract class JSApplication extends Application { private static final AtomicReference INSTANCE = new AtomicReference<>(); @@ -13,8 +12,6 @@ public static JSApplication getInstance() { return INSTANCE.get(); } - - @SuppressWarnings("ConstructorNotProtectedInAbstractClass") public JSApplication() { INSTANCE.set(this); } 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 dea50c57..7ee61ac1 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java +++ b/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java @@ -279,9 +279,6 @@ public static boolean isUsingWrapper() { } private static void launch(ClientProfile profile, Params params) throws Throwable { - // Add natives path - //JVMHelper.addNativePath(params.clientDir.resolve(NATIVES_DIR)); - // Add client args Collection args = new LinkedList<>(); if (profile.getVersion().compareTo(ClientProfile.Version.MC164) >= 0) @@ -338,16 +335,12 @@ public static Process launch( LogHelper.error(e); } }).start(); - // Resolve java bin and set permissions - LogHelper.debug("Resolving JVM binary"); - //Path javaBin = IOHelper.resolveJavaBin(jvmDir); checkJVMBitsAndVersion(); // Fill CLI arguments List args = new LinkedList<>(); boolean wrapper = isUsingWrapper(); - Path javaBin; - /*if (wrapper) javaBin = AvanguardStarter.wrapper; - else*/ + LogHelper.debug("Resolving JVM binary"); + Path javaBin = null; if (isDownloadJava) { //Linux и Mac не должны скачивать свою JVM if (JVMHelper.OS_TYPE == OS.MUSTDIE) diff --git a/LauncherAPI/src/main/java/com/mojang/authlib/minecraft/MinecraftProfileTexture.java b/LauncherAPI/src/main/java/com/mojang/authlib/minecraft/MinecraftProfileTexture.java index 700534b8..721b69b7 100644 --- a/LauncherAPI/src/main/java/com/mojang/authlib/minecraft/MinecraftProfileTexture.java +++ b/LauncherAPI/src/main/java/com/mojang/authlib/minecraft/MinecraftProfileTexture.java @@ -41,17 +41,14 @@ public MinecraftProfileTexture(String url, String hash) { this.hash = hash; } - @SuppressWarnings("unused") public String getHash() { return hash; } - @SuppressWarnings({"unused", "SameReturnValue"}) public String getMetadata(String key) { return null; } - @SuppressWarnings("unused") public String getUrl() { return url; } diff --git a/LauncherAPI/src/main/java/com/mojang/authlib/yggdrasil/CompatBridge.java b/LauncherAPI/src/main/java/com/mojang/authlib/yggdrasil/CompatBridge.java index 69304fa2..b722c10b 100644 --- a/LauncherAPI/src/main/java/com/mojang/authlib/yggdrasil/CompatBridge.java +++ b/LauncherAPI/src/main/java/com/mojang/authlib/yggdrasil/CompatBridge.java @@ -13,18 +13,15 @@ import java.util.UUID; // Used to bypass Launcher's class name obfuscation and access API -@SuppressWarnings("unused") @LauncherAPI public final class CompatBridge { public static final int PROFILES_MAX_BATCH_SIZE = SerializeLimits.MAX_BATCH_SIZE; - @SuppressWarnings("unused") public static CompatProfile checkServer(String username, String serverID) throws Exception { LogHelper.debug("CompatBridge.checkServer, Username: '%s', Server ID: %s", username, serverID); return CompatProfile.fromPlayerProfile(new CheckServerRequest(username, serverID).request()); } - @SuppressWarnings("unused") public static boolean joinServer(String username, String accessToken, String serverID) throws Exception { // Join server @@ -32,17 +29,14 @@ public static boolean joinServer(String username, String accessToken, String ser return new JoinServerRequest(username, accessToken, serverID).request(); } - @SuppressWarnings("unused") public static CompatProfile profileByUsername(String username) throws Exception { return CompatProfile.fromPlayerProfile(new ProfileByUsernameRequest(username).request()); } - @SuppressWarnings("unused") public static CompatProfile profileByUUID(UUID uuid) throws Exception { return CompatProfile.fromPlayerProfile(new ProfileByUUIDRequest(uuid).request()); } - @SuppressWarnings("unused") public static CompatProfile[] profilesByUsername(String... usernames) throws Exception { PlayerProfile[] profiles = new BatchProfileByUsernameRequest(usernames).request(); diff --git a/LauncherAPI/src/main/java/com/mojang/authlib/yggdrasil/CompatProfile.java b/LauncherAPI/src/main/java/com/mojang/authlib/yggdrasil/CompatProfile.java index 14da7047..fd19a64c 100644 --- a/LauncherAPI/src/main/java/com/mojang/authlib/yggdrasil/CompatProfile.java +++ b/LauncherAPI/src/main/java/com/mojang/authlib/yggdrasil/CompatProfile.java @@ -7,7 +7,6 @@ import java.util.UUID; -@SuppressWarnings("unused") @LauncherAPI public final class CompatProfile { public static final String SKIN_URL_PROPERTY = Launcher.SKIN_URL_PROPERTY; diff --git a/LauncherAPI/src/main/java/com/mojang/authlib/yggdrasil/LegacyBridge.java b/LauncherAPI/src/main/java/com/mojang/authlib/yggdrasil/LegacyBridge.java index 72a7b255..378145e6 100644 --- a/LauncherAPI/src/main/java/com/mojang/authlib/yggdrasil/LegacyBridge.java +++ b/LauncherAPI/src/main/java/com/mojang/authlib/yggdrasil/LegacyBridge.java @@ -10,27 +10,23 @@ // Used by 1.6.4 and below versions @LauncherAPI public final class LegacyBridge { - @SuppressWarnings("unused") public static boolean checkServer(String username, String serverID) throws Exception { LogHelper.debug("LegacyBridge.checkServer, Username: '%s', Server ID: %s", username, serverID); return new CheckServerRequest(username, serverID).request() != null; } - @SuppressWarnings("unused") public static String getCloakURL(String username) { LogHelper.debug("LegacyBridge.getCloakURL: '%s'", username); return CommonHelper.replace(System.getProperty("launcher.legacy.cloaksURL", "http://skins.minecraft.net/MinecraftCloaks/%username%.png"), "username", IOHelper.urlEncode(username)); } - @SuppressWarnings("unused") public static String getSkinURL(String username) { LogHelper.debug("LegacyBridge.getSkinURL: '%s'", username); return CommonHelper.replace(System.getProperty("launcher.legacy.skinsURL", "http://skins.minecraft.net/MinecraftSkins/%username%.png"), "username", IOHelper.urlEncode(username)); } - @SuppressWarnings("unused") public static String joinServer(String username, String accessToken, String serverID) { // Join server diff --git a/LauncherAPI/src/main/java/com/mojang/authlib/yggdrasil/YggdrasilAuthenticationService.java b/LauncherAPI/src/main/java/com/mojang/authlib/yggdrasil/YggdrasilAuthenticationService.java index 6cf0b6d6..6579f2e4 100644 --- a/LauncherAPI/src/main/java/com/mojang/authlib/yggdrasil/YggdrasilAuthenticationService.java +++ b/LauncherAPI/src/main/java/com/mojang/authlib/yggdrasil/YggdrasilAuthenticationService.java @@ -10,7 +10,6 @@ import java.net.Proxy; public final class YggdrasilAuthenticationService implements AuthenticationService { - @SuppressWarnings("UnusedParameters") public YggdrasilAuthenticationService(Proxy proxy, String clientToken) { LogHelper.debug("Patched AuthenticationService created: '%s'", clientToken); } 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 b184fc5e..e75f0be8 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/Request.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/Request.java @@ -54,7 +54,6 @@ protected final void readError(HInput input) throws IOException { } @LauncherAPI - @SuppressWarnings("DesignForExtension") public R request() throws Exception { if (!started.compareAndSet(false, true)) throw new IllegalStateException("Request already started"); 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 d694773e..adf44662 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 @@ -83,7 +83,6 @@ public Integer getType() { } @Override - @SuppressWarnings("CallToSystemExit") protected Result requestDo(HInput input, HOutput output) throws Exception { Path launcherPath = IOHelper.getCodeSource(LauncherRequest.class); byte[] digest = SecurityHelper.digest(SecurityHelper.DigestAlgorithm.SHA512, launcherPath); diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/LegacyLauncherRequest.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/LegacyLauncherRequest.java index 0c5ec83b..c387c5b6 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/LegacyLauncherRequest.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/LegacyLauncherRequest.java @@ -93,7 +93,6 @@ public Integer getType() { } @Override - @SuppressWarnings("CallToSystemExit") protected Result requestDo(HInput input, HOutput output) throws Exception { output.writeBoolean(EXE_BINARY); output.flush(); diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/JsonRequestAdapter.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/JsonRequestAdapter.java index 72411843..da6d860d 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/JsonRequestAdapter.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/JsonRequestAdapter.java @@ -12,7 +12,6 @@ public JsonRequestAdapter(ClientWebSocketService service) { this.service = service; } - @SuppressWarnings("unchecked") @Override public RequestInterface deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { String typename = json.getAsJsonObject().getAsJsonPrimitive(PROP_NAME).getAsString(); diff --git a/ServerWrapper/src/main/java/ru/gravit/launcher/server/ServerAgent.java b/ServerWrapper/src/main/java/ru/gravit/launcher/server/ServerAgent.java index 2acd9202..2b248e36 100644 --- a/ServerWrapper/src/main/java/ru/gravit/launcher/server/ServerAgent.java +++ b/ServerWrapper/src/main/java/ru/gravit/launcher/server/ServerAgent.java @@ -46,7 +46,6 @@ public static long getObjSize(Object obj) { public static Boolean isAutoloadLibraries = Boolean.getBoolean(System.getProperty("serverwrapper,agentlibrariesload", "false")); public static Boolean isAgentProxy = Boolean.getBoolean(System.getProperty("serverwrapper,agentproxy", "false")); - @SuppressWarnings("JavaLangInvokeHandleSignature") public static void premain(String agentArgument, Instrumentation instrumentation) { LogHelper.debug("Server Agent"); inst = instrumentation; 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 9e8e84a8..8fa85a88 100644 --- a/ServerWrapper/src/main/java/ru/gravit/launcher/server/ServerWrapper.java +++ b/ServerWrapper/src/main/java/ru/gravit/launcher/server/ServerWrapper.java @@ -85,8 +85,7 @@ public static void initGson() Launcher.gson = Launcher.gsonBuilder.create(); } - @SuppressWarnings("ConfusingArgumentToVarargsMethod") - public static void main(String[] args) throws Throwable { + public static void main(String... args) throws Throwable { ServerWrapper wrapper = new ServerWrapper(); LogHelper.printVersion("ServerWrapper"); LogHelper.printLicense("ServerWrapper"); diff --git a/libLauncher/src/main/java/ru/gravit/launcher/AutogenConfig.java b/libLauncher/src/main/java/ru/gravit/launcher/AutogenConfig.java index 6213046c..ffbd4ff1 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/AutogenConfig.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/AutogenConfig.java @@ -5,7 +5,8 @@ public class AutogenConfig { public String address; public int port; public int clientPort; - private boolean isInitModules; + @SuppressWarnings("unused") + private boolean isInitModules; public boolean isUsingWrapper; public boolean isDownloadJava; //Выставление этого флага требует модификации runtime части public String secretKeyClient; @@ -17,11 +18,8 @@ public class AutogenConfig { // 3 - Production (дебаг выключен, минимальный объем сообщений, stacktrace не выводится) AutogenConfig() { - } - @SuppressWarnings("UnnecessaryReturnStatement") public void initModules() { - if (isInitModules) return; } } diff --git a/libLauncher/src/main/java/ru/gravit/launcher/LauncherAgent.java b/libLauncher/src/main/java/ru/gravit/launcher/LauncherAgent.java index eb3925bd..19b6794e 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/LauncherAgent.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/LauncherAgent.java @@ -7,7 +7,7 @@ import java.util.jar.JarFile; @LauncherAPI -public class LauncherAgent { +public final class LauncherAgent { private static boolean isAgentStarted = false; public static Instrumentation inst; diff --git a/libLauncher/src/main/java/ru/gravit/launcher/LauncherConfig.java b/libLauncher/src/main/java/ru/gravit/launcher/LauncherConfig.java index bff7bfcb..067df7a0 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/LauncherConfig.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/LauncherConfig.java @@ -84,7 +84,6 @@ public LauncherConfig(HInput input) throws IOException, InvalidKeySpecException } @LauncherAPI - @SuppressWarnings("AssignmentToCollectionOrArrayFieldFromParameter") public LauncherConfig(String address, int port, RSAPublicKey publicKey, Map runtime, String projectname) { this.address = InetSocketAddress.createUnresolved(address, port); this.publicKey = Objects.requireNonNull(publicKey, "publicKey"); @@ -97,7 +96,6 @@ public LauncherConfig(String address, int port, RSAPublicKey publicKey, Map runtime) { this.address = InetSocketAddress.createUnresolved(address, port); this.publicKey = Objects.requireNonNull(publicKey, "publicKey"); diff --git a/libLauncher/src/main/java/ru/gravit/launcher/profiles/ClientProfile.java b/libLauncher/src/main/java/ru/gravit/launcher/profiles/ClientProfile.java index 06862a2b..44a6248d 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/profiles/ClientProfile.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/profiles/ClientProfile.java @@ -10,9 +10,8 @@ import java.net.InetSocketAddress; import java.util.*; -@SuppressWarnings("ComparableImplementedButEqualsNotOverridden") public final class ClientProfile implements Comparable { - public ClientProfile(String version, String assetIndex, int sortIndex, String title, String serverAddress, int serverPort, boolean updateFastCheck, boolean useWhitelist, String mainClass) { + public ClientProfile(String version, String assetIndex, int sortIndex, String title, String serverAddress, int serverPort, boolean updateFastCheck, boolean useWhitelist, String mainClass) { this.version = version; this.assetIndex = assetIndex; this.sortIndex = sortIndex; @@ -421,4 +420,131 @@ public void verify() { // Client launcher VerifyHelper.verify(getTitle(), VerifyHelper.NOT_EMPTY, "Main class can't be empty"); } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((assetDir == null) ? 0 : assetDir.hashCode()); + result = prime * result + ((assetIndex == null) ? 0 : assetIndex.hashCode()); + result = prime * result + ((classPath == null) ? 0 : classPath.hashCode()); + result = prime * result + ((clientArgs == null) ? 0 : clientArgs.hashCode()); + result = prime * result + ((dir == null) ? 0 : dir.hashCode()); + result = prime * result + ((jvmArgs == null) ? 0 : jvmArgs.hashCode()); + result = prime * result + ((mainClass == null) ? 0 : mainClass.hashCode()); + result = prime * result + ((serverAddress == null) ? 0 : serverAddress.hashCode()); + result = prime * result + serverPort; + result = prime * result + sortIndex; + result = prime * result + ((title == null) ? 0 : title.hashCode()); + result = prime * result + ((update == null) ? 0 : update.hashCode()); + result = prime * result + ((updateExclusions == null) ? 0 : updateExclusions.hashCode()); + result = prime * result + (updateFastCheck ? 1231 : 1237); + result = prime * result + ((updateOptional == null) ? 0 : updateOptional.hashCode()); + result = prime * result + ((updateShared == null) ? 0 : updateShared.hashCode()); + result = prime * result + ((updateVerify == null) ? 0 : updateVerify.hashCode()); + result = prime * result + (useWhitelist ? 1231 : 1237); + result = prime * result + ((version == null) ? 0 : version.hashCode()); + result = prime * result + ((whitelist == null) ? 0 : whitelist.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + ClientProfile other = (ClientProfile) obj; + if (assetDir == null) { + if (other.assetDir != null) + return false; + } else if (!assetDir.equals(other.assetDir)) + return false; + if (assetIndex == null) { + if (other.assetIndex != null) + return false; + } else if (!assetIndex.equals(other.assetIndex)) + return false; + if (classPath == null) { + if (other.classPath != null) + return false; + } else if (!classPath.equals(other.classPath)) + return false; + if (clientArgs == null) { + if (other.clientArgs != null) + return false; + } else if (!clientArgs.equals(other.clientArgs)) + return false; + if (dir == null) { + if (other.dir != null) + return false; + } else if (!dir.equals(other.dir)) + return false; + if (jvmArgs == null) { + if (other.jvmArgs != null) + return false; + } else if (!jvmArgs.equals(other.jvmArgs)) + return false; + if (mainClass == null) { + if (other.mainClass != null) + return false; + } else if (!mainClass.equals(other.mainClass)) + return false; + if (serverAddress == null) { + if (other.serverAddress != null) + return false; + } else if (!serverAddress.equals(other.serverAddress)) + return false; + if (serverPort != other.serverPort) + return false; + if (sortIndex != other.sortIndex) + return false; + if (title == null) { + if (other.title != null) + return false; + } else if (!title.equals(other.title)) + return false; + if (update == null) { + if (other.update != null) + return false; + } else if (!update.equals(other.update)) + return false; + if (updateExclusions == null) { + if (other.updateExclusions != null) + return false; + } else if (!updateExclusions.equals(other.updateExclusions)) + return false; + if (updateFastCheck != other.updateFastCheck) + return false; + if (updateOptional == null) { + if (other.updateOptional != null) + return false; + } else if (!updateOptional.equals(other.updateOptional)) + return false; + if (updateShared == null) { + if (other.updateShared != null) + return false; + } else if (!updateShared.equals(other.updateShared)) + return false; + if (updateVerify == null) { + if (other.updateVerify != null) + return false; + } else if (!updateVerify.equals(other.updateVerify)) + return false; + if (useWhitelist != other.useWhitelist) + return false; + if (version == null) { + if (other.version != null) + return false; + } else if (!version.equals(other.version)) + return false; + if (whitelist == null) { + if (other.whitelist != null) + return false; + } else if (!whitelist.equals(other.whitelist)) + return false; + return true; + } } diff --git a/libLauncher/src/main/java/ru/gravit/utils/helper/JVMHelper.java b/libLauncher/src/main/java/ru/gravit/utils/helper/JVMHelper.java index 6d608413..32b66599 100644 --- a/libLauncher/src/main/java/ru/gravit/utils/helper/JVMHelper.java +++ b/libLauncher/src/main/java/ru/gravit/utils/helper/JVMHelper.java @@ -14,7 +14,6 @@ import java.util.Map; public final class JVMHelper { - @SuppressWarnings("unused") @LauncherAPI public enum OS { MUSTDIE("mustdie"), LINUX("linux"), MACOSX("macosx"); @@ -84,7 +83,6 @@ public static Class firstClass(String... names) throws ClassNotFoundException } @LauncherAPI - @SuppressWarnings("CallToSystemGC") public static void fullGC() { RUNTIME.gc(); RUNTIME.runFinalization(); @@ -122,7 +120,6 @@ public static void checkStackTrace(Class mainClass) { } } - @SuppressWarnings("CallToSystemGetenv") private static int getCorrectOSArch() { // As always, mustdie must die if (OS_TYPE == OS.MUSTDIE)