From dc09f478715a58a5fda01652ccc29f320ee737c4 Mon Sep 17 00:00:00 2001 From: Silversthorn Date: Wed, 3 Jan 2024 21:10:33 +0100 Subject: [PATCH 1/2] Fixing issues for forge installation for versions >= 1.20 --- app/classes/shared/server.py | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/app/classes/shared/server.py b/app/classes/shared/server.py index 8448f656..035824c5 100644 --- a/app/classes/shared/server.py +++ b/app/classes/shared/server.py @@ -725,8 +725,9 @@ class ServerInstance: server_obj.execution_command = execution_command Console.debug("SUCCESS! Forge install completed") - else: - # NEW VERSION >= 1.17 + elif version_major <= 1 and version_minor < 20: + # NEW VERSION >= 1.17 and <= 1.20 + # (no jar file in server dir, only run.bat and run.sh) run_file_path = "" if self.helper.is_os_windows(): @@ -771,6 +772,37 @@ class ServerInstance: ) server_obj.execution_command = execution_command Console.debug("SUCCESS! Forge install completed") + else: + # NEW VERSION >= 1.20 + # (executable jar is back in server dir) + + # Retrieving the executable jar filename + file_path = glob.glob( + f"{server_obj.path}/forge-{version[0][0]}*.jar" + )[0] + file_name = re.findall( + r"(forge-[\-0-9.]+-shim.jar)", + file_path, + )[0] + + # Let's set the proper server executable + server_obj.executable = os.path.join(file_name) + + # Get memory values + memory_values = re.findall( + r"-Xms([A-Z0-9\.]+) -Xmx([A-Z0-9\.]+)", + server_obj.execution_command, + ) + + # Now lets set up the new run command. + # This is based off the run.sh/bat that + # Forge uses in 1.17 and < + execution_command = ( + f"java -Xms{memory_values[0][0]} -Xmx{memory_values[0][1]}" + f' -jar "{file_name}" nogui' + ) + server_obj.execution_command = execution_command + Console.debug("SUCCESS! Forge install completed") except: logger.debug("Could not find run file.") # TODO Use regex to get version and rebuild simple execution From b76636ed994accfba69b0e4fffd8650417b090ee Mon Sep 17 00:00:00 2001 From: Zedifus Date: Tue, 16 Jan 2024 18:04:59 +0000 Subject: [PATCH 2/2] Update changelog !687 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a2c3c9e5..6e94d0db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ TBD ### Bug fixes - Fix bukkit and downstream fork MOTD crash ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/686)) ### Tweaks -TBD +- Refactor Forge server initialisation flow for newer versions ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/687)) ### Lang TBD