diff --git a/CHANGELOG.md b/CHANGELOG.md index 71b8b4b6..a2c3c9e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/app/classes/minecraft/mc_ping.py b/app/classes/minecraft/mc_ping.py index c5cb9916..72a91351 100644 --- a/app/classes/minecraft/mc_ping.py +++ b/app/classes/minecraft/mc_ping.py @@ -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