Plugin Stuffs

Metadata

class mcdreforged.plugin.meta.metadata.Metadata(data: dict | None, *, plugin: AbstractPlugin | None = None)[source]

The metadata of a MCDR plugin

id: str

The id of the plugin. Should match regexp [a-z][a-z0-9_]{0,63}

Changed in version v2.11.0: Plugin id starts with non-alphabet character is no longer disallowed

name: str

The name of the plugin

description: str | Dict[str, str] | None

The description of the plugin

It can be a regular str or a Dict[str, str] indicating a mapping from language to description

author: List[str] | None

The authors of the plugin

The url to the plugin, e.g. link to a github repository

version: Version

The version of the plugin, in a less restrictive semver format

dependencies: Dict[str, VersionRequirement]

A dict of dependencies the plugin relies on

Key:

The id of the dependent plugin

Value:

The version requirement of the dependent plugin

entrypoint: str

The entrypoint module of the plugin

The entrypoint should be import-able

get_description(lang: str | None = None) str | None[source]

Return a translated plugin description in str

Parameters:

lang – Optional, the language to translate to. When not specified it will use the language of MCDR

Returns:

Translated plugin description

get_description_rtext() RTextBase[source]

Return a translated plugin description in RText

New in version v2.1.2.

class mcdreforged.plugin.meta.version.Version(version_str: str, *, allow_wildcard: bool = True)[source]

A version container that stores semver like version string

Example:

  • "1.2.3"

  • "1.0.*"

  • "1.2.3-pre4+build.5"

__init__(version_str: str, *, allow_wildcard: bool = True)[source]
Parameters:

version_str – The version string to be parsed

Keyword Arguments:

allow_wildcard – If wildcard ("*", "x", "X") is allowed. Default: True

class mcdreforged.plugin.meta.version.VersionRequirement(requirements: str)[source]

A version requirement tester

It can test if a given Version object matches its requirement

__init__(requirements: str)[source]
Parameters:

requirements – The requirement string, which contains several version predicates connected by space character. e.g. ">=1.0.x", "^2.9", ">=1.2.0 <1.4.3"

Plugin Event

class mcdreforged.plugin.plugin_event.PluginEvent(event_id: str)[source]

The abstract base class of plugin event

A plugin event has an id field as its identifier

id: str

The id of the plugin event

class mcdreforged.plugin.plugin_event.LiteralEvent(event_id: str)[source]

Bases: PluginEvent

A simple and minimum implementation of PluginEvent

All information you need to construct a LiteralEvent object is only the event id

__init__(event_id: str)[source]

Create a LiteralEvent

Parameters:

event_id – The id of the plugin event

class mcdreforged.plugin.plugin_event.MCDREvent(event_id: str, default_method_name: str)[source]

Bases: PluginEvent

Plugin event that used in MCDR

Generally, only MCDR is supposed to construct MCDREvent

class mcdreforged.plugin.plugin_event.MCDRPluginEvents[source]

A collection of all possible MCDREvent objects used in MCDR

GENERAL_INFO = MCDREvent[id='mcdr.general_info', default_method_name='on_info']
USER_INFO = MCDREvent[id='mcdr.user_info', default_method_name='on_user_info']
SERVER_START = MCDREvent[id='mcdr.server_start', default_method_name='on_server_start']
SERVER_STARTUP = MCDREvent[id='mcdr.server_startup', default_method_name='on_server_startup']
SERVER_STOP = MCDREvent[id='mcdr.server_stop', default_method_name='on_server_stop']
MCDR_START = MCDREvent[id='mcdr.mcdr_start', default_method_name='on_mcdr_start']
MCDR_STOP = MCDREvent[id='mcdr.mcdr_stop', default_method_name='on_mcdr_stop']
PLAYER_JOINED = MCDREvent[id='mcdr.player_joined', default_method_name='on_player_joined']
PLAYER_LEFT = MCDREvent[id='mcdr.player_left', default_method_name='on_player_left']
PLUGIN_LOADED = MCDREvent[id='mcdr.plugin_loaded', default_method_name='on_load']
PLUGIN_UNLOADED = MCDREvent[id='mcdr.plugin_unloaded', default_method_name='on_unload']