From a27d7f1597bac6b482d310f41c1941bbc79ed5b2 Mon Sep 17 00:00:00 2001 From: Gravita Date: Thu, 22 Dec 2022 19:07:46 +0700 Subject: [PATCH] [FEATURE] printExperimentalBranch --- .../launchserver/LaunchServerStarter.java | 20 +++++++++++++++++++ .../main/resources/experimental-build.json | 3 +++ 2 files changed, 23 insertions(+) create mode 100644 LaunchServer/src/main/resources/experimental-build.json diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServerStarter.java b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServerStarter.java index 59890706..5e058486 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServerStarter.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServerStarter.java @@ -21,6 +21,7 @@ import pro.gravit.launchserver.manangers.LaunchServerGsonManager; import pro.gravit.launchserver.modules.impl.LaunchServerModulesManager; import pro.gravit.launchserver.socket.WebSocketService; +import pro.gravit.utils.Version; import pro.gravit.utils.command.CommandHandler; import pro.gravit.utils.command.JLineCommandHandler; import pro.gravit.utils.command.StdCommandHandler; @@ -33,6 +34,7 @@ import java.nio.file.Path; import java.security.Security; import java.security.cert.CertificateException; +import java.util.List; public class LaunchServerStarter { public static final boolean allowUnsigned = Boolean.getBoolean("launchserver.allowUnsigned"); @@ -86,6 +88,7 @@ public static void main(String[] args) throws Exception { modulesManager.initModules(null); registerAll(); initGson(modulesManager); + printExperimentalBranch(); if (IOHelper.exists(dir.resolve("LaunchServer.conf"))) { configFile = dir.resolve("LaunchServer.conf"); } else { @@ -213,6 +216,23 @@ public static void registerAll() { OptionalTrigger.registerProviders(); } + private static void printExperimentalBranch() { + try(Reader reader = IOHelper.newReader(IOHelper.getResourceURL("experimental-build.json"))) { + ExperimentalBuild info = Launcher.gsonManager.configGson.fromJson(reader, ExperimentalBuild.class); + if(info.features == null || info.features.isEmpty()) { + return; + } + logger.warn("This is experimental build. Please do not use this in production"); + logger.warn("Experimental features: [{}]", String.join(",", info.features)); + } catch (Throwable e) { + logger.warn("Build information not found"); + } + } + + record ExperimentalBuild(List features) { + + } + public static void generateConfigIfNotExists(Path configFile, CommandHandler commandHandler, LaunchServer.LaunchServerEnv env) throws IOException { if (IOHelper.isFile(configFile)) return; diff --git a/LaunchServer/src/main/resources/experimental-build.json b/LaunchServer/src/main/resources/experimental-build.json new file mode 100644 index 00000000..6f281e40 --- /dev/null +++ b/LaunchServer/src/main/resources/experimental-build.json @@ -0,0 +1,3 @@ +{ + "features": [] +} \ No newline at end of file