Server Handler

class mcdreforged.handler.abstract_server_handler.AbstractServerHandler[source]

The abstract base class for server handler

Class inheriting tree:

AbstractServerHandler
├── BasicHandler
├── AbstractMinecraftHandler
│   ├── VanillaHandler
│   │   ├── Beta18Handler
│   │   └── ForgeHandler
│   └── BukkitHandler
│       ├── Bukkit14Handler
│       ├── CatServerHandler
│       └── ArclightHandler
├── BungeecordHandler
│   └── WaterfallHandler
└── VelocityHandler
get_name() str[source]

The name of the server handler

The name is used as the identifier of this server handler in MCDR configuration

get_stop_command() str[source]

The command to stop the server

get_send_message_command(target: str, message: str | RTextBase, server_information: ServerInformation) str | None[source]

The command to send a message to a target

get_broadcast_message_command(message: str | RTextBase, server_information: ServerInformation) str | None[source]

The command to broadcast a message in the server

pre_parse_server_stdout(text: str) str[source]

A parsing preprocessor. Invoked before any parsing operation

Remove useless / annoying things like control characters in the text before parsing

Parameters:

text – A line of the server stdout to be parsed

classmethod parse_console_command(text: str) Info[source]

Parse console input

Parameters:

text – A line of console input to be parsed

Returns:

An Info object as the result

classmethod _get_server_stdout_raw_result(text: str) Info[source]

This method does a raw parsing and returns an almost un-parsed Info object

Use as the first step of the parsing process, or as the parsing result if you give up parsing this text

classmethod get_content_parsing_formatter() str | Iterable[str][source]

Return a str or a str iterable that is used in method _content_parse() for parsing

These strings will be passed as the 1st parameter to parse.parse, they are both supposed to contain at least the following fields:

  • hour

  • min

  • sec

  • logging

  • content

The return value of the first succeeded parse.parse call will be used for filling fields of the Info object

The return value should be a constant value

classmethod _content_parse(info: Info)[source]

A commonly used method to parse several generic elements from an un-parsed Info object

Elements expected to be parsed includes:

Parameters:

info – The to-be-processed Info object

parse_server_stdout(text: str) Info[source]

Main parsing operation. Parse a string from the stdout of the server and output a parsed info

It may raise any exceptions if the format of the input string is not correct

In this default implementation, it firstly uses _get_server_stdout_raw_result() to get a raw Info object, then use _content_parse() to fill generic information into the Info object, finally returns that as a simply-parsed info

If the server handler is able to parse more information, you can do more post-parsing operations after invoking this method via super()

Parameters:

text – A line of the server stdout to be parsed

Returns:

An Info object as the result

parse_player_joined(info: Info) str | None[source]

Check if the info indicating a player joined message

If it is, returns the name of the player, otherwise returns None

Parameters:

info – The info object to be checked

Returns:

The name of the player, or None

parse_player_left(info: Info) str | None[source]

Check if the info indicates a player left message

If it is, returns the name of the player, otherwise returns None

Parameters:

info – The info object to be checked

Returns:

The name of the player, or None

parse_server_version(info: Info) str | None[source]

Check if the info contains a server version message

If it is, returns server version, otherwise returns None

Parameters:

info – The info object to be checked

Returns:

The version of the server, or None

parse_server_address(info: Info) Tuple[str, int] | None[source]

Check if the info contains the address which the server is listening on

If it is, returns server ip and port it’s listening on, otherwise returns None

Parameters:

info – The info object to be checked

Returns:

A tuple containing the ip and the port, or None

test_server_startup_done(info: Info) bool[source]

Check if the info indicates a server startup message

Parameters:

info – The info object to be checked

Returns:

If the info indicates a server startup message

test_rcon_started(info: Info) bool[source]

Check if rcon has started

Parameters:

info – The info object to be checked

Returns:

If rcon has started

test_server_stopping(info: Info) bool[source]

Check if the server is stopping

Parameters:

info – The info object to be checked

Returns:

If the server is stopping

class mcdreforged.handler.impl.BasicHandler[source]

The basic plain handler, providing the minimum parsed information

It’s used as the fallback handler when every other dedicated handler failed

class mcdreforged.handler.impl.AbstractMinecraftHandler[source]

An abstract handler for Minecraft Java Edition servers

classmethod get_player_message_parsing_formatter() List[str][source]

Return a list of str that is used in method parse_server_stdout() for parsing player message

These strings will be passed as the 1st parameter to parse.parse, they are both supposed to contain at least the following fields:

  • name, the name of the player

  • message, what the player said

The return value of the first succeeded parse.parse call will be used for filling fields of the Info object

If none of these formatter strings can be parsed successfully, then this info is considered as a non-player message, i.e. has info.player equaling None

classmethod format_message(message: str | RTextBase) str[source]

A utility method to convert a message into a valid argument used in message sending command

class mcdreforged.handler.impl.VanillaHandler[source]

A handler for vanilla Minecraft servers

class mcdreforged.handler.impl.Beta18Handler[source]

Yes, a handler for Minecraft beta 1.8

class mcdreforged.handler.impl.ForgeHandler[source]

A handler for Forge Minecraft servers

class mcdreforged.handler.impl.BukkitHandler[source]

A handler for bukkit and bukkit-like (e.g. Paper) Minecraft servers

class mcdreforged.handler.impl.Bukkit14Handler[source]

A handler for bukkit and spigot Minecraft servers in 1.14+

class mcdreforged.handler.impl.CatServerHandler[source]

A handler for CatServer Minecraft servers

CatServer uses vanilla logging format but spigot like player joined message

And has color code around the player left message

class mcdreforged.handler.impl.ArclightHandler[source]

A handler for Arclight servers

class mcdreforged.handler.impl.BungeecordHandler[source]

A handler for Bungeecord servers

class mcdreforged.handler.impl.WaterfallHandler[source]

A handler for Waterfall servers

The logging format of waterfall server is paper like (waterfall is PaperMC’s bungeecord fork shmm)

class mcdreforged.handler.impl.VelocityHandler[source]

A handler for Velocity servers