This repository was archived by the owner on May 12, 2024. It is now read-only.
forked from ZockerSK/FakeMCServer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
63 lines (51 loc) · 2.08 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env python3
import base64
import json
import os.path
from socket_server import SocketServer
server = None
def main():
if os.path.exists("config.json"):
with open("config.json", 'r') as file:
configuration = json.load(file)
ip = configuration["ip"]
port = configuration["port"]
motd = configuration["motd"]["1"] + "\n" + configuration["motd"]["2"]
version_text = configuration["version_text"]
kick_message = ""
server_icon = None
for message in configuration["kick_message"]:
kick_message += message + "\n"
kick_message = kick_message[:-2]
if not os.path.exists(configuration["server_icon"]):
print("Server icon doesn't exists - submitting none...")
else:
with open(configuration["server_icon"], 'rb') as image:
server_icon = "data:image/png;base64," + base64.b64encode(image.read()).decode()
try:
global server
server = SocketServer(ip, port, motd, version_text, kick_message, server_icon)
server.start()
except KeyboardInterrupt:
server.close()
exit(1)
except Exception as e:
print(e)
else:
configuration = {}
configuration["ip"] = "0.0.0.0"
configuration["port"] = 25565
configuration["motd"] = {}
configuration["motd"]["1"] = "§4Maintenance!"
configuration["motd"]["2"] = "§aCheck example.com for more information!"
configuration["version_text"] = "§4Maintenance"
configuration["kick_message"] = ["§bSorry", "", "§aThis server is offline!"]
configuration["server_icon"] = "server_icon.png"
configuration["samples"] = ["§bexample.com", "", "§4Maintenance"]
with open("config.json", 'w') as file:
json.dump(configuration, file, sort_keys=True, indent=4, ensure_ascii=False)
print("[!] A new configuration was created!")
print("Please check the settings in the config.json!")
exit(1)
if __name__ == '__main__':
main()