mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Check type in extra so we don't iterate thru str
This commit is contained in:
parent
a67f53a4c9
commit
60ac3bf630
@ -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:
|
||||
@ -37,20 +38,16 @@ class Server:
|
||||
if "text" in description.keys():
|
||||
lines.append(description["text"])
|
||||
if "extra" in description.keys():
|
||||
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"))
|
||||
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"))
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user