endstone.plugin

Classes relating to loading and managing plugins.

Classes relating to loading and managing plugins.

Modules

NameDescription
plugin_loader

Classes

NameDescription
Plugin

Represents a Plugin

PluginCommand

Represents a Command belonging to a Plugin

PluginDescription

Represents the basic information about a plugin that the plugin loader needs to know.

PluginLoadOrder

Represents the order in which a plugin should be initialized and enabled.

PluginLoader

Represents a plugin loader, which handles direct access to specific types of plugins

PluginManager

Represents a plugin manager that handles all plugins from the Server

Service

Represents a list of methods.

ServiceManager

Represent a service manager that manages services and service providers.

ServicePriority

Represents various priorities of a provider.

classPlugin

Bases: _Plugin

Plugin()

Represents a Plugin

Methods

NameDescription
register_events

Registers all events defined in the given listener instance.

reload_config

Returns the plugin's configuration loaded from config.toml.

save_config

Saves the current configuration to the config.toml file.

save_default_config

Saves the default config.toml file to the plugin's data folder.

save_resources

Saves a packaged resource from the plugin module to the data folder.

attrapi_version

api_version = None

attrauthors

authors = None

attrcommands

commands = None

attrconfigproperty

config: dict

Returns the plugin's configuration loaded from config.toml.

Loads and returns the plugin’s configuration data from config.toml. If the configuration has not been loaded yet, it is automatically reloaded using reload_config().

Returns

NameTypeDescription
dictdict

The plugin's configuration data.

attrcontributors

contributors = None

attrdefault_permission

default_permission = None

attrdepend

depend = None

attrdescription

description = None

attrload

load = None

attrload_before

load_before = None

attrpermissions

permissions = None

attrprefix

prefix = None

attrprovides

provides = None

attrsoft_depend

soft_depend = None

attrversion

version = None

attrwebsite

website = None

methregister_events

register_events(listener: object) -> None

Registers all events defined in the given listener instance.

Parameters

NameTypeDescriptionDefault
listenerobject

The listener object containing event handler methods to be registered.

required

methreload_config

reload_config() -> dict

Returns the plugin's configuration loaded from config.toml.

Loads and returns the plugin’s configuration data from config.toml. If a default configuration file is packaged with the plugin, its values are used as defaults.

Returns

NameTypeDescription
dictdict

The plugin's configuration data.

methsave_config

save_config() -> None

Saves the current configuration to the config.toml file.

methsave_default_config

save_default_config() -> None

Saves the default config.toml file to the plugin's data folder.

If config.toml does not already exist in the plugin’s data folder, this method copies the default version from the plugin’s packaged resources. If the file already exists, the method does nothing and fails silently.

methsave_resources

save_resources(path: str, replace: bool = False) -> None

Saves a packaged resource from the plugin module to the data folder.

The method locates a resource bundled within the plugin’s package and copies it to the plugin’s data folder, preserving its relative directory structure. If the target file already exists, it will only be replaced if replace is set to True.

Parameters

NameTypeDescriptionDefault
pathstr

The relative path to the resource inside the plugin’s package. Directory separators are normalized to forward slashes.

required
replacebool

Whether to overwrite the existing file if it already exists. Defaults to False.

False

Raises

TypeDescription
FileNotFoundError

If the specified resource cannot be found in the package.

OSError

If an error occurs while copying or creating directories.

classPluginCommand

Bases: Command

PluginCommand()

Represents a Command belonging to a Plugin

Attributes

NameTypeDescription
executorCommandExecutor

The CommandExecutor to run when parsing this command

pluginPlugin

The owner of this PluginCommand

attrexecutorproperty

executor: CommandExecutor

The CommandExecutor to run when parsing this command

attrpluginproperty

plugin: Plugin

The owner of this PluginCommand

classPluginDescription

PluginDescription(name: str, version: str, description: str | None = None, load: PluginLoadOrder | None = None, authors: list[str] | None = None, contributors: list[str] | None = None, website: str | None = None, prefix: str | None = None, provides: list[str] | None = None, depend: list[str] | None = None, soft_depend: list[str] | None = None, load_before: list[str] | None = None, default_permission: PermissionDefault | None = None, commands: list[Command] | None = None, permissions: list[Permission] | None = None, *args, **kwargs)

Represents the basic information about a plugin that the plugin loader needs to know.

Attributes

NameTypeDescription
api_versionstr

Gives the API version which this plugin is designed to support.

authorslist[str]

Gives the list of authors for the plugin.

commandslist[Command]

Gives the list of commands the plugin will register at runtime.

contributorslist[str]

Gives the list of contributors for the plugin.

default_permissionPermissionDefault

Gives the default value of permissions registered for the plugin.

dependlist[str]

Gives a list of other plugins that the plugin requires.

descriptionstr

Gives a human-friendly description of the functionality the plugin provides.

full_namestr

Returns the name of a plugin, including the version.

loadPluginLoadOrder

Gives the phase of server startup that the plugin should be loaded.

load_beforelist[str]

Gets the list of plugins that should consider this plugin a soft-dependency.

namestr

Gives the name of the plugin. This name is a unique identifier for plugins.

permissionslist[Permission]

Gives the list of permissions the plugin will register at runtime, immediately proceeding enabling.

prefixstr

Gives the token to prefix plugin-specific logging messages with.

provideslist[str]

Gives the list of other plugin APIs which this plugin provides. These are usable for other plugins to depend on.

soft_dependlist[str]

Gives a list of other plugins that the plugin requires for full functionality.

versionstr

Gives the version of the plugin.

websitestr

Gives the plugin's or plugin's author's website.

attrapi_versionproperty

api_version: str

Gives the API version which this plugin is designed to support.

attrauthorsproperty

authors: list[str]

Gives the list of authors for the plugin.

attrcommandsproperty

commands: list[Command]

Gives the list of commands the plugin will register at runtime.

attrcontributorsproperty

contributors: list[str]

Gives the list of contributors for the plugin.

attrdefault_permissionproperty

default_permission: PermissionDefault

Gives the default value of permissions registered for the plugin.

attrdependproperty

depend: list[str]

Gives a list of other plugins that the plugin requires.

attrdescriptionproperty

description: str

Gives a human-friendly description of the functionality the plugin provides.

attrfull_nameproperty

full_name: str

Returns the name of a plugin, including the version.

attrloadproperty

Gives the phase of server startup that the plugin should be loaded.

attrload_beforeproperty

load_before: list[str]

Gets the list of plugins that should consider this plugin a soft-dependency.

attrnameproperty

name: str

Gives the name of the plugin. This name is a unique identifier for plugins.

attrpermissionsproperty

permissions: list[Permission]

Gives the list of permissions the plugin will register at runtime, immediately proceeding enabling.

attrprefixproperty

prefix: str

Gives the token to prefix plugin-specific logging messages with.

attrprovidesproperty

provides: list[str]

Gives the list of other plugin APIs which this plugin provides. These are usable for other plugins to depend on.

attrsoft_dependproperty

soft_depend: list[str]

Gives a list of other plugins that the plugin requires for full functionality.

attrversionproperty

version: str

Gives the version of the plugin.

attrwebsiteproperty

website: str

Gives the plugin's or plugin's author's website.

classPluginLoadOrder

Bases: Enum

PluginLoadOrder()

Represents the order in which a plugin should be initialized and enabled.

Attributes

NameTypeDescription
POSTWORLD
STARTUP

attrPOSTWORLD

POSTWORLD = 1

attrSTARTUP

STARTUP = 0

classPluginLoader

PluginLoader(server: Server)

Represents a plugin loader, which handles direct access to specific types of plugins

Methods

NameDescription
disable_plugin

Disables the specified plugin

enable_plugin

Enables the specified plugin

load_plugin

Loads the plugin contained in the specified file

load_plugins

Loads the plugin contained within the specified directory

Attributes

NameTypeDescription
plugin_file_filterslist[str]

Returns a list of all filename filters expected by this PluginLoader

serverServer

Retrieves the Server object associated with the PluginLoader.

attrplugin_file_filtersproperty

plugin_file_filters: list[str]

Returns a list of all filename filters expected by this PluginLoader

attrserverproperty

server: Server

Retrieves the Server object associated with the PluginLoader.

methdisable_plugin

disable_plugin(plugin: Plugin) -> None

Disables the specified plugin

methenable_plugin

enable_plugin(plugin: Plugin) -> None

Enables the specified plugin

methload_plugin

load_plugin(file: str) -> Plugin

Loads the plugin contained in the specified file

methload_plugins

load_plugins(directory: str) -> list[Plugin]

Loads the plugin contained within the specified directory

classPluginManager

PluginManager()

Represents a plugin manager that handles all plugins from the Server

Methods

NameDescription
call_event

Calls an event which will be passed to plugins.

clear_plugins

Disables and removes all plugins

disable_plugin

Disables the specified plugin

disable_plugins

Disables all the loaded plugins

enable_plugin

Enables the specified plugin

enable_plugins

Enable all the loaded plugins

get_default_perm_subscriptions

Gets a set containing all subscribed Permissibles to the given default list, by permission level.

get_default_permissions

Gets the default permissions for the given permission level.

get_permission

Gets a Permission from its fully qualified name.

get_permission_subscriptions

Gets a set containing all subscribed Permissibles to the given permission.

get_plugin

Checks if the given plugin is loaded and returns it when applicable.

load_plugin

Loads the plugin in the specified file

recalculate_permission_defaults

Recalculates the defaults for the given Permission.

register_event

Registers the given event

subscribe_to_default_perms

Subscribes to the given Default permissions by permission level.

subscribe_to_permission

Subscribes the given Permissible for information about the requested Permission.

unsubscribe_from_default_perms

Unsubscribes from the given Default permissions by permission level.

unsubscribe_from_permission

Unsubscribes the given Permissible for information about the requested Permission.

Attributes

NameTypeDescription
permissionsset[Permission]

Gets a set of all registered permissions.

pluginslist[Plugin]

Gets a list of all currently loaded plugins

attrpermissionsproperty

permissions: set[Permission]

Gets a set of all registered permissions.

attrpluginsproperty

plugins: list[Plugin]

Gets a list of all currently loaded plugins

methcall_event

call_event(event: Event) -> None

Calls an event which will be passed to plugins.

methclear_plugins

clear_plugins() -> None

Disables and removes all plugins

methdisable_plugin

disable_plugin(plugin: Plugin) -> None

Disables the specified plugin

methdisable_plugins

disable_plugins() -> None

Disables all the loaded plugins

methenable_plugin

enable_plugin(plugin: Plugin) -> None

Enables the specified plugin

methenable_plugins

enable_plugins() -> None

Enable all the loaded plugins

methget_default_perm_subscriptions

get_default_perm_subscriptions(level: PermissionLevel) -> set[Permissible]

Gets a set containing all subscribed Permissibles to the given default list, by permission level.

methget_default_permissions

get_default_permissions(level: PermissionLevel) -> list[Permission]

Gets the default permissions for the given permission level.

methget_permission

get_permission(name: str) -> Permission

Gets a Permission from its fully qualified name.

methget_permission_subscriptions

get_permission_subscriptions(permission: str) -> set[Permissible]

Gets a set containing all subscribed Permissibles to the given permission.

methget_plugin

get_plugin(name: str) -> Plugin

Checks if the given plugin is loaded and returns it when applicable.

methload_plugin

load_plugin(file: str) -> Plugin

Loads the plugin in the specified file

methrecalculate_permission_defaults

recalculate_permission_defaults(perm: Permission) -> None

Recalculates the defaults for the given Permission.

methregister_event

register_event(name: str, executor: Callable[[Event], None], priority: EventPriority, plugin: Plugin, ignore_cancelled: bool) -> None

Registers the given event

methsubscribe_to_default_perms

subscribe_to_default_perms(level: PermissionLevel, permissible: Permissible) -> None

Subscribes to the given Default permissions by permission level.

methsubscribe_to_permission

subscribe_to_permission(permission: str, permissible: Permissible) -> None

Subscribes the given Permissible for information about the requested Permission.

methunsubscribe_from_default_perms

unsubscribe_from_default_perms(level: PermissionLevel, permissible: Permissible) -> None

Unsubscribes from the given Default permissions by permission level.

methunsubscribe_from_permission

unsubscribe_from_permission(permission: str, permissible: Permissible) -> None

Unsubscribes the given Permissible for information about the requested Permission.

classService

Service()

Represents a list of methods.

classServiceManager

ServiceManager()

Represent a service manager that manages services and service providers.

Methods

NameDescription
load
register

Register a provider of a service.

unregister_all

Unregister all the services registered by a particular plugin.

methload

load(name: str) -> Service

methregister

register(name: str, provider: Service, plugin: Plugin, priority: ServicePriority) -> None

Register a provider of a service.

methunregister_all

unregister_all(plugin: Plugin) -> None

Unregister all the services registered by a particular plugin.

classServicePriority

Bases: IntEnum

ServicePriority()

Represents various priorities of a provider.

Attributes

NameTypeDescription
HIGH
HIGHEST
LOW
LOWEST
NORMAL

attrHIGH

HIGH = 3

attrHIGHEST

HIGHEST = 4

attrLOW

LOW = 1

attrLOWEST

LOWEST = 0

attrNORMAL

NORMAL = 2

On this page