Skip to content

Commit

Permalink
Fixed a issue with color
Browse files Browse the repository at this point in the history
  • Loading branch information
Thorinwasher committed Mar 29, 2021
1 parent 7db9311 commit 190c970
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
12 changes: 6 additions & 6 deletions config.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
Content:
hoverMessage: |-
§7[§f§lPhantom§7]
§bThis is some example text
§3It can be five lines long.
§3I think at least.
&7[&f&lPhantom&7]
&bThis is some example text
&3It can be five lines long.
&3I think at least.
# What text is sent to users who try to connect to the server?
imagePath: Logo.png
kickMessage: |-
§7[§f§lPhantom§7]
§4Players who connect will be
§4kicked with §cthis message§4!
lowerMessage: |-
§8[§7§lPhantom§8]
§f§oThis server is just a broadcast!
&8[&7&lPhantom&8]
&f&oThis server is just a broadcast!
upperMessage: This msg appears above the server!
Style: 1
configVersion: 1
Expand Down
12 changes: 7 additions & 5 deletions phantom.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
@author: Thorin
Version 0.3.0
Version 0.5.1
"""
import socket
import json
Expand Down Expand Up @@ -72,7 +72,7 @@ def JSON_Response(protocol_version):
virtual_players = []
print(virtual_Playernames)
for playername in virtual_Playernames:
playerDict = {"name":playername,"id": "4566e69f-c907-48ee-8d71-d7ba5aa00d20"}
playerDict = {"name":fix_coloring(playername),"id": "4566e69f-c907-48ee-8d71-d7ba5aa00d20"}
virtual_players.append(playerDict)

max_players = 0
Expand All @@ -83,14 +83,14 @@ def JSON_Response(protocol_version):

JSON = {
"version" : {
"name":Content["upperMessage"],
"name":fix_coloring(Content["upperMessage"]),
"protocol":protocol_version
},
"players": {
"max": max_players,
"online": 0,
"sample" : virtual_players},
"description": Content["lowerMessage"],
"description": fix_coloring(Content["lowerMessage"]),
"favicon": "data:image/png;base64" + base64_message
}
return JSON
Expand All @@ -101,7 +101,9 @@ def JSON_Response(protocol_version):
port=25565
timeout=5


def fix_coloring(text):
#TODO add a \& option
return re.sub("&", "§", text)

def read_handshake(conn):
packet_length = unpack_varint(conn);
Expand Down

0 comments on commit 190c970

Please sign in to comment.