|
7 | 7 | from base64 import b64decode |
8 | 8 | from PIL import Image, ImageTk |
9 | 9 | from queue import Queue, Empty |
10 | | -from mcstatus import JavaServer |
11 | 10 | from threading import Thread, Lock |
12 | | -from mcstatus.pinger import ServerPinger |
13 | | -from mcstatus.protocol.connection import TCPSocketConnection |
| 11 | + |
| 12 | + |
| 13 | +def import_big_library(): |
| 14 | + from mcstatus.address import Address |
| 15 | + from mcstatus.pinger import ServerPinger |
| 16 | + from mcstatus.protocol.connection import TCPSocketConnection |
| 17 | + globals()["Address"] = Address |
| 18 | + globals()["ServerPinger"] = ServerPinger |
| 19 | + globals()["TCPSocketConnection"] = TCPSocketConnection |
| 20 | + |
| 21 | + |
| 22 | +Thread(target=import_big_library).start() |
14 | 23 |
|
15 | 24 |
|
16 | 25 | class ServerScanner: |
@@ -148,12 +157,10 @@ def get_server_info(self) -> dict: |
148 | 157 | 获取服务器在`#Status_Response`包中的返回JSON |
149 | 158 | https://wiki.vg/Server_List_Ping#Status_Response |
150 | 159 | """ |
151 | | - server = JavaServer(self.host, self.port, self.timeout) |
152 | | - |
153 | 160 | info = {"host": self.host, "port": self.port} |
154 | 161 | try: |
155 | | - with TCPSocketConnection(server.address, server.timeout) as connection: |
156 | | - pinger = ServerPinger(connection, address=server.address) |
| 162 | + with TCPSocketConnection((self.host, self.port), self.timeout) as connection: |
| 163 | + pinger = ServerPinger(connection, address=Address(self.host, self.port)) |
157 | 164 | pinger.handshake() |
158 | 165 | info_data = pinger.read_status() |
159 | 166 | ping_time = pinger.test_ping() |
|
0 commit comments