Server Handler
- class mcdreforged.handler.server_handler.ServerHandler[source]
The interface class for server handler
Class inheriting tree:
ServerHandler (interface) └── AbstractServerHandler ├── BasicHandler ├── AbstractMinecraftHandler │ ├── VanillaHandler │ ├── Beta18Handler │ ├── ForgeHandler │ └── BukkitHandler │ ├── Bukkit14Handler │ ├── CatServerHandler │ └── ArclightHandler ├── BungeecordHandler │ └── WaterfallHandler └── VelocityHandler
- abstract get_name() str [source]
The name of the server handler
The name is used as the identifier of this server handler in MCDR configuration
- abstract get_send_message_command(target: str, message: str | RTextBase, server_information: ServerInformation) str | None [source]
The command to send a message to a target
- abstract get_broadcast_message_command(message: str | RTextBase, server_information: ServerInformation) str | None [source]
The command to broadcast a message in the server
- abstract 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
- abstract 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
- abstract 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 rawInfo
object, then use_content_parse()
to fill generic information into theInfo
object, finally returns that as a simply-parsed infoIf 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
- abstract 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
- abstract 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
- abstract 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
- abstract 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
- abstract 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
- class mcdreforged.handler.abstract_server_handler.AbstractServerHandler[source]
The abstract base class for server handler, with some common implementations
- classmethod _get_server_stdout_raw_result(text: str) Info [source]
This method does a raw parsing and returns an almost un-parsed
Info
objectUse 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
re.Pattern
or an Iterable ofre.Pattern
iterable that is used in method_content_parse()
for parsingThese regex patterns are supposed to contain at least the following fields:
hour
min
sec
logging
content
The return value of the first succeeded
re.Pattern.fullmatch()
call will be used for filling fields of theInfo
objectThe return value should be a constant value
- 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[Pattern] [source]
Return a list of
re.Pattern
that is used in methodparse_server_stdout()
for parsing player messageThese regex patterns are supposed to contain at least the following fields:
name
, the name of the playermessage
, what the player said
The return value of the first succeeded
re.Pattern.fullmatch()
call will be used for filling fields of theInfo
objectIf 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
- 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.BungeecordHandler[source]
A handler for Bungeecord servers