dolor.servers.server

connection_task(func)[source]

Decorator for connection tasks within a class.

class ServerConnection(server, reader, writer)[source]

Bases: dolor.connection.Connection

property is_player
async disconnect(reason)[source]
async set_compression(threshold)[source]
async login_success()[source]
async message(message, *, position=ChatPosition.Chat, sender=None)[source]
close()[source]

Closes the connection.

Should be used alongside the wait_closed() method.

async wait_closed()[source]

Waits until the connection is closed.

create_task(coro)[source]

Internal function used to ensure that all listeners complete.

async write_packet(*args, **kwargs)[source]

Writes a packet.

Parameters
  • packet (subclass of Packet or Packet) –

    If a subclass of Packet, then the packet to write will be created by forwarding packet and **kwargs to the create_packet() method. Otherwise, packet is the packet to write.

    packet being a subclass of Packet is preferred so that the packet is created with the correct context for the connection.

  • **kwargs – The packet attributes to set and their corresponding values. Only able to be passed if packet is a subclass of Packet.

Returns

The written packet.

Return type

Packet

Raises

TypeError – If **kwargs is passed but packet isn’t a subclass of Packet.

class Server(version, address, port=25565, *, lang_file=None, max_players=20, description=None, favicon=None, offline=False, comp_enabled=True, comp_threshold=256)[source]

Bases: dolor.packet_handler.PacketHandler

session_server = 'https://sessionserver.mojang.com/session/minecraft'
Connection

alias of dolor.servers.server.ServerConnection

register_connection_task(func)[source]

Registers a packet listener.

func is a coroutine function.

unregister_connection_task(func)[source]

Unregisters a connection task.

external_connection_task(func)[source]

Decorator for external connection tasks.

register_intrinsic_connection_tasks()[source]
safe_connection_func(task)[source]
register_packet_listener(*args, outgoing=False)[source]

Registers a packet listener.

Parameters
  • func (coroutine function) – The packet listener.

  • *checkers (subclass of Packet or int or function) –

    If a subclass of Packet, then the listener will be called if the packet is an instance of that class.

    If an int, then the listener will be called if the id of the packet is equal to the passed int.

    If a function, then the function can either return a bool and take one argument, which represents the packet to check, or it can return a bool and take two arguments, the first being the relevant Connection, and the second being the packet to check.

  • **kwargs – Keyword arguments that must match the keyword arguments passed to listeners_for_packet() for the packet listener to be included in its return.

Raises
  • TypeError – If func isn’t a coroutine function.

  • ValueError – If no checkers are specified.

async listen_to_packet(c, p, *, outgoing)[source]
async listen(c)[source]
async new_connection(reader, writer)[source]
async central_connection_task(c)[source]
async main_task()[source]
is_serving()[source]
close()[source]
async wait_closed()[source]
append(conn)[source]
remove(conn)[source]
async startup()[source]
async on_start()[source]
async start()[source]
run()[source]
property players
async send_server_hash(c, server_hash)[source]