Plugin Stuffs

Attributes

class mcdreforged.plugin.type.common.PluginType(*values)[source]

Format of the plugin

Added in version v2.13.0.

builtin = 1

MCDR builtin plugin

solo = 2

Solo Plugin

packed = 3

Packed Plugin

directory = 4

Directory Plugin

linked_directory = 5

Linked Directory Plugin

Metadata

For metadata declarations and field formats, see Metadata

class mcdreforged.plugin.meta.metadata.Metadata(*args: Any, **kwargs: Any)[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 allowed

version: Version

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

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

authors: List[Person] | None

The authors of the plugin

maintainers: List[Person] | None

The maintainers of the plugin

The links related to the plugin

license: str | None

The license of the plugin

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

requirements_file: RequirementsFileSpec

The defination of the Python requirements file inside the multi-file plugin

entrypoint: str

The entrypoint module of the plugin

The entrypoint should be import-able

classmethod create(data: dict | PluginMetadataJsonModel, *, plugin: AbstractPlugin | None = None) Metadata[source]
Parameters:
  • plugin (AbstractPlugin) – the plugin which this metadata is belonged to

  • data (dict or None) – a dict with information of the plugin

Added in version v2.16.0.

property author: List[str] | None

The author names of the plugin

Deprecated since version v2.16.0: Use authors instead.

The homepage of the plugin

Deprecated since version v2.16.0: Use links instead.

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

Added in version v2.1.2.

to_dict() dict[source]

Create a dict present of this metadata object

Added in version v2.13.0.

class mcdreforged.plugin.meta.schema.Person(*, name: str, email: str | None = None, homepage: str | None = None)[source]
name: str
email: str | None
homepage: str | None
homepage: str | None
source: str | None
documentation: str | None
issues: str | None
class mcdreforged.plugin.meta.metadata.RequirementsFileSpec(mode: Mode, path: str | None)[source]

The declared handling strategy for a multi-file plugin’s Python requirements file

class Mode(*values)[source]
AUTO = 'auto'
DISABLED = 'disabled'
REQUIRED = 'required'
mode: Mode
path: str | None
classmethod auto() RequirementsFileSpec[source]
classmethod disabled() RequirementsFileSpec[source]
classmethod required(path: str) RequirementsFileSpec[source]
classmethod from_declaration(value: str | None, *, declared: bool) RequirementsFileSpec[source]
classmethod from_model(model: PluginMetadataJsonModel) RequirementsFileSpec[source]
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_PRE = MCDREvent(id='mcdr.server_start_pre', default_method_name='on_server_start_pre')
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')