mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Merge branch 'dev' into feature/paper-builds
This commit is contained in:
commit
01a7c2e238
@ -3,9 +3,9 @@
|
|||||||
### New features
|
### New features
|
||||||
TBD
|
TBD
|
||||||
### Bug fixes
|
### Bug fixes
|
||||||
TBD
|
- Fix bukkit and downstream fork MOTD crash ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/686))
|
||||||
### Tweaks
|
### Tweaks
|
||||||
TBD
|
- Refactor Forge server initialisation flow for newer versions ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/687))
|
||||||
### Lang
|
### Lang
|
||||||
TBD
|
TBD
|
||||||
<br><br>
|
<br><br>
|
||||||
|
@ -12,6 +12,7 @@ from app.classes.minecraft.bedrock_ping import BedrockPing
|
|||||||
from app.classes.shared.console import Console
|
from app.classes.shared.console import Console
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
MOTD_CODES = ["bold", "italic", "underlined", "strikethrough"]
|
||||||
|
|
||||||
|
|
||||||
class Server:
|
class Server:
|
||||||
@ -34,18 +35,19 @@ class Server:
|
|||||||
lines = []
|
lines = []
|
||||||
|
|
||||||
description = self.description
|
description = self.description
|
||||||
|
if "text" in description.keys():
|
||||||
|
lines.append(description["text"])
|
||||||
if "extra" in description.keys():
|
if "extra" in description.keys():
|
||||||
|
if isinstance(description["extra"], list):
|
||||||
for e in description["extra"]:
|
for e in description["extra"]:
|
||||||
|
if not isinstance(e, dict):
|
||||||
|
lines.append(e)
|
||||||
|
continue
|
||||||
# Conversion format code needed only for Java Version
|
# Conversion format code needed only for Java Version
|
||||||
lines.append(get_code_format("reset"))
|
lines.append(get_code_format("reset"))
|
||||||
if "bold" in e.keys():
|
for item in MOTD_CODES:
|
||||||
lines.append(get_code_format("bold"))
|
if e.get(item, False):
|
||||||
if "italic" in e.keys():
|
lines.append(get_code_format(item))
|
||||||
lines.append(get_code_format("italic"))
|
|
||||||
if "underlined" in e.keys():
|
|
||||||
lines.append(get_code_format("underlined"))
|
|
||||||
if "strikethrough" in e.keys():
|
|
||||||
lines.append(get_code_format("strikethrough"))
|
|
||||||
if "color" in e.keys():
|
if "color" in e.keys():
|
||||||
lines.append(get_code_format(e["color"]))
|
lines.append(get_code_format(e["color"]))
|
||||||
# Then append the text
|
# Then append the text
|
||||||
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user