Fixing issues for forge installation for versions >= 1.20

This commit is contained in:
Silversthorn 2024-01-03 21:10:33 +01:00
parent 1d32afa09d
commit dc09f47871

View File

@ -725,8 +725,9 @@ class ServerInstance:
server_obj.execution_command = execution_command server_obj.execution_command = execution_command
Console.debug("SUCCESS! Forge install completed") Console.debug("SUCCESS! Forge install completed")
else: elif version_major <= 1 and version_minor < 20:
# NEW VERSION >= 1.17 # NEW VERSION >= 1.17 and <= 1.20
# (no jar file in server dir, only run.bat and run.sh)
run_file_path = "" run_file_path = ""
if self.helper.is_os_windows(): if self.helper.is_os_windows():
@ -771,6 +772,37 @@ class ServerInstance:
) )
server_obj.execution_command = execution_command server_obj.execution_command = execution_command
Console.debug("SUCCESS! Forge install completed") 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: except:
logger.debug("Could not find run file.") logger.debug("Could not find run file.")
# TODO Use regex to get version and rebuild simple execution # TODO Use regex to get version and rebuild simple execution