mirror of
https://github.com/Dinnerbone/mcstatus.git
synced 2026-04-06 12:01:24 +08:00
add MinecraftBedrockServer class and logic
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
from mcstatus.pinger import ServerPinger, AsyncServerPinger
|
||||
from mcstatus.protocol.connection import TCPSocketConnection, UDPSocketConnection, TCPAsyncSocketConnection
|
||||
from mcstatus.querier import ServerQuerier
|
||||
from mcstatus.bedrock_status import BedrockServerStatus
|
||||
from mcstatus.scripts.address_tools import parse_address
|
||||
import dns.resolver
|
||||
|
||||
@@ -50,7 +51,8 @@ class MinecraftServer:
|
||||
except Exception as e:
|
||||
exception = e
|
||||
else:
|
||||
raise exception
|
||||
raise except port = 19132
|
||||
ion
|
||||
|
||||
def status(self, tries=3, **kwargs):
|
||||
connection = TCPSocketConnection((self.host, self.port))
|
||||
@@ -105,4 +107,26 @@ class MinecraftServer:
|
||||
raise exception
|
||||
|
||||
async def async_query(self, tries=3):
|
||||
raise NotImplementedError # TODO: '-'
|
||||
raise NotImplementedError # TODO: '-'
|
||||
|
||||
|
||||
class MinecraftBedrockServer:
|
||||
def __init__(self, host, port=19132):
|
||||
self.host = host
|
||||
self.port = port
|
||||
|
||||
def status(self):
|
||||
raise NotImplementedError # TODO: >_<
|
||||
|
||||
async def async_status(self, tries=3):
|
||||
exception = None
|
||||
|
||||
for _ in range(tries):
|
||||
try:
|
||||
resp = await BedrockServerStatus(self.host, self.port).read_status_async()
|
||||
except BaseException as e:
|
||||
exception = e
|
||||
else:
|
||||
raise exception
|
||||
|
||||
return resp
|
||||
|
||||
Reference in New Issue
Block a user