mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Merge branch 'dev' into bug/server-config-save
This commit is contained in:
commit
6c2a63f1e8
@ -12,6 +12,7 @@ TBD
|
|||||||
- Fix root dir selection in Upload Zip Import ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/508))
|
- Fix root dir selection in Upload Zip Import ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/508))
|
||||||
- Fix stats error on mac M1 chips ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/512))
|
- Fix stats error on mac M1 chips ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/512))
|
||||||
- Fix window path escape on java override ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/513))
|
- Fix window path escape on java override ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/513))
|
||||||
|
- Fix Forge import stalling on 1.17 Forge servers ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/515))
|
||||||
### Tweaks
|
### Tweaks
|
||||||
- Make server directories non-configurable ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/511))
|
- Make server directories non-configurable ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/511))
|
||||||
- Add popover to server port to detail it's purpose ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/514))
|
- Add popover to server port to detail it's purpose ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/514))
|
||||||
|
@ -192,7 +192,7 @@ class ServerJars:
|
|||||||
with open(path, "wb") as output:
|
with open(path, "wb") as output:
|
||||||
shutil.copyfileobj(r.raw, output)
|
shutil.copyfileobj(r.raw, output)
|
||||||
# If this is the newer forge version we will run the installer
|
# If this is the newer forge version we will run the installer
|
||||||
if server == "forge" and int(version.split(".")[1]) > 15:
|
if server == "forge":
|
||||||
ServersController.finish_import(server_id, True)
|
ServersController.finish_import(server_id, True)
|
||||||
else:
|
else:
|
||||||
ServersController.finish_import(server_id)
|
ServersController.finish_import(server_id)
|
||||||
|
@ -10,6 +10,7 @@ import logging.config
|
|||||||
import subprocess
|
import subprocess
|
||||||
import html
|
import html
|
||||||
import urllib.request
|
import urllib.request
|
||||||
|
import glob
|
||||||
|
|
||||||
# TZLocal is set as a hidden import on win pipeline
|
# TZLocal is set as a hidden import on win pipeline
|
||||||
from tzlocal import get_localzone
|
from tzlocal import get_localzone
|
||||||
@ -580,54 +581,105 @@ class ServerInstance:
|
|||||||
# Process has exited. Lets do some work to setup the new
|
# Process has exited. Lets do some work to setup the new
|
||||||
# run command.
|
# run command.
|
||||||
# Let's grab the server object we're going to update.
|
# Let's grab the server object we're going to update.
|
||||||
server_obj = HelperServers.get_server_obj(self.server_id)
|
server_obj: Servers = HelperServers.get_server_obj(self.server_id)
|
||||||
|
|
||||||
# The forge install is done so we can delete that install file.
|
# The forge install is done so we can delete that install file.
|
||||||
os.remove(os.path.join(server_obj.path, server_obj.executable))
|
os.remove(os.path.join(server_obj.path, server_obj.executable))
|
||||||
|
|
||||||
# We need to grab the exact forge version number.
|
# We need to grab the exact forge version number.
|
||||||
# We know we can find it here in the run.sh/bat script.
|
# We know we can find it here in the run.sh/bat script.
|
||||||
run_file_path = ""
|
try:
|
||||||
if self.helper.is_os_windows():
|
|
||||||
run_file_path = os.path.join(server_obj.path, "run.bat")
|
|
||||||
else:
|
|
||||||
run_file_path = os.path.join(server_obj.path, "run.sh")
|
|
||||||
|
|
||||||
if Helpers.check_file_perms(run_file_path) and os.path.isfile(
|
# Getting the forge version from the executable command
|
||||||
run_file_path
|
version = re.findall(
|
||||||
):
|
r"forge-([0-9\.]+)((?:)|(?:-([0-9\.]+)-[a-zA-Z]+)).jar",
|
||||||
run_file = open(run_file_path, "r", encoding="utf-8")
|
server_obj.execution_command,
|
||||||
run_file_text = run_file.read()
|
|
||||||
else:
|
|
||||||
Console.error(
|
|
||||||
"ERROR ! Forge install can't read the scripts files."
|
|
||||||
" Aborting ..."
|
|
||||||
)
|
)
|
||||||
return
|
version_param = version[0][0].split(".")
|
||||||
|
version_major = int(version_param[0])
|
||||||
|
version_minor = int(version_param[1])
|
||||||
|
|
||||||
# We get the server command parameters from forge script
|
# Checking which version we are with
|
||||||
server_command = re.findall(
|
if version_major <= 1 and version_minor < 17:
|
||||||
r"java @([a-zA-Z0-9_\.]+)"
|
# OLD VERSION < 1.17
|
||||||
r" @([a-z.\/\-]+)([0-9.\-]+)\/\b([a-z_0-9]+\.txt)\b( .{2,4})?",
|
|
||||||
run_file_text,
|
|
||||||
)[0]
|
|
||||||
|
|
||||||
version = server_command[2]
|
# Retrieving the executable jar filename
|
||||||
executable_path = f"{server_command[1]}{server_command[2]}/"
|
file_path = glob.glob(
|
||||||
|
f"{server_obj.path}/forge-{version[0][0]}*.jar"
|
||||||
|
)[0]
|
||||||
|
file_name = re.findall(
|
||||||
|
r"(forge[-0-9.]+.jar)",
|
||||||
|
file_path,
|
||||||
|
)[0]
|
||||||
|
|
||||||
# Let's set the proper server executable
|
# Let's set the proper server executable
|
||||||
server_obj.executable = os.path.join(
|
server_obj.executable = os.path.join(file_name)
|
||||||
f"{executable_path}forge-{version}-server.jar"
|
|
||||||
)
|
# Get memory values
|
||||||
# Now lets set up the new run command.
|
memory_values = re.findall(
|
||||||
# This is based off the run.sh/bat that
|
r"-Xms([A-Z0-9\.]+) -Xmx([A-Z0-9\.]+)",
|
||||||
# Forge uses in 1.16 and <
|
server_obj.execution_command,
|
||||||
execution_command = (
|
)
|
||||||
f"java @{server_command[0]}"
|
|
||||||
f" @{executable_path}{server_command[3]} nogui {server_command[4]}"
|
# Now lets set up the new run command.
|
||||||
)
|
# This is based off the run.sh/bat that
|
||||||
server_obj.execution_command = execution_command
|
# Forge uses in 1.17 and <
|
||||||
Console.debug("SUCCESS! Forge install completed")
|
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")
|
||||||
|
|
||||||
|
else:
|
||||||
|
# NEW VERSION >= 1.17
|
||||||
|
|
||||||
|
run_file_path = ""
|
||||||
|
if self.helper.is_os_windows():
|
||||||
|
run_file_path = os.path.join(server_obj.path, "run.bat")
|
||||||
|
else:
|
||||||
|
run_file_path = os.path.join(server_obj.path, "run.sh")
|
||||||
|
|
||||||
|
if Helpers.check_file_perms(run_file_path) and os.path.isfile(
|
||||||
|
run_file_path
|
||||||
|
):
|
||||||
|
run_file = open(run_file_path, "r", encoding="utf-8")
|
||||||
|
run_file_text = run_file.read()
|
||||||
|
else:
|
||||||
|
Console.error(
|
||||||
|
"ERROR ! Forge install can't read the scripts files."
|
||||||
|
" Aborting ..."
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
|
# We get the server command parameters from forge script
|
||||||
|
server_command = re.findall(
|
||||||
|
r"java @([a-zA-Z0-9_\.]+)"
|
||||||
|
r" @([a-z.\/\-]+)([0-9.\-]+)"
|
||||||
|
r"\/\b([a-z_0-9]+\.txt)\b( .{2,4})?",
|
||||||
|
run_file_text,
|
||||||
|
)[0]
|
||||||
|
|
||||||
|
version = server_command[2]
|
||||||
|
executable_path = f"{server_command[1]}{server_command[2]}/"
|
||||||
|
|
||||||
|
# Let's set the proper server executable
|
||||||
|
server_obj.executable = os.path.join(
|
||||||
|
f"{executable_path}forge-{version}-server.jar"
|
||||||
|
)
|
||||||
|
# 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 @{server_command[0]}"
|
||||||
|
f" @{executable_path}{server_command[3]} nogui"
|
||||||
|
" {server_command[4]}"
|
||||||
|
)
|
||||||
|
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
|
||||||
|
|
||||||
# We'll update the server with the new information now.
|
# We'll update the server with the new information now.
|
||||||
HelperServers.update_server(server_obj)
|
HelperServers.update_server(server_obj)
|
||||||
|
Loading…
Reference in New Issue
Block a user