Merge branch 'dev' into tweak/forge-fix

This commit is contained in:
Zedifus 2024-01-16 18:02:57 +00:00
commit 12bb29ac2d
2 changed files with 22 additions and 20 deletions

View File

@ -3,7 +3,7 @@
### New features
TBD
### Bug fixes
TBD
- Fix bukkit and downstream fork MOTD crash ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/686))
### Tweaks
TBD
### Lang

View File

@ -12,6 +12,7 @@ from app.classes.minecraft.bedrock_ping import BedrockPing
from app.classes.shared.console import Console
logger = logging.getLogger(__name__)
MOTD_CODES = ["bold", "italic", "underlined", "strikethrough"]
class Server:
@ -34,26 +35,27 @@ class Server:
lines = []
description = self.description
if "text" in description.keys():
lines.append(description["text"])
if "extra" in description.keys():
for e in description["extra"]:
# Conversion format code needed only for Java Version
lines.append(get_code_format("reset"))
if "bold" in e.keys():
lines.append(get_code_format("bold"))
if "italic" in e.keys():
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():
lines.append(get_code_format(e["color"]))
# Then append the text
if "text" in e.keys():
if e["text"] == "\n":
lines.append("§§")
else:
lines.append(e["text"])
if isinstance(description["extra"], list):
for e in description["extra"]:
if not isinstance(e, dict):
lines.append(e)
continue
# Conversion format code needed only for Java Version
lines.append(get_code_format("reset"))
for item in MOTD_CODES:
if e.get(item, False):
lines.append(get_code_format(item))
if "color" in e.keys():
lines.append(get_code_format(e["color"]))
# Then append the text
if "text" in e.keys():
if e["text"] == "\n":
lines.append("§§")
else:
lines.append(e["text"])
total_text = " ".join(lines)
self.description = total_text