Plugin
endstone.plugin
¶
Classes relating to loading and managing plugins.
Modules:
| Name | Description |
|---|---|
plugin_loader |
|
Classes:
| Name | Description |
|---|---|
Plugin |
Represents a Plugin |
PluginCommand |
Represents a Command belonging to a Plugin |
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. |
Plugin
¶
Bases: Plugin
Represents a Plugin
Methods:
| Name | Description |
|---|---|
get_command |
Gets the command with the given name, specific to this plugin. |
on_disable |
Called when this plugin is disabled |
on_enable |
Called when this plugin is enabled |
on_load |
Called after a plugin is loaded but before it has been enabled. |
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. |
Attributes:
| Name | Type | Description |
|---|---|---|
api_version |
|
|
authors |
|
|
commands |
|
|
config |
dict
|
Returns the plugin's configuration loaded from config.toml. |
contributors |
|
|
data_folder |
Path
|
Returns the folder that the plugin data's files are located in. |
default_permission |
|
|
depend |
|
|
description |
|
|
is_enabled |
bool
|
Returns a value indicating whether this plugin is currently enabled |
load |
|
|
load_before |
|
|
logger |
Logger
|
Returns the plugin logger associated with this server's logger. |
name |
str
|
Returns the name of the plugin. |
permissions |
|
|
plugin_loader |
PluginLoader
|
Gets the associated PluginLoader responsible for this plugin |
prefix |
|
|
provides |
|
|
server |
Server
|
Returns the Server instance currently running this plugin |
soft_depend |
|
|
version |
|
|
website |
|
config
property
¶
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:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
The plugin's configuration data. |
data_folder
property
¶
data_folder: Path
Returns the folder that the plugin data's files are located in.
is_enabled
property
¶
is_enabled: bool
Returns a value indicating whether this plugin is currently enabled
plugin_loader
property
¶
plugin_loader: PluginLoader
Gets the associated PluginLoader responsible for this plugin
get_command
¶
get_command(name: str) -> PluginCommand
Gets the command with the given name, specific to this plugin.
register_events
¶
register_events(listener: object) -> None
Registers all events defined in the given listener instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
listener
|
object
|
The listener object containing event handler methods to be registered. |
required |
reload_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:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
The plugin's configuration data. |
save_default_config
¶
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.
save_resources
¶
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:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
The relative path to the resource inside the plugin’s package. Directory separators are normalized to forward slashes. |
required |
replace
|
bool
|
Whether to overwrite the existing file if it already exists. Defaults to False. |
False
|
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If the specified resource cannot be found in the package. |
OSError
|
If an error occurs while copying or creating directories. |
PluginCommand
¶
PluginCommand(
name: str,
description: str | None = None,
usages: list[str] | None = None,
aliases: list[str] | None = None,
permissions: list[str] | None = None,
*args,
**kwargs
)
Bases: Command
Represents a Command belonging to a Plugin
Attributes:
| Name | Type | Description |
|---|---|---|
executor |
CommandExecutor
|
The CommandExecutor to run when parsing this command |
plugin |
Plugin
|
The owner of this PluginCommand |
executor
property
writable
¶
executor: CommandExecutor
The CommandExecutor to run when parsing this command
PluginLoadOrder
¶
PluginLoader
¶
PluginLoader(server: Server)
Represents a plugin loader, which handles direct access to specific types of plugins
Methods:
| Name | Description |
|---|---|
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:
| Name | Type | Description |
|---|---|---|
plugin_file_filters |
list[str]
|
Returns a list of all filename filters expected by this PluginLoader |
server |
Server
|
Retrieves the Server object associated with the PluginLoader. |
plugin_file_filters
property
¶
Returns a list of all filename filters expected by this PluginLoader
PluginManager
¶
Represents a plugin manager that handles all plugins from the Server
Methods:
| Name | Description |
|---|---|
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. |
is_plugin_enabled |
|
load_plugin |
Loads the plugin in the specified file |
load_plugins |
|
recalculate_permission_defaults |
Recalculates the defaults for the given Permission. |
register_event |
Registers the given event |
remove_permission |
|
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:
| Name | Type | Description |
|---|---|---|
permissions |
set[Permission]
|
Gets a set of all registered permissions. |
plugins |
list[Plugin]
|
Gets a list of all currently loaded plugins |
get_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.
get_default_permissions
¶
get_default_permissions(
level: PermissionLevel,
) -> list[Permission]
Gets the default permissions for the given permission level.
get_permission
¶
get_permission(name: str) -> Permission
Gets a Permission from its fully qualified name.
get_permission_subscriptions
¶
get_permission_subscriptions(
permission: str,
) -> set[Permissible]
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.
is_plugin_enabled
¶
Checks if the given plugin is enabled or not
Checks if the given plugin is enabled or not
load_plugins
¶
Loads the plugin contained within the specified directory
Loads the plugins in the list of the files
recalculate_permission_defaults
¶
recalculate_permission_defaults(perm: Permission) -> None
Recalculates the defaults for the given Permission.
register_event
¶
register_event(
name: str,
executor: Callable[[Event], None],
priority: EventPriority,
plugin: Plugin,
ignore_cancelled: bool,
) -> None
Registers the given event
remove_permission
¶
remove_permission(perm: Permission) -> None
Removes a Permission registration from this plugin manager by permission object.
remove_permission(name: str) -> None
Removes a Permission registration from this plugin manager by name.
subscribe_to_default_perms
¶
subscribe_to_default_perms(
level: PermissionLevel, permissible: Permissible
) -> None
Subscribes to the given Default permissions by permission level.
subscribe_to_permission
¶
subscribe_to_permission(
permission: str, permissible: Permissible
) -> None
Subscribes the given Permissible for information about the requested Permission.
unsubscribe_from_default_perms
¶
unsubscribe_from_default_perms(
level: PermissionLevel, permissible: Permissible
) -> None
Unsubscribes from the given Default permissions by permission level.
unsubscribe_from_permission
¶
unsubscribe_from_permission(
permission: str, permissible: Permissible
) -> None
Unsubscribes the given Permissible for information about the requested Permission.
ServiceManager
¶
Represent a service manager that manages services and service providers.
Methods:
| Name | Description |
|---|---|
load |
|
register |
Register a provider of a service. |
unregister |
|
unregister_all |
Unregister all the services registered by a particular plugin. |