diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java index 8d135b90..d4edeee6 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java @@ -61,11 +61,7 @@ import pro.gravit.launchserver.auth.provider.RejectAuthProvider; import pro.gravit.launchserver.auth.texture.RequestTextureProvider; import pro.gravit.launchserver.auth.texture.TextureProvider; -import pro.gravit.launchserver.binary.EXEL4JLauncherBinary; -import pro.gravit.launchserver.binary.EXELauncherBinary; -import pro.gravit.launchserver.binary.JARLauncherBinary; -import pro.gravit.launchserver.binary.LauncherBinary; -import pro.gravit.launchserver.binary.ProguardConf; +import pro.gravit.launchserver.binary.*; import pro.gravit.launchserver.components.AuthLimiterComponent; import pro.gravit.launchserver.components.Component; import pro.gravit.launchserver.components.RegLimiterComponent; @@ -256,6 +252,7 @@ public void close() { public static class ExeConf { public boolean enabled; + public String alternative; public boolean setMaxVersion; public String maxVersion; public String productName; @@ -721,6 +718,19 @@ private LauncherBinary binary() { LogHelper.error(e); } } + if(config.launch4j.alternative != null) + { + switch (config.launch4j.alternative) { + case "simple": + return new SimpleEXELauncherBinary(this); + case "no": + //None + break; + default: + LogHelper.warning("Alternative %s not found", config.launch4j.alternative); + break; + } + } try { Class.forName("net.sf.launch4j.Builder"); if (config.launch4j.enabled) return new EXEL4JLauncherBinary(this); @@ -766,6 +776,7 @@ private void generateConfigIfNotExists(boolean testEnv) throws IOException { newConfig.launch4j = new ExeConf(); newConfig.launch4j.enabled = true; newConfig.launch4j.copyright = "© GravitLauncher Team"; + newConfig.launch4j.alternative = "no"; newConfig.launch4j.fileDesc = "GravitLauncher ".concat(Version.getVersion().getVersionString()); newConfig.launch4j.fileVer = Version.getVersion().getVersionString().concat(".").concat(String.valueOf(Version.getVersion().patch)); newConfig.launch4j.internalName = "Launcher"; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/SimpleEXELauncherBinary.java b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/SimpleEXELauncherBinary.java index bf1edae4..1bbac5cd 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/SimpleEXELauncherBinary.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/SimpleEXELauncherBinary.java @@ -2,6 +2,7 @@ import pro.gravit.launchserver.LaunchServer; import pro.gravit.utils.helper.IOHelper; +import pro.gravit.utils.helper.LogHelper; import java.io.IOException; import java.io.OutputStream; @@ -9,13 +10,18 @@ public class SimpleEXELauncherBinary extends LauncherBinary { public Path exeTemplate; - protected SimpleEXELauncherBinary(LaunchServer server) { + public SimpleEXELauncherBinary(LaunchServer server) { super(server, LauncherBinary.resolve(server, ".exe")); exeTemplate = server.dir.resolve("SimpleTemplate.exe"); } @Override public void build() throws IOException { + if(!IOHelper.isFile(exeTemplate)) + { + LogHelper.warning("[SimpleEXEBinary] File %s not found. %s not created", exeTemplate.toString(), syncBinaryFile.toString()); + return; + } try(OutputStream output = IOHelper.newOutput(syncBinaryFile)) { IOHelper.transfer(exeTemplate, output);