endstone/plugin
Classes
| Name | Description |
|---|---|
Plugin | Represents a Plugin. |
PluginDescription | Represents the basic information about a plugin that the plugin loader needs to know. |
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 | Services represent a list of methods. |
ServiceManager | Represent a service manager that manages services and service providers. |
Enums
| Name | Description |
|---|---|
PluginLoadOrder | Represents the order in which a plugin should be initialized and enabled. |
ServicePriority | Represents various priorities of a provider. |
classPlugin
Defined in <endstone/plugin/plugin.h>
Bases: CommandExecutor
Represents a Plugin.
Methods
| Name | Description |
|---|---|
Plugin | |
Plugin | |
operator= | |
~Plugin | |
getDescription | Returns the details of this plugin. |
onLoad | Called after a plugin is loaded but before it has been enabled. |
onEnable | Called when this plugin is enabled. |
onDisable | Called when this plugin is disabled. |
getLogger | Returns the plugin logger associated with this server's logger. The returned logger automatically tags all log messages with the plugin's name. |
isEnabled | Returns a value indicating whether this plugin is currently enabled. |
getPluginLoader | Gets the associated PluginLoader responsible for this plugin. |
getServer | Returns the Server instance currently running this plugin. |
getName | Returns the name of the plugin. |
getCommand | Gets the command with the given name, specific to this plugin. |
getDataFolder | Returns the folder that the plugin data's files are located in. The folder may not yet exist. |
registerEvent | |
registerEvent | |
setEnabled |
methPlugin
Plugin() =defaultmethPlugin
Plugin(const Plugin&) =deletemethoperator=
meth~Plugin
~Plugin() override=defaultmethgetDescriptionabstractconst
const PluginDescription& getDescription() const =0Returns the details of this plugin.
Returns
| Type | Description |
|---|---|
const PluginDescription& | Details of this plugin |
methonLoadvirtual
void onLoad()Called after a plugin is loaded but before it has been enabled.
When multiple plugins are loaded, the onLoad() for all plugins is called before any onEnable() is called.
methonEnablevirtual
void onEnable()Called when this plugin is enabled.
methonDisablevirtual
void onDisable()Called when this plugin is disabled.
methgetLoggerconst
Logger& getLogger() constReturns the plugin logger associated with this server's logger. The returned logger automatically tags all log messages with the plugin's name.
methisEnabledconst
bool isEnabled() constReturns a value indicating whether this plugin is currently enabled.
Returns
| Type | Description |
|---|---|
bool | true if this plugin is enabled, otherwise false |
methgetPluginLoaderconst
PluginLoader& getPluginLoader() constGets the associated PluginLoader responsible for this plugin.
Returns
| Type | Description |
|---|---|
PluginLoader& | PluginLoader that controls this plugin |
methgetServerconst
Server& getServer() constReturns the Server instance currently running this plugin.
methgetNameconst
std::string getName() constReturns the name of the plugin.
This should return the bare name of the plugin and should be used for comparison.
Returns
| Type | Description |
|---|---|
std::string | name of the plugin |
methgetCommandconst
PluginCommand* getCommand(std::string name) constGets the command with the given name, specific to this plugin.
Parameters
| Name | Type | Description |
|---|---|---|
name | std::string | name or alias of the command |
Returns
| Type | Description |
|---|---|
PluginCommand* | the plugin command if found, otherwise null |
methgetDataFolderconst
const std::filesystem::path& getDataFolder() constReturns the folder that the plugin data's files are located in. The folder may not yet exist.
Returns
| Type | Description |
|---|---|
const std::filesystem::path& | The folder |
methregisterEvent
void registerEvent(void(T::*)(EventType&) func, T& instance, EventPriority priority = EventPriority::Normal, bool ignore_cancelled = false)methregisterEvent
void registerEvent(std::function<void(EventType&)> func, EventPriority priority = EventPriority::Normal, bool ignore_cancelled = false)methsetEnabledprotected
void setEnabled(bool enabled)Sets the enabled state of this plugin
Parameters
| Name | Type | Description |
|---|---|---|
enabled | bool | true if enabled, otherwise false |
classPluginDescription
Defined in <endstone/plugin/plugin_description.h>
Represents the basic information about a plugin that the plugin loader needs to know.
Methods
methPluginDescription
PluginDescription(std::string name, std::string version, std::string description = "", PluginLoadOrder load = PluginLoadOrder::PostWorld, std::vector<std::string> authors = {}, std::vector<std::string> contributors = {}, std::string website = "", std::string prefix = "", std::vector<std::string> provides = {}, std::vector<std::string> depend = {}, std::vector<std::string> soft_depend = {}, std::vector<std::string> load_before = {}, PermissionDefault default_permission = PermissionDefault::Operator, std::vector<Command> commands = {}, std::vector<Permission> permissions = {})methgetNameconst
std::string getName() constGives the name of the plugin. This name is a unique identifier for plugins.
Returns
| Type | Description |
|---|---|
std::string | the name of the plugin |
methgetVersionconst
std::string getVersion() constGives the version of the plugin.
Returns
| Type | Description |
|---|---|
std::string | the version of the plugin |
methgetFullNameconst
std::string getFullName() constReturns the name of a plugin, including the version.
Returns
| Type | Description |
|---|---|
std::string | a descriptive name of the plugin and respective version |
methgetAPIVersionconst
std::string getAPIVersion() constGives the API version which this plugin is designed to support.
Returns
| Type | Description |
|---|---|
std::string | the API version supported by the plugin |
methgetDescriptionconst
std::string getDescription() constGives a human-friendly description of the functionality the plugin provides.
Returns
| Type | Description |
|---|---|
std::string | description of this plugin, or empty if not specified |
methgetLoadconst
PluginLoadOrder getLoad() constGives the phase of server startup that the plugin should be loaded.
Returns
| Type | Description |
|---|---|
PluginLoadOrder | the phase when the plugin should be loaded |
methgetAuthorsconst
std::vector<std::string> getAuthors() constGives the list of authors for the plugin.
Returns
| Type | Description |
|---|---|
std::vector<std::string> | an immutable list of the plugin's authors |
methgetContributorsconst
std::vector<std::string> getContributors() constGives the list of contributors for the plugin.
Returns
| Type | Description |
|---|---|
std::vector<std::string> | an immutable list of the plugin's contributions |
methgetWebsiteconst
std::string getWebsite() constGives the plugin's or plugin's author's website.
Returns
| Type | Description |
|---|---|
std::string | the website of this plugin, or empty if not specified |
methgetPrefixconst
std::string getPrefix() constGives the token to prefix plugin-specific logging messages with.
Returns
| Type | Description |
|---|---|
std::string | the prefixed logging token, or empty if not specified |
methgetProvidesconst
std::vector<std::string> getProvides() constGives the list of other plugin APIs which this plugin provides. These are usable for other plugins to depend on.
Returns
| Type | Description |
|---|---|
std::vector<std::string> | immutable list of the plugin APIs which this plugin provides |
methgetDependconst
std::vector<std::string> getDepend() constGives a list of other plugins that the plugin requires.
Returns
| Type | Description |
|---|---|
std::vector<std::string> | immutable list of the plugin's dependencies |
methgetSoftDependconst
std::vector<std::string> getSoftDepend() constGives a list of other plugins that the plugin requires for full functionality.
Returns
| Type | Description |
|---|---|
std::vector<std::string> | immutable list of the plugin's preferred dependencies |
methgetLoadBeforeconst
std::vector<std::string> getLoadBefore() constGets the list of plugins that should consider this plugin a soft-dependency.
Returns
| Type | Description |
|---|---|
std::vector<std::string> | immutable list of plugins that should consider this plugin a soft-dependency |
methgetDefaultPermissionconst
PermissionDefault getDefaultPermission() constGives the default value of permissions registered for the plugin.
Returns
| Type | Description |
|---|---|
PermissionDefault | the default value for the plugin's permissions |
methgetCommandsconst
std::vector<Command> getCommands() constGives the list of commands the plugin will register at runtime.
Returns
| Type | Description |
|---|---|
std::vector<Command> | the commands this plugin will register |
methgetPermissionsconst
std::vector<Permission> getPermissions() constGives the list of permissions the plugin will register at runtime, immediately proceeding enabling.
Returns
| Type | Description |
|---|---|
std::vector<Permission> | the permissions this plugin will register |
classPluginLoader
Defined in <endstone/plugin/plugin_loader.h>
Represents a plugin loader, which handles direct access to specific types of plugins.
Variables
| Name | Description |
|---|---|
server_ |
Methods
| Name | Description |
|---|---|
PluginLoader | |
PluginLoader | |
operator= | |
~PluginLoader | |
loadPlugin | |
loadPlugins | Loads the plugin contained within the specified directory. |
getPluginFileFilters | Returns a list of all filename filters expected by this PluginLoader. |
enablePlugin | Enables the specified plugin Attempting to enable a plugin that is already enabled will have no effect. |
disablePlugin | Disables the specified plugin Attempting to disable a plugin that is not enabled will have no effect. |
getServer | Retrieves the Server object associated with the PluginLoader. |
varserver_protected
Server& server_methPluginLoaderexplicit
PluginLoader(Server& server)methPluginLoader
PluginLoader(const PluginLoader&) =deletemethoperator=
PluginLoader& operator=(const PluginLoader&) =deletemeth~PluginLoadervirtual
~PluginLoader() =defaultmethloadPluginabstract
Plugin* loadPlugin(std::string file) =0Loads the plugin contained in the specified file
Parameters
| Name | Type | Description |
|---|---|---|
file | std::string | File to attempt to load |
methloadPluginsvirtual
std::vector<Plugin*> loadPlugins(std::string directory)Loads the plugin contained within the specified directory.
Parameters
| Name | Type | Description |
|---|---|---|
directory | std::string | Directory to check for plugins |
Returns
| Type | Description |
|---|---|
std::vector<Plugin*> | A list of all plugins loaded |
methgetPluginFileFiltersabstractconst
std::vector<std::string> getPluginFileFilters() const =0Returns a list of all filename filters expected by this PluginLoader.
Returns
| Type | Description |
|---|---|
std::vector<std::string> | The filters |
methenablePluginvirtualconst
void enablePlugin(Plugin& plugin) constEnables the specified plugin Attempting to enable a plugin that is already enabled will have no effect.
methdisablePluginvirtualconst
void disablePlugin(Plugin& plugin) constDisables the specified plugin Attempting to disable a plugin that is not enabled will have no effect.
methgetServerconst
Server& getServer() constRetrieves the Server object associated with the PluginLoader.
This function returns a reference to the Server object that the PluginLoader is associated with.
classPluginManager
Defined in <endstone/plugin/plugin_manager.h>
Represents a plugin manager that handles all plugins from the Server.
Methods
methPluginManager
PluginManager() =defaultmethPluginManager
PluginManager(PluginManager const&) =deletemethoperator=
PluginManager& operator=(PluginManager const&) =deletemeth~PluginManagervirtual
~PluginManager() =defaultmethregisterLoaderabstract
void registerLoader(std::unique_ptr<PluginLoader> loader) =0Registers the specified plugin loader
Parameters
| Name | Type | Description |
|---|---|---|
loader | std::unique_ptr<PluginLoader> | PluginLoader to register |
methgetPluginabstractconst
Plugin* getPlugin(const std::string& name) const =0Checks if the given plugin is loaded and returns it when applicable. Please note that the name of the plugin is case-sensitive
Parameters
| Name | Type | Description |
|---|---|---|
name | const std::string& | Name of the plugin to check |
methgetPluginsabstractconst
std::vector<Plugin*> getPlugins() const =0Gets a list of all currently loaded plugins
Returns
| Type | Description |
|---|---|
std::vector<Plugin*> | List of Plugins |
methisPluginEnabledabstractconst
bool isPluginEnabled(const std::string& name) const =0Checks if the given plugin is enabled or not Please note that the name of the plugin is case-sensitive.
Parameters
| Name | Type | Description |
|---|---|---|
name | const std::string& | Name of the plugin to check |
Returns
| Type | Description |
|---|---|
bool | true if the plugin is enabled, otherwise false |
methisPluginEnabledabstractconst
bool isPluginEnabled(Plugin* plugin) const =0Checks if the given plugin is enabled or not
Returns
| Type | Description |
|---|---|
bool | true if the plugin is enabled, otherwise false |
methloadPluginabstract
Plugin* loadPlugin(std::string file) =0Loads the plugin in the specified file
File must be valid according to the current enabled Plugin interfaces
Parameters
| Name | Type | Description |
|---|---|---|
file | std::string | File containing the plugin to load |
methloadPluginsabstract
std::vector<Plugin*> loadPlugins(std::string directory) =0Loads the plugin contained within the specified directory
Parameters
| Name | Type | Description |
|---|---|---|
directory | std::string | Directory to check for plugins |
Returns
| Type | Description |
|---|---|
std::vector<Plugin*> | A list of all plugins loaded |
methloadPluginsabstract
std::vector<Plugin*> loadPlugins(std::vector<std::string> files) =0Loads the plugins in the list of the files
Parameters
| Name | Type | Description |
|---|---|---|
files | std::vector<std::string> | List of files containing plugins to load |
Returns
| Type | Description |
|---|---|
std::vector<Plugin*> | A list of all plugins loaded |
methenablePluginabstractconst
void enablePlugin(Plugin& plugin) const =0Enables the specified plugin Attempting to enable a plugin that is already enabled will have no effect
methenablePluginsabstractconst
void enablePlugins() const =0Enable all the loaded plugins
methdisablePluginabstract
void disablePlugin(Plugin& plugin) =0Disables the specified plugin Attempting to disable a plugin that is not enabled will have no effect
methdisablePluginsabstract
void disablePlugins() =0Disables all the loaded plugins
methclearPluginsabstract
void clearPlugins() =0Disables and removes all plugins
methcallEventabstract
void callEvent(Event& event) =0Calls an event which will be passed to plugins.
methregisterEventabstract
void registerEvent(std::string event, std::function<void(Event&)> executor, EventPriority priority, Plugin& plugin, bool ignore_cancelled) =0Registers the given event
Parameters
| Name | Type | Description |
|---|---|---|
event | std::string | Event name to register |
executor | std::function<void(Event&)> | EventExecutor to register |
priority | EventPriority | Priority of this event |
plugin | Plugin& | Plugin to register |
ignore_cancelled | bool | Do not call executor if event was already cancelled |
methgetPermissionabstractconst
Permission* getPermission(std::string name) const =0Gets a Permission from its fully qualified name
Parameters
| Name | Type | Description |
|---|---|---|
name | std::string | Name of the permission |
Returns
| Type | Description |
|---|---|
Permission* | Permission, or null if none |
methaddPermissionabstract
Permission& addPermission(std::unique_ptr<Permission> perm) =0Adds a Permission to this plugin manager.
Parameters
| Name | Type | Description |
|---|---|---|
perm | std::unique_ptr<Permission> | Permission to add |
Returns
| Type | Description |
|---|---|
Permission& | Permission, or nullptr if a permission is already defined with the given name of the new permission |
methremovePermissionabstract
void removePermission(Permission& perm) =0Removes a Permission registration from this plugin manager.
If the specified permission does not exist in this plugin manager, nothing will happen. Removing a permission registration will not remove the permission from any Permissibles that have it.
Parameters
| Name | Type | Description |
|---|---|---|
perm | Permission& | Permission to remove |
methremovePermissionabstract
void removePermission(std::string name) =0Removes a Permission registration from this plugin manager.
If the specified permission does not exist in this plugin manager, nothing will happen. Removing a permission registration will not remove the permission from any Permissibles that have it.
Parameters
| Name | Type | Description |
|---|---|---|
name | std::string | Permission to remove |
methgetDefaultPermissionsabstractconst
std::vector<Permission*> getDefaultPermissions(PermissionLevel level) const =0Gets the default permissions for the given permission level
Parameters
| Name | Type | Description |
|---|---|---|
level | PermissionLevel | Which set of default permissions to get |
Returns
| Type | Description |
|---|---|
std::vector<Permission*> | The default permissions |
methrecalculatePermissionDefaultsabstract
void recalculatePermissionDefaults(Permission& perm) =0Recalculates the defaults for the given Permission.
This will have no effect if the specified permission is not registered here.
Parameters
| Name | Type | Description |
|---|---|---|
perm | Permission& | Permission to recalculate |
methsubscribeToPermissionabstract
void subscribeToPermission(std::string permission, Permissible& permissible) =0Subscribes the given Permissible for information about the requested Permission, by name. If the specified Permission changes in any form, the Permissible will be asked to recalculate.
Parameters
| Name | Type | Description |
|---|---|---|
permission | std::string | Permission to subscribe to |
permissible | Permissible& | Permissible subscribing |
methunsubscribeFromPermissionabstract
void unsubscribeFromPermission(std::string permission, Permissible& permissible) =0Unsubscribes the given Permissible for information about the requested Permission, by name.
Parameters
| Name | Type | Description |
|---|---|---|
permission | std::string | Permission to unsubscribe from |
permissible | Permissible& | Permissible subscribing |
methgetPermissionSubscriptionsabstractconst
std::unordered_set<Permissible*> getPermissionSubscriptions(std::string permission) const =0Gets a set containing all subscribed Permissibles to the given permission, by name
Parameters
| Name | Type | Description |
|---|---|---|
permission | std::string | Permission to query for |
Returns
| Type | Description |
|---|---|
std::unordered_set<Permissible*> | Set containing all subscribed permissions |
methsubscribeToDefaultPermsabstract
void subscribeToDefaultPerms(PermissionLevel level, Permissible& permissible) =0Subscribes to the given Default permissions by permission level
If the specified defaults change in any form, the Permissible will be asked to recalculate.
Parameters
| Name | Type | Description |
|---|---|---|
level | PermissionLevel | Default list to subscribe to |
permissible | Permissible& | Permissible subscribing |
methunsubscribeFromDefaultPermsabstract
void unsubscribeFromDefaultPerms(PermissionLevel level, Permissible& permissible) =0Unsubscribes from the given Default permissions by permission level
Parameters
| Name | Type | Description |
|---|---|---|
level | PermissionLevel | Default list to unsubscribe from |
permissible | Permissible& | Permissible subscribing |
methgetDefaultPermSubscriptionsabstractconst
std::unordered_set<Permissible*> getDefaultPermSubscriptions(PermissionLevel level) const =0Gets a set containing all subscribed Permissibles to the given default list, by permission level
Parameters
| Name | Type | Description |
|---|---|---|
level | PermissionLevel | Default list to query for |
Returns
| Type | Description |
|---|---|
std::unordered_set<Permissible*> | Set containing all subscribed permissions |
methgetPermissionsabstractconst
std::unordered_set<Permission*> getPermissions() const =0Gets a set of all registered permissions.
This set is a copy and will not be modified live.
Returns
| Type | Description |
|---|---|
std::unordered_set<Permission*> | Set containing all current registered permissions |
classService
Defined in <endstone/plugin/service.h>
Bases: std::enable_shared_from_this<Service>
Services represent a list of methods.
Methods
| Name | Description |
|---|---|
~Service |
meth~Servicevirtual
~Service() =defaultclassServiceManager
Defined in <endstone/plugin/service_manager.h>
Represent a service manager that manages services and service providers.
Services are an interface specifying a list of methods that a provider must implement. Providers are implementations of these services.
Methods
| Name | Description |
|---|---|
~ServiceManager | |
registerService | Register a provider of a service. |
unregisterAll | Unregister all the services registered by a particular plugin. |
unregister | Unregister a particular provider for a particular service. |
unregister | Unregister a particular provider. |
get | Queries for a provider. This may return null if no provider has been registered for a service. The highest priority provider is returned. |
load |
meth~ServiceManagervirtual
~ServiceManager() =defaultmethregisterServiceabstract
void registerService(std::string name, std::shared_ptr<Service> provider, const Plugin& plugin, ServicePriority priority) =0Register a provider of a service.
Parameters
| Name | Type | Description |
|---|---|---|
name | std::string | service name |
provider | std::shared_ptr<Service> | service provider to register |
plugin | const Plugin& | plugin associated with the service |
priority | ServicePriority | priority of the provider |
methunregisterAllabstract
void unregisterAll(const Plugin& plugin) =0Unregister all the services registered by a particular plugin.
Parameters
| Name | Type | Description |
|---|---|---|
plugin | const Plugin& | The plugin |
methunregisterabstract
void unregister(std::string name, const Service& provider) =0Unregister a particular provider for a particular service.
Parameters
| Name | Type | Description |
|---|---|---|
name | std::string | The service name |
provider | const Service& | The service provider implementation |
methunregisterabstract
void unregister(const Service& provider) =0Unregister a particular provider.
Parameters
| Name | Type | Description |
|---|---|---|
provider | const Service& | The service provider implementation |
methgetabstractconst
std::shared_ptr<Service> get(std::string name) const =0Queries for a provider. This may return null if no provider has been registered for a service. The highest priority provider is returned.
Parameters
| Name | Type | Description |
|---|---|---|
name | std::string | The service name |
Returns
| Type | Description |
|---|---|
std::shared_ptr<Service> | provider or null |
methloadconst
std::shared_ptr<T> load(std::string name) constenumPluginLoadOrder
PluginLoadOrderRepresents the order in which a plugin should be initialized and enabled.
Values
| Name | Value | Description |
|---|---|---|
Startup | Indicates that the plugin will be loaded at startup | |
PostWorld | Indicates that the plugin will be loaded after the first/default world was created |
enumServicePriority
ServicePriorityRepresents various priorities of a provider.
Values
| Name | Value | Description |
|---|---|---|
Lowest | ||
Low | ||
Normal | ||
High | ||
Highest |