From 71180e59feda93c39dacfc39be6aa989d44ab01d Mon Sep 17 00:00:00 2001
From: RaphiMC <50594595+RaphiMC@users.noreply.github.com>
Date: Thu, 12 Sep 2024 21:08:03 +0200
Subject: [PATCH] Added CLI option to list supported server versions

---
 .../protocoltranslator/viaproxy/ViaProxyConfig.java       | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/main/java/net/raphimc/viaproxy/protocoltranslator/viaproxy/ViaProxyConfig.java b/src/main/java/net/raphimc/viaproxy/protocoltranslator/viaproxy/ViaProxyConfig.java
index 7d86753..4a3873c 100644
--- a/src/main/java/net/raphimc/viaproxy/protocoltranslator/viaproxy/ViaProxyConfig.java
+++ b/src/main/java/net/raphimc/viaproxy/protocoltranslator/viaproxy/ViaProxyConfig.java
@@ -186,6 +186,7 @@ public class ViaProxyConfig {
     public void loadFromArguments(final String[] args) throws Exception {
         final OptionParser optionParser = new OptionParser();
         final OptionSpec<Void> optionHelp = optionParser.accepts("help").forHelp();
+        final OptionSpec<Void> optionListVersions = optionParser.accepts("list-versions", "Lists all supported server/target versions").forHelp();
 
         final Map<OptionSpec<Object>, ConfigOption> optionMap = new HashMap<>();
         final Stack<SectionIndex> stack = new Stack<>();
@@ -212,6 +213,13 @@ public class ViaProxyConfig {
             final OptionSet options = optionParser.parse(args);
             if (options.has(optionHelp)) {
                 throw new HelpRequestedException();
+            } else if (options.has(optionListVersions)) {
+                Logger.LOGGER.info("=== Supported Server Versions ===");
+                for (ProtocolVersion version : ProtocolVersion.getProtocols()) {
+                    Logger.LOGGER.info(version.getName());
+                }
+                Logger.LOGGER.info("===================================");
+                System.exit(0);
             }
 
             if (options.has("minecraft-account-index")) {