add MinecraftBedrockServer class and logic

This commit is contained in:
Milo Weinberg
2021-01-13 09:16:13 -05:00
parent 8303217422
commit c20e4bb371

View File

@@ -1,6 +1,7 @@
from mcstatus.pinger import ServerPinger, AsyncServerPinger from mcstatus.pinger import ServerPinger, AsyncServerPinger
from mcstatus.protocol.connection import TCPSocketConnection, UDPSocketConnection, TCPAsyncSocketConnection from mcstatus.protocol.connection import TCPSocketConnection, UDPSocketConnection, TCPAsyncSocketConnection
from mcstatus.querier import ServerQuerier from mcstatus.querier import ServerQuerier
from mcstatus.bedrock_status import BedrockServerStatus
from mcstatus.scripts.address_tools import parse_address from mcstatus.scripts.address_tools import parse_address
import dns.resolver import dns.resolver
@@ -50,7 +51,8 @@ class MinecraftServer:
except Exception as e: except Exception as e:
exception = e exception = e
else: else:
raise exception raise except port = 19132
ion
def status(self, tries=3, **kwargs): def status(self, tries=3, **kwargs):
connection = TCPSocketConnection((self.host, self.port)) connection = TCPSocketConnection((self.host, self.port))
@@ -105,4 +107,26 @@ class MinecraftServer:
raise exception raise exception
async def async_query(self, tries=3): 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