diff --git a/GITCONVENTION.md b/GITCONVENTION.md new file mode 100644 index 00000000..b5bc7406 --- /dev/null +++ b/GITCONVENTION.md @@ -0,0 +1,42 @@ +# GravitLauncher GitConvention # +Цель конвенции — внедрить простые, прозрачные и эффективные правила работы с Git. + +Разработка GravitLauncher идёт на базе [Git Flow](https://leanpub.com/git-flow/read). Подробности ниже. + +## Ветвление ## + +| Название ветки | Значение ветки | Исходная ветка | Пример ветки | +| ------------- | ------------- | ------------- | ------------- | +| **master** | Полностью готовая для production-а | **release** | | +| **develop** | Разработка нового функционала | **master** | | +| **release** | Тестирование всего нового функционала | **develop** | | +| | | | | +| **bugfix-*** | Исправляет баг нового функционала | **release** | *bugfix-auth* | +| **feature-*** | Добавляет новую возможность | **develop** | *feature-auth* | +| **hotfix-*** | Вносит срочное исправление для production-а | **master** | *hotfix-auth* | +----- +![Image of GitFlow](https://i.ytimg.com/vi/w2r0oLFtXAw/maxresdefault.jpg) +----- + +## Коммиты ## +**Основные правила:** +1. Все коммиты должны быть на русском языке. +2. Запрещено использовать прошедшее время. +3. Обязательно должен быть использован префикс. +4. В конце не должно быть лишнего знака препинания. +5. Длина любой части не должна превышать 100 символов. + +**Структура:** +``` +[Префикс] <Сообщение> +``` + +| Префикс | Значение | Пример | +| ------- | -------- | ------ | +| **[FIX]** | Всё, что касается исправления багов | [FIX] Баг с неудачной авторизацией | +| **[DOCS]** | Всё, что касается документации | [DOCS] Документирование API авторизации | +| **[FEATURE]** | Всё, что касается новых возможностей | [FEATURE] 2FA при авторизации | +| **[STYLE]** | Всё, что касается опечаток и форматирования | [STYLE] Опечатки в модуле авторизации | +| **[REFACTOR]** | Всё, что касается рефакторинга | [REFACTOR] Переход на EDA в модуле авторизации | +| **[TEST]** | Всё, что касается тестирования | [TEST] Покрытие модуля авторизации тестами | +| **[ANY]** | Всё, что не подходит к предыдущему. | [ANY] Подключение Travis CI | diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java index e800ffae..dfc6e4da 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java @@ -139,6 +139,7 @@ public static final class Config { public boolean enabledProGuard; public boolean stripLineNumbers; public boolean deleteTempFiles; + public boolean enableRcon; public String startScript; @@ -189,6 +190,14 @@ public void verify() { { throw new NullPointerException("TextureProvider must not be null"); } + if(permissionsHandler == null) + { + throw new NullPointerException("PermissionsHandler must not be null"); + } + if(env == null) + { + throw new NullPointerException("Env must not be null"); + } } } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/MySQLAuthHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/MySQLAuthHandler.java index 0cdde91d..41d65110 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/MySQLAuthHandler.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/MySQLAuthHandler.java @@ -8,6 +8,7 @@ import java.util.UUID; import ru.gravit.launchserver.auth.MySQLSourceConfig; +import ru.gravit.utils.helper.LogHelper; public final class MySQLAuthHandler extends CachedAuthHandler { private MySQLSourceConfig mySQLHolder; @@ -25,6 +26,13 @@ public final class MySQLAuthHandler extends CachedAuthHandler { @Override public void init() { + //Verify + if(mySQLHolder == null) LogHelper.error("[Verify][AuthHandler] mySQLHolder cannot be null"); + if(uuidColumn == null) LogHelper.error("[Verify][AuthHandler] uuidColumn cannot be null"); + if(usernameColumn == null) LogHelper.error("[Verify][AuthHandler] usernameColumn cannot be null"); + if(accessTokenColumn == null) LogHelper.error("[Verify][AuthHandler] accessTokenColumn cannot be null"); + if(serverIDColumn == null) LogHelper.error("[Verify][AuthHandler] serverIDColumn cannot be null"); + if(table == null) LogHelper.error("[Verify][AuthHandler] table cannot be null"); // Prepare SQL queries queryByUUIDSQL = String.format("SELECT %s, %s, %s, %s FROM %s WHERE %s=? LIMIT 1", uuidColumn, usernameColumn, accessTokenColumn, serverIDColumn, table, uuidColumn); 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 b3554bd5..9f2dcdb0 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 @@ -9,6 +9,7 @@ import ru.gravit.launchserver.auth.AuthException; import ru.gravit.launchserver.auth.MySQLSourceConfig; import ru.gravit.utils.helper.CommonHelper; +import ru.gravit.utils.helper.LogHelper; import ru.gravit.utils.helper.SecurityHelper; public final class MySQLAuthProvider extends AuthProvider { @@ -18,6 +19,13 @@ public final class MySQLAuthProvider extends AuthProvider { private String[] queryParams; private boolean usePermission; + @Override + public void init() { + if(query == null) LogHelper.error("[Verify][AuthProvider] query cannot be null"); + if(message == null) LogHelper.error("[Verify][AuthProvider] message cannot be null"); + if(mySQLHolder == null) LogHelper.error("[Verify][AuthProvider] mySQLHolder cannot be null"); + } + @Override public AuthProviderResult auth(String login, String password, String ip) throws SQLException, AuthException { Connection c = mySQLHolder.getConnection(); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/RequestAuthProvider.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/RequestAuthProvider.java index 0d5a10c2..917ca21e 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/RequestAuthProvider.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/RequestAuthProvider.java @@ -8,6 +8,7 @@ import ru.gravit.launcher.ClientPermissions; import ru.gravit.utils.helper.CommonHelper; import ru.gravit.utils.helper.IOHelper; +import ru.gravit.utils.helper.LogHelper; import ru.gravit.utils.helper.SecurityHelper; public final class RequestAuthProvider extends AuthProvider { @@ -19,6 +20,8 @@ public final class RequestAuthProvider extends AuthProvider { @Override public void init() { + if(url == null) LogHelper.error("[Verify][AuthProvider] url cannot be null"); + if(response == null) LogHelper.error("[Verify][AuthProvider] response cannot be null"); pattern = Pattern.compile(response); } 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 3858c826..51b125bd 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,13 +44,7 @@ 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.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.launchserver.command.service.*; import ru.gravit.utils.helper.LogHelper; import ru.gravit.utils.helper.VerifyHelper; @@ -153,6 +147,7 @@ protected CommandHandler(LaunchServer server) { registerCommand("configHelp", new ConfigHelpCommand(server)); registerCommand("configList", new ConfigListCommand(server)); registerCommand("swapAuthProvider", new SwapAuthProviderCommand(server)); + registerCommand("serverStatus", new ServerStatusCommand(server)); } 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 new file mode 100644 index 00000000..8978453b --- /dev/null +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/service/ServerStatusCommand.java @@ -0,0 +1,41 @@ +package ru.gravit.launchserver.command.service; + +import ru.gravit.launchserver.LaunchServer; +import ru.gravit.launchserver.auth.handler.CachedAuthHandler; +import ru.gravit.launchserver.command.Command; +import ru.gravit.utils.helper.JVMHelper; +import ru.gravit.utils.helper.LogHelper; + +public class ServerStatusCommand extends Command { + public ServerStatusCommand(LaunchServer server) { + super(server); + } + + @Override + public String getArgsDescription() { + return null; + } + + @Override + public String getUsageDescription() { + return "Check server status"; + } + + @Override + public void invoke(String... args) throws Exception { + LogHelper.info("Show server status"); + LogHelper.info("Memory: free %d | total: %d | max: %d", JVMHelper.RUNTIME.freeMemory(), JVMHelper.RUNTIME.totalMemory(),JVMHelper.RUNTIME.maxMemory()); + long uptime = JVMHelper.RUNTIME_MXBEAN.getUptime() / 1000; + long second = uptime % 60; + long min = (uptime / 60) % 60; + long hour = (uptime / 60 / 60) % 24; + long days = (uptime / 60 / 60 / 24); + 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); + LogHelper.info("Sessions: %d | Modules: %d | Commands: %d",server.sessionManager.getSessions().size(), server.modulesManager.modules.size(), server.commandHandler.commandsMap().size()); + if(server.config.authHandler instanceof CachedAuthHandler) + { + LogHelper.info("AuthHandler: EntryCache: %d | usernameCache: %d",((CachedAuthHandler) server.config.authHandler).getEntryCache().size(),((CachedAuthHandler) server.config.authHandler).getUsernamesCache().size()); + } + } +} diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/ModulesManager.java b/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/ModulesManager.java index 3364a488..f20d7d90 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/ModulesManager.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/ModulesManager.java @@ -3,17 +3,20 @@ import java.net.URL; import java.util.ArrayList; -import ru.gravit.launcher.modules.SimpleModuleManager; +import ru.gravit.launcher.managers.ModulesConfigManager; +import ru.gravit.launcher.managers.SimpleModuleManager; import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.modules.CoreModule; import ru.gravit.launchserver.modules.LaunchServerModuleContext; import ru.gravit.utils.PublicURLClassLoader; public class ModulesManager extends SimpleModuleManager { + public ModulesConfigManager configManager; public ModulesManager(LaunchServer lsrv) { modules = new ArrayList<>(1); + configManager = new ModulesConfigManager(lsrv.dir.resolve("config")); classloader = new PublicURLClassLoader(new URL[0], ClassLoader.getSystemClassLoader()); - context = new LaunchServerModuleContext(lsrv, classloader); + context = new LaunchServerModuleContext(lsrv, classloader, configManager); registerCoreModule(); } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/modules/LaunchServerModuleContext.java b/LaunchServer/src/main/java/ru/gravit/launchserver/modules/LaunchServerModuleContext.java index 30279000..1e43c23e 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/modules/LaunchServerModuleContext.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/modules/LaunchServerModuleContext.java @@ -1,6 +1,8 @@ package ru.gravit.launchserver.modules; +import ru.gravit.launcher.managers.ModulesConfigManager; import ru.gravit.launcher.modules.ModuleContext; +import ru.gravit.launcher.modules.ModulesConfigManagerInterface; import ru.gravit.launcher.modules.ModulesManagerInterface; import ru.gravit.launchserver.LaunchServer; import ru.gravit.utils.PublicURLClassLoader; @@ -8,10 +10,12 @@ public class LaunchServerModuleContext implements ModuleContext { public final LaunchServer launchServer; public final PublicURLClassLoader classloader; + public final ModulesConfigManager modulesConfigManager; - public LaunchServerModuleContext(LaunchServer server, PublicURLClassLoader classloader) { + public LaunchServerModuleContext(LaunchServer server, PublicURLClassLoader classloader, ModulesConfigManager modulesConfigManager) { launchServer = server; this.classloader = classloader; + this.modulesConfigManager = modulesConfigManager; } @Override @@ -23,4 +27,9 @@ public Type getType() { public ModulesManagerInterface getModulesManager() { return launchServer.modulesManager; } + + @Override + public ModulesConfigManagerInterface getModulesConfigManager() { + return modulesConfigManager; + } } 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 cc1784d6..8101a2a4 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/response/Response.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/response/Response.java @@ -9,6 +9,7 @@ import ru.gravit.launcher.serialize.HInput; import ru.gravit.launcher.serialize.HOutput; import ru.gravit.launchserver.LaunchServer; +import ru.gravit.launchserver.response.admin.ExecCommandResponse; import ru.gravit.launchserver.response.auth.AuthResponse; import ru.gravit.launchserver.response.auth.AuthServerResponse; import ru.gravit.launchserver.response.auth.ChangeServerResponse; @@ -60,6 +61,7 @@ public static void registerResponses() { registerResponse(RequestType.SERVERAUTH.getNumber(), AuthServerResponse::new); registerResponse(RequestType.SETPROFILE.getNumber(), SetProfileResponse::new); registerResponse(RequestType.CHANGESERVER.getNumber(), ChangeServerResponse::new); + registerResponse(RequestType.EXECCOMMAND.getNumber(), ExecCommandResponse::new); } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/response/admin/ExecCommandResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/response/admin/ExecCommandResponse.java new file mode 100644 index 00000000..7aae8b8b --- /dev/null +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/response/admin/ExecCommandResponse.java @@ -0,0 +1,42 @@ +package ru.gravit.launchserver.response.admin; + +import ru.gravit.launcher.serialize.HInput; +import ru.gravit.launcher.serialize.HOutput; +import ru.gravit.launcher.serialize.SerializeLimits; +import ru.gravit.launchserver.LaunchServer; +import ru.gravit.launchserver.response.Response; +import ru.gravit.launchserver.socket.Client; +import ru.gravit.utils.helper.LogHelper; + +import java.io.IOException; + +public class ExecCommandResponse extends Response { + public ExecCommandResponse(LaunchServer server, long session, HInput input, HOutput output, String ip) { + super(server, session, input, output, ip); + } + + @Override + public void reply() throws Exception { + Client clientData = server.sessionManager.getClient(session); + if(!clientData.isAuth || !clientData.permissions.canAdmin || !server.config.enableRcon) requestError("Access denied"); + writeNoError(output); + String cmd = input.readString(SerializeLimits.MAX_COMMAND); + LogHelper.Output loutput = message -> { + try { + output.writeBoolean(true); + output.writeString(message, SerializeLimits.MAX_COMMAND); + } catch (IOException e) { + LogHelper.error(e); + } + }; + LogHelper.addOutput(loutput); + try + { + server.commandHandler.eval(cmd,false); + output.writeBoolean(false); + } finally { + LogHelper.removeOutput(loutput); + } + writeNoError(output); + } +} 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 e2862de7..1c45abdb 100644 --- a/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/config.cfg +++ b/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/config.cfg @@ -1,8 +1,8 @@ { "port": 7240, - "address": "127.0.0.1", + "address": "xx.xx", "bindAddress": "0.0.0.0", - "projectName": "Test", + "projectName": "xxxx", "mirrors": [ "http://mirror.gravitlauncher.ml/" ], diff --git a/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/profile1.10.2.cfg b/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/profile1.10.2.cfg index b1fc0afd..423bfe49 100644 --- a/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/profile1.10.2.cfg +++ b/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/profile1.10.2.cfg @@ -3,7 +3,7 @@ "assetIndex": "1.10.2", "assetDir": "asset1.10", "dir": "HiTech", - "info": "My Info", + "info": "Информация о сервере", "sortIndex": 0, "title": "xxxxxxxx", "serverAddress": "localhost", @@ -38,5 +38,8 @@ "--tweakClass", "net.minecraftforge.fml.common.launcher.FMLTweaker", "--tweakClass", "com.mumfrey.liteloader.launch.LiteLoaderTweaker" ], + "optionalJVMArgs": [], + "optionalClientArgs": [], + "optionalClassPath": [], "whitelist": [] } \ No newline at end of file diff --git a/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/profile1.11.2.cfg b/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/profile1.11.2.cfg index 6337cdae..77a61146 100644 --- a/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/profile1.11.2.cfg +++ b/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/profile1.11.2.cfg @@ -3,7 +3,7 @@ "assetIndex": "1.11.2", "assetDir": "asset1.11", "dir": "HiTech", - "info": "My Info", + "info": "Информация о сервере", "sortIndex": 0, "title": "xxxxxxxx", "serverAddress": "localhost", @@ -38,5 +38,8 @@ "--tweakClass", "net.minecraftforge.fml.common.launcher.FMLTweaker", "--tweakClass", "com.mumfrey.liteloader.launch.LiteLoaderTweaker" ], + "optionalJVMArgs": [], + "optionalClientArgs": [], + "optionalClassPath": [], "whitelist": [] } \ No newline at end of file diff --git a/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/profile1.12.2.cfg b/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/profile1.12.2.cfg index 5869c484..b4b2a11f 100644 --- a/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/profile1.12.2.cfg +++ b/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/profile1.12.2.cfg @@ -3,7 +3,7 @@ "assetIndex": "1.12.2", "assetDir": "asset1.12", "dir": "HiTech", - "info": "My Info", + "info": "Информация о сервере", "sortIndex": 0, "title": "xxxxxxxx", "serverAddress": "localhost", @@ -38,5 +38,8 @@ "--tweakClass", "net.minecraftforge.fml.common.launcher.FMLTweaker", "--tweakClass", "com.mumfrey.liteloader.launch.LiteLoaderTweaker" ], + "optionalJVMArgs": [], + "optionalClientArgs": [], + "optionalClassPath": [], "whitelist": [] } \ No newline at end of file diff --git a/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/profile1.13.1.cfg b/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/profile1.13.1.cfg index 0b832494..12f2ccae 100644 --- a/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/profile1.13.1.cfg +++ b/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/profile1.13.1.cfg @@ -3,7 +3,7 @@ "assetIndex": "1.13.1", "assetDir": "asset1.13.1", "dir": "HiTech", - "info": "My Info", + "info": "Информация о сервере", "sortIndex": 0, "title": "xxxxxxxx", "serverAddress": "localhost", @@ -36,5 +36,8 @@ "classPath": ["forge.jar", "liteloader.jar", "minecraft.jar", "libraries"], "clientArgs": [ ], + "optionalJVMArgs": [], + "optionalClientArgs": [], + "optionalClassPath": [], "whitelist": [] } \ No newline at end of file diff --git a/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/profile1.13.cfg b/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/profile1.13.cfg index d0bbdb1a..19afb377 100644 --- a/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/profile1.13.cfg +++ b/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/profile1.13.cfg @@ -3,7 +3,7 @@ "assetIndex": "1.13", "assetDir": "asset1.13", "dir": "HiTech", - "info": "My Info", + "info": "Информация о сервере", "sortIndex": 0, "title": "xxxxxxxx", "serverAddress": "localhost", @@ -36,5 +36,8 @@ "classPath": ["forge.jar", "liteloader.jar", "minecraft.jar", "libraries"], "clientArgs": [ ], + "optionalJVMArgs": [], + "optionalClientArgs": [], + "optionalClassPath": [], "whitelist": [] } \ No newline at end of file diff --git a/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/profile1.4.7.cfg b/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/profile1.4.7.cfg index a6517b83..81857091 100644 --- a/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/profile1.4.7.cfg +++ b/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/profile1.4.7.cfg @@ -3,7 +3,7 @@ "assetIndex": "---", "assetDir": "asset1.4.7", "dir": "xxxxxxx", - "info": "My Info", + "info": "Информация о сервере", "sortIndex": 0, "title": "Test1.4.7", "serverAddress": "localhost", @@ -31,5 +31,8 @@ ], "classPath": ["minecraft.jar", "libraries"], "clientArgs": [], + "optionalJVMArgs": [], + "optionalClientArgs": [], + "optionalClassPath": [], "whitelist": [] } \ No newline at end of file diff --git a/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/profile1.5.2.cfg b/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/profile1.5.2.cfg index 66c5a67b..cbc38a43 100644 --- a/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/profile1.5.2.cfg +++ b/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/profile1.5.2.cfg @@ -3,7 +3,7 @@ "assetIndex": "---", "assetDir": "asset1.5.2", "dir": "xxxxxxx", - "info": "My Info", + "info": "Информация о сервере", "sortIndex": 0, "title": "Test1.5.2", "serverAddress": "localhost", @@ -31,5 +31,8 @@ ], "classPath": ["minecraft.jar", "libraries"], "clientArgs": [], + "optionalJVMArgs": [], + "optionalClientArgs": [], + "optionalClassPath": [], "whitelist": [] } \ No newline at end of file diff --git a/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/profile1.6.4.cfg b/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/profile1.6.4.cfg index 2937adc1..9e2af4dc 100644 --- a/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/profile1.6.4.cfg +++ b/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/profile1.6.4.cfg @@ -3,7 +3,7 @@ "assetIndex": "---", "assetDir": "asset1.6.4", "dir": "xxxxxxx", - "info": "My Info", + "info": "Информация о сервере", "sortIndex": 0, "title": "Test1.6.4", "serverAddress": "localhost", @@ -36,5 +36,8 @@ "--tweakClass", "cpw.mods.fml.common.launcher.FMLTweaker", "--tweakClass", "com.mumfrey.liteloader.launch.LiteLoaderTweaker" ], + "optionalJVMArgs": [], + "optionalClientArgs": [], + "optionalClassPath": [], "whitelist": [] } \ No newline at end of file diff --git a/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/profile1.7.10.cfg b/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/profile1.7.10.cfg index 6bf71d1b..fa35d761 100644 --- a/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/profile1.7.10.cfg +++ b/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/profile1.7.10.cfg @@ -3,7 +3,7 @@ "assetIndex": "1.7.10", "assetDir": "asset1.7.10", "dir": "xxxxxxx", - "info": "My Info", + "info": "Информация о сервере", "sortIndex": 0, "title": "Test1.7.10", "serverAddress": "localhost", @@ -34,5 +34,8 @@ "--tweakClass", "cpw.mods.fml.common.launcher.FMLTweaker", "--tweakClass", "com.mumfrey.liteloader.launch.LiteLoaderTweaker" ], + "optionalJVMArgs": [], + "optionalClientArgs": [], + "optionalClassPath": [], "whitelist": [] } \ No newline at end of file diff --git a/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/profile1.7.2.cfg b/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/profile1.7.2.cfg index 598164f3..089b7a85 100644 --- a/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/profile1.7.2.cfg +++ b/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/profile1.7.2.cfg @@ -3,7 +3,7 @@ "assetIndex": "1.7.2", "assetDir": "asset1.7.2", "dir": "xxxxxxx", - "info": "My Info", + "info": "Информация о сервере", "sortIndex": 0, "title": "Test1.7.2", "serverAddress": "localhost", @@ -34,5 +34,8 @@ "--tweakClass", "cpw.mods.fml.common.launcher.FMLTweaker", "--tweakClass", "com.mumfrey.liteloader.launch.LiteLoaderTweaker" ], + "optionalJVMArgs": [], + "optionalClientArgs": [], + "optionalClassPath": [], "whitelist": [] } \ No newline at end of file diff --git a/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/profile1.8.9.cfg b/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/profile1.8.9.cfg index 34d26418..0550c3de 100644 --- a/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/profile1.8.9.cfg +++ b/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/profile1.8.9.cfg @@ -3,7 +3,7 @@ "assetIndex": "1.8.9", "assetDir": "asset1.8.9", "dir": "xxxxxxx", - "info": "My Info", + "info": "Информация о сервере", "sortIndex": 0, "title": "Test1.8.9", "serverAddress": "localhost", @@ -34,5 +34,8 @@ "--tweakClass", "net.minecraftforge.fml.common.launcher.FMLTweaker", "--tweakClass", "com.mumfrey.liteloader.launch.LiteLoaderTweaker" ], + "optionalJVMArgs": [], + "optionalClientArgs": [], + "optionalClassPath": [], "whitelist": [] } \ No newline at end of file diff --git a/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/profile1.9.4.cfg b/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/profile1.9.4.cfg index 4d4dde69..3dff6561 100644 --- a/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/profile1.9.4.cfg +++ b/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/profile1.9.4.cfg @@ -3,7 +3,7 @@ "assetIndex": "1.9.4", "assetDir": "asset1.9.4", "dir": "xxxxxxx", - "info": "My Info", + "info": "Информация о сервере", "sortIndex": 0, "title": "Test1.9.4", "serverAddress": "localhost", @@ -34,5 +34,8 @@ "--tweakClass", "net.minecraftforge.fml.common.launcher.FMLTweaker", "--tweakClass", "com.mumfrey.liteloader.launch.LiteLoaderTweaker" ], + "optionalJVMArgs": [], + "optionalClientArgs": [], + "optionalClassPath": [], "whitelist": [] } \ No newline at end of file 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 86531160..00ba27d6 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java +++ b/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java @@ -69,6 +69,10 @@ public static final class Params extends StreamObject { @LauncherAPI public final Set updateOptional; @LauncherAPI + public final Set optionalClientArgs; + @LauncherAPI + public final Set optionalClassPath; + @LauncherAPI public final String accessToken; @LauncherAPI public final boolean autoEnter; @@ -89,9 +93,19 @@ public Params(byte[] launcherDigest, Path assetDir, Path clientDir, PlayerProfil boolean autoEnter, boolean fullScreen, int ram, int width, int height) { this.launcherDigest = launcherDigest.clone(); this.updateOptional = new HashSet<>(); + this.optionalClientArgs = new HashSet<>(); + this.optionalClassPath = new HashSet<>(); for (ClientProfile.OptionalFile s : Launcher.profile.getOptional()) { if (s.mark) updateOptional.add(s); } + for(ClientProfile.OptionalArgs s : Launcher.profile.getOptionalClientArgs()) + { + if(s.mark) optionalClientArgs.add(s); + } + for(ClientProfile.OptionalArgs s : Launcher.profile.getOptionalClassPath()) + { + if(s.mark) optionalClassPath.add(s); + } // Client paths this.assetDir = assetDir; this.clientDir = clientDir; @@ -114,9 +128,29 @@ public Params(HInput input) throws Exception { assetDir = IOHelper.toPath(input.readString(0)); clientDir = IOHelper.toPath(input.readString(0)); updateOptional = new HashSet<>(); + optionalClientArgs = new HashSet<>(); + optionalClassPath = new HashSet<>(); int len = input.readLength(128); for (int i = 0; i < len; ++i) { - updateOptional.add(new ClientProfile.OptionalFile(input.readString(512), true)); + String file = input.readString(512); + boolean mark = input.readBoolean(); + updateOptional.add(new ClientProfile.OptionalFile(file, mark)); + } + len = input.readLength(256); + for (int i = 0; i < len; ++i) { + int len2 = input.readLength(16); + boolean mark = input.readBoolean(); + String[] optArgs = new String[len]; + for(int j=0;j args, ClientProfile profile Collections.addAll(args, "--server", profile.getServerAddress()); Collections.addAll(args, "--port", Integer.toString(profile.getServerPort())); } - + for(ClientProfile.OptionalArgs optionalArgs : params.optionalClientArgs) + { + if(optionalArgs.mark) Collections.addAll(args,optionalArgs.args); + } // Add window size args if (params.fullScreen) Collections.addAll(args, "--fullscreen", Boolean.toString(true)); @@ -375,6 +427,13 @@ public static Process launch( // Add classpath and main class String pathLauncher = IOHelper.getCodeSource(ClientLauncher.class).toString(); Collections.addAll(args, profile.getJvmArgs()); + if(profile.getOptionalJVMArgs() != null) + { + for(ClientProfile.OptionalArgs addArgs : profile.getOptionalJVMArgs()) + { + if(addArgs.mark) Collections.addAll(args,addArgs.args); + } + } Collections.addAll(args, "-Djava.library.path=".concat(params.clientDir.resolve(NATIVES_DIR).toString())); // Add Native Path Collections.addAll(args, "-javaagent:".concat(pathLauncher)); if (wrapper) @@ -456,6 +515,15 @@ public static void main(String... args) throws Throwable { for (Path classpathURL : classPath) { LauncherAgent.addJVMClassPath(classpathURL.toAbsolutePath().toString()); } + for(ClientProfile.OptionalArgs optionalArgs : params.optionalClassPath) + { + if(!optionalArgs.mark) continue; + LinkedList optionalClassPath = resolveClassPathList(params.clientDir, optionalArgs.args); + for (Path classpathURL : optionalClassPath) { + LauncherAgent.addJVMClassPath(classpathURL.toAbsolutePath().toString()); + } + } + URL[] classpathurls = resolveClassPath(params.clientDir, profile.getClassPath()); classLoader = new PublicURLClassLoader(classpathurls, ClassLoader.getSystemClassLoader()); Thread.currentThread().setContextClassLoader(classLoader); diff --git a/Launcher/src/main/java/ru/gravit/launcher/client/ClientModuleContext.java b/Launcher/src/main/java/ru/gravit/launcher/client/ClientModuleContext.java index f27eb037..2328565c 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/client/ClientModuleContext.java +++ b/Launcher/src/main/java/ru/gravit/launcher/client/ClientModuleContext.java @@ -3,6 +3,7 @@ import ru.gravit.launcher.Launcher; import ru.gravit.launcher.LauncherEngine; import ru.gravit.launcher.modules.ModuleContext; +import ru.gravit.launcher.modules.ModulesConfigManagerInterface; import ru.gravit.launcher.modules.ModulesManagerInterface; public class ClientModuleContext implements ModuleContext { @@ -21,4 +22,9 @@ public Type getType() { public ModulesManagerInterface getModulesManager() { return Launcher.modulesManager; } + + @Override + public ModulesConfigManagerInterface getModulesConfigManager() { + return null; // ClientModuleContext не поддерживает modulesConfigManager + } } diff --git a/Launcher/src/main/java/ru/gravit/launcher/client/ClientModuleManager.java b/Launcher/src/main/java/ru/gravit/launcher/client/ClientModuleManager.java index 80d7450b..f41cda42 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/client/ClientModuleManager.java +++ b/Launcher/src/main/java/ru/gravit/launcher/client/ClientModuleManager.java @@ -1,7 +1,7 @@ package ru.gravit.launcher.client; import ru.gravit.launcher.LauncherEngine; -import ru.gravit.launcher.modules.SimpleModuleManager; +import ru.gravit.launcher.managers.SimpleModuleManager; import java.net.URL; import java.util.ArrayList; diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/admin/ExecCommandRequest.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/admin/ExecCommandRequest.java new file mode 100644 index 00000000..2b4a0e01 --- /dev/null +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/admin/ExecCommandRequest.java @@ -0,0 +1,41 @@ +package ru.gravit.launcher.request.admin; + +import ru.gravit.launcher.request.Request; +import ru.gravit.launcher.request.RequestType; +import ru.gravit.launcher.serialize.HInput; +import ru.gravit.launcher.serialize.HOutput; +import ru.gravit.launcher.serialize.SerializeLimits; +import ru.gravit.utils.helper.LogHelper; + +public class ExecCommandRequest extends Request { + public LogHelper.Output loutput; + public String cmd; + + public ExecCommandRequest(LogHelper.Output output, String cmd) { + this.loutput = output; + this.cmd = cmd; + } + + @Override + public Integer getType() { + return RequestType.EXECCOMMAND.getNumber(); + } + + @Override + protected Boolean requestDo(HInput input, HOutput output) throws Exception { + readError(input); + output.writeString(cmd, SerializeLimits.MAX_COMMAND); + boolean isContinue = true; + while (isContinue) + { + isContinue = input.readBoolean(); + if(isContinue) + { + String log = input.readString(SerializeLimits.MAX_COMMAND); + if(loutput != null) loutput.println(log); + } + } + readError(input); + return true; + } +} diff --git a/ServerWrapper/src/main/java/ru/gravit/launcher/server/ModulesManager.java b/ServerWrapper/src/main/java/ru/gravit/launcher/server/ModulesManager.java index 30f90c70..f8702148 100644 --- a/ServerWrapper/src/main/java/ru/gravit/launcher/server/ModulesManager.java +++ b/ServerWrapper/src/main/java/ru/gravit/launcher/server/ModulesManager.java @@ -1,15 +1,19 @@ package ru.gravit.launcher.server; -import ru.gravit.launcher.modules.SimpleModuleManager; +import ru.gravit.launcher.managers.ModulesConfigManager; +import ru.gravit.launcher.managers.SimpleModuleManager; import ru.gravit.utils.PublicURLClassLoader; import java.net.URL; +import java.nio.file.Paths; import java.util.ArrayList; public class ModulesManager extends SimpleModuleManager { + public ModulesConfigManager modulesConfigManager; public ModulesManager(ServerWrapper wrapper) { modules = new ArrayList<>(); + modulesConfigManager = new ModulesConfigManager(Paths.get("modules-config")); classloader = new PublicURLClassLoader(new URL[0], ClassLoader.getSystemClassLoader()); - context = new ServerModuleContext(wrapper, classloader); + context = new ServerModuleContext(wrapper, classloader, modulesConfigManager); } } diff --git a/ServerWrapper/src/main/java/ru/gravit/launcher/server/ServerModuleContext.java b/ServerWrapper/src/main/java/ru/gravit/launcher/server/ServerModuleContext.java index a02d8856..93802a0d 100644 --- a/ServerWrapper/src/main/java/ru/gravit/launcher/server/ServerModuleContext.java +++ b/ServerWrapper/src/main/java/ru/gravit/launcher/server/ServerModuleContext.java @@ -1,17 +1,21 @@ package ru.gravit.launcher.server; import ru.gravit.launcher.Launcher; +import ru.gravit.launcher.managers.ModulesConfigManager; import ru.gravit.launcher.modules.ModuleContext; +import ru.gravit.launcher.modules.ModulesConfigManagerInterface; import ru.gravit.launcher.modules.ModulesManagerInterface; import ru.gravit.utils.PublicURLClassLoader; public class ServerModuleContext implements ModuleContext { public final PublicURLClassLoader classLoader; public final ServerWrapper wrapper; + public final ModulesConfigManager modulesConfigManager; - public ServerModuleContext(ServerWrapper wrapper, PublicURLClassLoader classLoader) { + public ServerModuleContext(ServerWrapper wrapper, PublicURLClassLoader classLoader, ModulesConfigManager modulesConfigManager) { this.classLoader = classLoader; this.wrapper = wrapper; + this.modulesConfigManager = modulesConfigManager; } @Override @@ -23,4 +27,9 @@ public Type getType() { public ModulesManagerInterface getModulesManager() { return Launcher.modulesManager; } + + @Override + public ModulesConfigManagerInterface getModulesConfigManager() { + return modulesConfigManager; + } } 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 f742962e..e9aad99d 100644 --- a/ServerWrapper/src/main/java/ru/gravit/launcher/server/ServerWrapper.java +++ b/ServerWrapper/src/main/java/ru/gravit/launcher/server/ServerWrapper.java @@ -9,10 +9,7 @@ import ru.gravit.launcher.request.auth.AuthServerRequest; import ru.gravit.launcher.request.update.ProfilesRequest; import ru.gravit.utils.PublicURLClassLoader; -import ru.gravit.utils.helper.CommonHelper; -import ru.gravit.utils.helper.IOHelper; -import ru.gravit.utils.helper.LogHelper; -import ru.gravit.utils.helper.SecurityHelper; +import ru.gravit.utils.helper.*; import java.io.*; import java.lang.invoke.MethodHandle; @@ -51,10 +48,14 @@ public static boolean auth(ServerWrapper wrapper) { break; } } - if(wrapper.profile == null) LogHelper.warning("Your profile not found"); + if(wrapper.profile == null) { + LogHelper.error("Your profile not found"); + if(ServerWrapper.config.stopOnError) System.exit(-1); + } return true; } catch (Throwable e) { LogHelper.error(e); + if(ServerWrapper.config.stopOnError) System.exit(-1); return false; } @@ -104,6 +105,7 @@ public static void main(String... args) throws Throwable { } LauncherConfig cfg = new LauncherConfig(config.address, config.port, SecurityHelper.toPublicRSAKey(IOHelper.read(publicKeyFile)), new HashMap<>(), config.projectname); Launcher.setConfig(cfg); + if(config.logFile != null) LogHelper.addOutput(IOHelper.newWriter(Paths.get(config.logFile),true)); if (config.syncAuth) auth(wrapper); else CommonHelper.newThread("Server Auth Thread", true, () -> ServerWrapper.loopAuth(wrapper, config.reconnectCount, config.reconnectSleep)); @@ -111,6 +113,7 @@ public static void main(String... args) throws Throwable { String classname = (config.mainclass == null || config.mainclass.isEmpty()) ? args[0] : config.mainclass; if (classname.length() == 0) { LogHelper.error("MainClass not found. Please set MainClass for ServerWrapper.cfg or first commandline argument"); + if(config.stopOnError) System.exit(-1); } Class mainClass; if (config.customClassPath) { @@ -165,6 +168,7 @@ private static void generateConfigIfNotExists() throws IOException { newConfig.password = "password"; newConfig.mainclass = ""; newConfig.syncAuth = true; + newConfig.stopOnError = true; newConfig.reconnectCount = 10; newConfig.reconnectSleep = 1000; //try(Reader reader = IOHelper.newReader(IOHelper.getResourceURL("ru/gravit/launcher/server/ServerWrapper.cfg"))) @@ -191,7 +195,9 @@ public static final class Config { public int reconnectSleep; public boolean customClassPath; public boolean autoloadLibraries; + public boolean stopOnError; public boolean syncAuth; + public String logFile; public String classpath; public String librariesDir; public String mainclass; diff --git a/libLauncher/src/main/java/ru/gravit/launcher/Launcher.java b/libLauncher/src/main/java/ru/gravit/launcher/Launcher.java index a721ad50..ec40c3a1 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/Launcher.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/Launcher.java @@ -60,9 +60,9 @@ public final class Launcher { private static final Pattern UUID_PATTERN = Pattern.compile("-", Pattern.LITERAL); public static final int MAJOR = 4; public static final int MINOR = 2; - public static final int PATCH = 0; - public static final int BUILD = 0; - public static final Version.Type RELEASE = Version.Type.EXPERIMENTAL; + public static final int PATCH = 1; + public static final int BUILD = 1; + public static final Version.Type RELEASE = Version.Type.STABLE; public static GsonBuilder gsonBuilder; public static Gson gson; diff --git a/libLauncher/src/main/java/ru/gravit/launcher/managers/ModulesConfigManager.java b/libLauncher/src/main/java/ru/gravit/launcher/managers/ModulesConfigManager.java new file mode 100644 index 00000000..80d55ab0 --- /dev/null +++ b/libLauncher/src/main/java/ru/gravit/launcher/managers/ModulesConfigManager.java @@ -0,0 +1,40 @@ +package ru.gravit.launcher.managers; + +import ru.gravit.launcher.modules.ModulesConfigManagerInterface; +import ru.gravit.utils.helper.IOHelper; +import ru.gravit.utils.helper.LogHelper; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; + +public class ModulesConfigManager implements ModulesConfigManagerInterface { + public Path configDir; + + public ModulesConfigManager(Path configDir) { + this.configDir = configDir; + } + + public Path getModuleConfig(String moduleName) + { + if(!IOHelper.isDir(configDir)) { + try { + Files.createDirectories(configDir); + } catch (IOException e) { + LogHelper.error(e); + } + } + return configDir.resolve(moduleName.concat("Config.json")); + } + public Path getModuleConfigDir(String moduleName) + { + if(!IOHelper.isDir(configDir)) { + try { + Files.createDirectories(configDir); + } catch (IOException e) { + LogHelper.error(e); + } + } + return configDir.resolve(moduleName); + } +} diff --git a/libLauncher/src/main/java/ru/gravit/launcher/modules/SimpleModuleManager.java b/libLauncher/src/main/java/ru/gravit/launcher/managers/SimpleModuleManager.java similarity index 96% rename from libLauncher/src/main/java/ru/gravit/launcher/modules/SimpleModuleManager.java rename to libLauncher/src/main/java/ru/gravit/launcher/managers/SimpleModuleManager.java index 91771546..40898330 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/modules/SimpleModuleManager.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/managers/SimpleModuleManager.java @@ -1,5 +1,8 @@ -package ru.gravit.launcher.modules; +package ru.gravit.launcher.managers; +import ru.gravit.launcher.modules.Module; +import ru.gravit.launcher.modules.ModuleContext; +import ru.gravit.launcher.modules.ModulesManagerInterface; import ru.gravit.utils.PublicURLClassLoader; import ru.gravit.utils.helper.IOHelper; import ru.gravit.utils.helper.LogHelper; diff --git a/libLauncher/src/main/java/ru/gravit/launcher/modules/ModuleContext.java b/libLauncher/src/main/java/ru/gravit/launcher/modules/ModuleContext.java index e35762f0..a79601bb 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/modules/ModuleContext.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/modules/ModuleContext.java @@ -8,4 +8,5 @@ enum Type { Type getType(); ModulesManagerInterface getModulesManager(); + ModulesConfigManagerInterface getModulesConfigManager(); } diff --git a/libLauncher/src/main/java/ru/gravit/launcher/modules/ModulesConfigManagerInterface.java b/libLauncher/src/main/java/ru/gravit/launcher/modules/ModulesConfigManagerInterface.java new file mode 100644 index 00000000..052857ac --- /dev/null +++ b/libLauncher/src/main/java/ru/gravit/launcher/modules/ModulesConfigManagerInterface.java @@ -0,0 +1,8 @@ +package ru.gravit.launcher.modules; + +import java.nio.file.Path; + +public interface ModulesConfigManagerInterface { + Path getModuleConfig(String moduleName); + Path getModuleConfigDir(String moduleName); +} 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 6f6c1945..93ab5517 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/profiles/ClientProfile.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/profiles/ClientProfile.java @@ -143,6 +143,18 @@ public int hashCode() { return Objects.hash(file); } } + public static class OptionalArgs + { + @LauncherAPI + public boolean mark; + @LauncherAPI + public String[] args; + + public OptionalArgs(String[] args, boolean mark) { + this.mark = mark; + this.args = args; + } + } // Updater and client watch service @LauncherAPI @@ -170,6 +182,12 @@ public int hashCode() { private final List clientArgs = new ArrayList<>(); @LauncherAPI private final List whitelist = new ArrayList<>(); + @LauncherAPI + private final List optionalJVMArgs = new ArrayList<>(); + @LauncherAPI + private final List optionalClientArgs = new ArrayList<>(); + @LauncherAPI + private final List optionalClassPath = new ArrayList<>(); @Override public int compareTo(ClientProfile o) { @@ -191,6 +209,19 @@ public String[] getClassPath() { return classPath.toArray(new String[0]); } + @LauncherAPI + public List getOptionalJVMArgs() { + return optionalJVMArgs; + } + @LauncherAPI + public List getOptionalClientArgs() { + return optionalClientArgs; + } + @LauncherAPI + public List getOptionalClassPath() { + return optionalClassPath; + } + @LauncherAPI public String[] getClientArgs() { return clientArgs.toArray(new String[0]); diff --git a/libLauncher/src/main/java/ru/gravit/launcher/request/RequestType.java b/libLauncher/src/main/java/ru/gravit/launcher/request/RequestType.java index 25571eab..74cecc0d 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/request/RequestType.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/request/RequestType.java @@ -11,7 +11,7 @@ public enum RequestType implements EnumSerializer.Itf { LEGACYLAUNCHER(1), UPDATE(2), UPDATE_LIST(3), // Update requests AUTH(4), JOIN_SERVER(5), CHECK_SERVER(6), // Auth requests PROFILE_BY_USERNAME(7), PROFILE_BY_UUID(8), BATCH_PROFILE_BY_USERNAME(9), // Profile requests - PROFILES(10), SERVERAUTH(11), SETPROFILE(12), LAUNCHER(13), CHANGESERVER(14), + PROFILES(10), SERVERAUTH(11), SETPROFILE(12), LAUNCHER(13), CHANGESERVER(14),EXECCOMMAND(15), CUSTOM(255); // Custom requests private static final EnumSerializer SERIALIZER = new EnumSerializer<>(RequestType.class); diff --git a/libLauncher/src/main/java/ru/gravit/launcher/serialize/SerializeLimits.java b/libLauncher/src/main/java/ru/gravit/launcher/serialize/SerializeLimits.java index d11f3a3f..f118eeec 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/serialize/SerializeLimits.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/serialize/SerializeLimits.java @@ -19,4 +19,6 @@ public class SerializeLimits { public static final int MAX_DIGEST = 512; @LauncherAPI public static final int MAX_HWID_STR = 1024; + @LauncherAPI + public static final int MAX_COMMAND = 2048; }