endstone/plugin

Classes

NameDescription
PluginRepresents a Plugin.
PluginDescriptionRepresents the basic information about a plugin that the plugin loader needs to know.
PluginLoaderRepresents a plugin loader, which handles direct access to specific types of plugins.
PluginManagerRepresents a plugin manager that handles all plugins from the Server.
ServiceServices represent a list of methods.
ServiceManagerRepresent a service manager that manages services and service providers.

Enums

NameDescription
PluginLoadOrderRepresents the order in which a plugin should be initialized and enabled.
ServicePriorityRepresents various priorities of a provider.

classPlugin

Defined in <endstone/plugin/plugin.h>

Bases: CommandExecutor

Represents a Plugin.

Methods

NameDescription
Plugin
Plugin
operator=
~Plugin
getDescriptionReturns the details of this plugin.
onLoadCalled after a plugin is loaded but before it has been enabled.
onEnableCalled when this plugin is enabled.
onDisableCalled when this plugin is disabled.
getLoggerReturns the plugin logger associated with this server's logger. The returned logger automatically tags all log messages with the plugin's name.
isEnabledReturns a value indicating whether this plugin is currently enabled.
getPluginLoaderGets the associated PluginLoader responsible for this plugin.
getServerReturns the Server instance currently running this plugin.
getNameReturns the name of the plugin.
getCommandGets the command with the given name, specific to this plugin.
getDataFolderReturns the folder that the plugin data's files are located in. The folder may not yet exist.
registerEvent
registerEvent
setEnabled

methPlugin

Plugin() =default

methPlugin

Plugin(const Plugin&) =delete

methoperator=

Plugin& operator=(const Plugin&) =delete

meth~Plugin

~Plugin() override=default

methgetDescriptionabstractconst

const PluginDescription& getDescription() const =0

Returns the details of this plugin.

Returns

TypeDescription
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() const

Returns the plugin logger associated with this server's logger. The returned logger automatically tags all log messages with the plugin's name.

Returns

TypeDescription
Logger&Logger associated with this plugin

methisEnabledconst

bool isEnabled() const

Returns a value indicating whether this plugin is currently enabled.

Returns

TypeDescription
booltrue if this plugin is enabled, otherwise false

methgetPluginLoaderconst

PluginLoader& getPluginLoader() const

Gets the associated PluginLoader responsible for this plugin.

Returns

TypeDescription
PluginLoader&PluginLoader that controls this plugin

methgetServerconst

Server& getServer() const

Returns the Server instance currently running this plugin.

Returns

TypeDescription
Server&Server running this plugin

methgetNameconst

std::string getName() const

Returns the name of the plugin.

This should return the bare name of the plugin and should be used for comparison.

Returns

TypeDescription
std::stringname of the plugin

methgetCommandconst

PluginCommand* getCommand(std::string name) const

Gets the command with the given name, specific to this plugin.

Parameters

NameTypeDescription
namestd::stringname or alias of the command

Returns

TypeDescription
PluginCommand*the plugin command if found, otherwise null

methgetDataFolderconst

const std::filesystem::path& getDataFolder() const

Returns the folder that the plugin data's files are located in. The folder may not yet exist.

Returns

TypeDescription
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

NameTypeDescription
enabledbooltrue 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() const

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

Returns

TypeDescription
std::stringthe name of the plugin

methgetVersionconst

std::string getVersion() const

Gives the version of the plugin.

Returns

TypeDescription
std::stringthe version of the plugin

methgetFullNameconst

std::string getFullName() const

Returns the name of a plugin, including the version.

Returns

TypeDescription
std::stringa descriptive name of the plugin and respective version

methgetAPIVersionconst

std::string getAPIVersion() const

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

Returns

TypeDescription
std::stringthe API version supported by the plugin

methgetDescriptionconst

std::string getDescription() const

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

Returns

TypeDescription
std::stringdescription of this plugin, or empty if not specified

methgetLoadconst

PluginLoadOrder getLoad() const

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

Returns

TypeDescription
PluginLoadOrderthe phase when the plugin should be loaded

methgetAuthorsconst

std::vector<std::string> getAuthors() const

Gives the list of authors for the plugin.

Returns

TypeDescription
std::vector<std::string>an immutable list of the plugin's authors

methgetContributorsconst

std::vector<std::string> getContributors() const

Gives the list of contributors for the plugin.

Returns

TypeDescription
std::vector<std::string>an immutable list of the plugin's contributions

methgetWebsiteconst

std::string getWebsite() const

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

Returns

TypeDescription
std::stringthe website of this plugin, or empty if not specified

methgetPrefixconst

std::string getPrefix() const

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

Returns

TypeDescription
std::stringthe prefixed logging token, or empty if not specified

methgetProvidesconst

std::vector<std::string> getProvides() const

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

Returns

TypeDescription
std::vector<std::string>immutable list of the plugin APIs which this plugin provides

methgetDependconst

std::vector<std::string> getDepend() const

Gives a list of other plugins that the plugin requires.

Returns

TypeDescription
std::vector<std::string>immutable list of the plugin's dependencies

methgetSoftDependconst

std::vector<std::string> getSoftDepend() const

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

Returns

TypeDescription
std::vector<std::string>immutable list of the plugin's preferred dependencies

methgetLoadBeforeconst

std::vector<std::string> getLoadBefore() const

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

Returns

TypeDescription
std::vector<std::string>immutable list of plugins that should consider this plugin a soft-dependency

methgetDefaultPermissionconst

PermissionDefault getDefaultPermission() const

Gives the default value of permissions registered for the plugin.

Returns

TypeDescription
PermissionDefaultthe default value for the plugin's permissions

methgetCommandsconst

std::vector<Command> getCommands() const

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

Returns

TypeDescription
std::vector<Command>the commands this plugin will register

methgetPermissionsconst

std::vector<Permission> getPermissions() const

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

Returns

TypeDescription
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

NameDescription
server_

Methods

NameDescription
PluginLoader
PluginLoader
operator=
~PluginLoader
loadPlugin
loadPluginsLoads the plugin contained within the specified directory.
getPluginFileFiltersReturns a list of all filename filters expected by this PluginLoader.
enablePluginEnables the specified plugin Attempting to enable a plugin that is already enabled will have no effect.
disablePluginDisables the specified plugin Attempting to disable a plugin that is not enabled will have no effect.
getServerRetrieves the Server object associated with the PluginLoader.

varserver_protected

Server& server_

methPluginLoaderexplicit

PluginLoader(Server& server)

methPluginLoader

PluginLoader(const PluginLoader&) =delete

methoperator=

PluginLoader& operator=(const PluginLoader&) =delete

meth~PluginLoadervirtual

~PluginLoader() =default

methloadPluginabstract

Plugin* loadPlugin(std::string file) =0

Loads the plugin contained in the specified file

Parameters

NameTypeDescription
filestd::stringFile to attempt to load

Returns

TypeDescription
Plugin*Plugin that was contained in the specified file, or nullptr if unsuccessful

methloadPluginsvirtual

std::vector<Plugin*> loadPlugins(std::string directory)

Loads the plugin contained within the specified directory.

Parameters

NameTypeDescription
directorystd::stringDirectory to check for plugins

Returns

TypeDescription
std::vector<Plugin*>A list of all plugins loaded

methgetPluginFileFiltersabstractconst

std::vector<std::string> getPluginFileFilters() const =0

Returns a list of all filename filters expected by this PluginLoader.

Returns

TypeDescription
std::vector<std::string>The filters

methenablePluginvirtualconst

void enablePlugin(Plugin& plugin) const

Enables the specified plugin Attempting to enable a plugin that is already enabled will have no effect.

Parameters

NameTypeDescription
pluginPlugin&Plugin to enable

methdisablePluginvirtualconst

void disablePlugin(Plugin& plugin) const

Disables the specified plugin Attempting to disable a plugin that is not enabled will have no effect.

Parameters

NameTypeDescription
pluginPlugin&Plugin to disable

methgetServerconst

Server& getServer() const

Retrieves the Server object associated with the PluginLoader.

This function returns a reference to the Server object that the PluginLoader is associated with.

Returns

TypeDescription
Server&The Server reference.

classPluginManager

Defined in <endstone/plugin/plugin_manager.h>

Represents a plugin manager that handles all plugins from the Server.

Methods

methPluginManager

PluginManager() =default

methPluginManager

PluginManager(PluginManager const&) =delete

methoperator=

PluginManager& operator=(PluginManager const&) =delete

meth~PluginManagervirtual

~PluginManager() =default

methregisterLoaderabstract

void registerLoader(std::unique_ptr<PluginLoader> loader) =0

Registers the specified plugin loader

Parameters

NameTypeDescription
loaderstd::unique_ptr<PluginLoader>PluginLoader to register

methgetPluginabstractconst

Plugin* getPlugin(const std::string& name) const =0

Checks if the given plugin is loaded and returns it when applicable. Please note that the name of the plugin is case-sensitive

Parameters

NameTypeDescription
nameconst std::string&Name of the plugin to check

Returns

TypeDescription
Plugin*Plugin if it exists, otherwise nullptr

methgetPluginsabstractconst

std::vector<Plugin*> getPlugins() const =0

Gets a list of all currently loaded plugins

Returns

TypeDescription
std::vector<Plugin*>List of Plugins

methisPluginEnabledabstractconst

bool isPluginEnabled(const std::string& name) const =0

Checks if the given plugin is enabled or not Please note that the name of the plugin is case-sensitive.

Parameters

NameTypeDescription
nameconst std::string&Name of the plugin to check

Returns

TypeDescription
booltrue if the plugin is enabled, otherwise false

methisPluginEnabledabstractconst

bool isPluginEnabled(Plugin* plugin) const =0

Checks if the given plugin is enabled or not

Parameters

NameTypeDescription
pluginPlugin*Plugin to check

Returns

TypeDescription
booltrue if the plugin is enabled, otherwise false

methloadPluginabstract

Plugin* loadPlugin(std::string file) =0

Loads the plugin in the specified file

File must be valid according to the current enabled Plugin interfaces

Parameters

NameTypeDescription
filestd::stringFile containing the plugin to load

Returns

TypeDescription
Plugin*The Plugin loaded, or nullptr if it was invalid

methloadPluginsabstract

std::vector<Plugin*> loadPlugins(std::string directory) =0

Loads the plugin contained within the specified directory

Parameters

NameTypeDescription
directorystd::stringDirectory to check for plugins

Returns

TypeDescription
std::vector<Plugin*>A list of all plugins loaded

methloadPluginsabstract

std::vector<Plugin*> loadPlugins(std::vector<std::string> files) =0

Loads the plugins in the list of the files

Parameters

NameTypeDescription
filesstd::vector<std::string>List of files containing plugins to load

Returns

TypeDescription
std::vector<Plugin*>A list of all plugins loaded

methenablePluginabstractconst

void enablePlugin(Plugin& plugin) const =0

Enables the specified plugin Attempting to enable a plugin that is already enabled will have no effect

Parameters

NameTypeDescription
pluginPlugin&Plugin to enable

methenablePluginsabstractconst

void enablePlugins() const =0

Enable all the loaded plugins

methdisablePluginabstract

void disablePlugin(Plugin& plugin) =0

Disables the specified plugin Attempting to disable a plugin that is not enabled will have no effect

Parameters

NameTypeDescription
pluginPlugin&Plugin to disable

methdisablePluginsabstract

void disablePlugins() =0

Disables all the loaded plugins

methclearPluginsabstract

void clearPlugins() =0

Disables and removes all plugins

methcallEventabstract

void callEvent(Event& event) =0

Calls an event which will be passed to plugins.

Parameters

NameTypeDescription
eventEvent&Event to be called

methregisterEventabstract

void registerEvent(std::string event, std::function<void(Event&)> executor, EventPriority priority, Plugin& plugin, bool ignore_cancelled) =0

Registers the given event

Parameters

NameTypeDescription
eventstd::stringEvent name to register
executorstd::function<void(Event&)>EventExecutor to register
priorityEventPriorityPriority of this event
pluginPlugin&Plugin to register
ignore_cancelledboolDo not call executor if event was already cancelled

methgetPermissionabstractconst

Permission* getPermission(std::string name) const =0

Gets a Permission from its fully qualified name

Parameters

NameTypeDescription
namestd::stringName of the permission

Returns

TypeDescription
Permission*Permission, or null if none

methaddPermissionabstract

Permission& addPermission(std::unique_ptr<Permission> perm) =0

Adds a Permission to this plugin manager.

Parameters

NameTypeDescription
permstd::unique_ptr<Permission>Permission to add

Returns

TypeDescription
Permission&Permission, or nullptr if a permission is already defined with the given name of the new permission

methremovePermissionabstract

void removePermission(Permission& perm) =0

Removes 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

NameTypeDescription
permPermission&Permission to remove

methremovePermissionabstract

void removePermission(std::string name) =0

Removes 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

NameTypeDescription
namestd::stringPermission to remove

methgetDefaultPermissionsabstractconst

std::vector<Permission*> getDefaultPermissions(PermissionLevel level) const =0

Gets the default permissions for the given permission level

Parameters

NameTypeDescription
levelPermissionLevelWhich set of default permissions to get

Returns

TypeDescription
std::vector<Permission*>The default permissions

methrecalculatePermissionDefaultsabstract

void recalculatePermissionDefaults(Permission& perm) =0

Recalculates the defaults for the given Permission.

This will have no effect if the specified permission is not registered here.

Parameters

NameTypeDescription
permPermission&Permission to recalculate

methsubscribeToPermissionabstract

void subscribeToPermission(std::string permission, Permissible& permissible) =0

Subscribes 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

NameTypeDescription
permissionstd::stringPermission to subscribe to
permissiblePermissible&Permissible subscribing

methunsubscribeFromPermissionabstract

void unsubscribeFromPermission(std::string permission, Permissible& permissible) =0

Unsubscribes the given Permissible for information about the requested Permission, by name.

Parameters

NameTypeDescription
permissionstd::stringPermission to unsubscribe from
permissiblePermissible&Permissible subscribing

methgetPermissionSubscriptionsabstractconst

std::unordered_set<Permissible*> getPermissionSubscriptions(std::string permission) const =0

Gets a set containing all subscribed Permissibles to the given permission, by name

Parameters

NameTypeDescription
permissionstd::stringPermission to query for

Returns

TypeDescription
std::unordered_set<Permissible*>Set containing all subscribed permissions

methsubscribeToDefaultPermsabstract

void subscribeToDefaultPerms(PermissionLevel level, Permissible& permissible) =0

Subscribes to the given Default permissions by permission level

If the specified defaults change in any form, the Permissible will be asked to recalculate.

Parameters

NameTypeDescription
levelPermissionLevelDefault list to subscribe to
permissiblePermissible&Permissible subscribing

methunsubscribeFromDefaultPermsabstract

void unsubscribeFromDefaultPerms(PermissionLevel level, Permissible& permissible) =0

Unsubscribes from the given Default permissions by permission level

Parameters

NameTypeDescription
levelPermissionLevelDefault list to unsubscribe from
permissiblePermissible&Permissible subscribing

methgetDefaultPermSubscriptionsabstractconst

std::unordered_set<Permissible*> getDefaultPermSubscriptions(PermissionLevel level) const =0

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

Parameters

NameTypeDescription
levelPermissionLevelDefault list to query for

Returns

TypeDescription
std::unordered_set<Permissible*>Set containing all subscribed permissions

methgetPermissionsabstractconst

std::unordered_set<Permission*> getPermissions() const =0

Gets a set of all registered permissions.

This set is a copy and will not be modified live.

Returns

TypeDescription
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

NameDescription
~Service

meth~Servicevirtual

~Service() =default

classServiceManager

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

NameDescription
~ServiceManager
registerServiceRegister a provider of a service.
unregisterAllUnregister all the services registered by a particular plugin.
unregisterUnregister a particular provider for a particular service.
unregisterUnregister a particular provider.
getQueries 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() =default

methregisterServiceabstract

void registerService(std::string name, std::shared_ptr<Service> provider, const Plugin& plugin, ServicePriority priority) =0

Register a provider of a service.

Parameters

NameTypeDescription
namestd::stringservice name
providerstd::shared_ptr<Service>service provider to register
pluginconst Plugin&plugin associated with the service
priorityServicePrioritypriority of the provider

methunregisterAllabstract

void unregisterAll(const Plugin& plugin) =0

Unregister all the services registered by a particular plugin.

Parameters

NameTypeDescription
pluginconst Plugin&The plugin

methunregisterabstract

void unregister(std::string name, const Service& provider) =0

Unregister a particular provider for a particular service.

Parameters

NameTypeDescription
namestd::stringThe service name
providerconst Service&The service provider implementation

methunregisterabstract

void unregister(const Service& provider) =0

Unregister a particular provider.

Parameters

NameTypeDescription
providerconst Service&The service provider implementation

methgetabstractconst

std::shared_ptr<Service> get(std::string name) const =0

Queries for a provider. This may return null if no provider has been registered for a service. The highest priority provider is returned.

Parameters

NameTypeDescription
namestd::stringThe service name

Returns

TypeDescription
std::shared_ptr<Service>provider or null

methloadconst

std::shared_ptr<T> load(std::string name) const

enumPluginLoadOrder

PluginLoadOrder

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

Values

NameValueDescription
StartupIndicates that the plugin will be loaded at startup
PostWorldIndicates that the plugin will be loaded after the first/default world was created

enumServicePriority

ServicePriority

Represents various priorities of a provider.

Values

NameValueDescription
Lowest
Low
Normal
High
Highest

On this page

classPluginmethPluginmethPluginmethoperator=meth~PluginmethgetDescriptionmethonLoadmethonEnablemethonDisablemethgetLoggermethisEnabledmethgetPluginLoadermethgetServermethgetNamemethgetCommandmethgetDataFoldermethregisterEventmethregisterEventmethsetEnabledclassPluginDescriptionmethPluginDescriptionmethgetNamemethgetVersionmethgetFullNamemethgetAPIVersionmethgetDescriptionmethgetLoadmethgetAuthorsmethgetContributorsmethgetWebsitemethgetPrefixmethgetProvidesmethgetDependmethgetSoftDependmethgetLoadBeforemethgetDefaultPermissionmethgetCommandsmethgetPermissionsclassPluginLoadervarserver_methPluginLoadermethPluginLoadermethoperator=meth~PluginLoadermethloadPluginmethloadPluginsmethgetPluginFileFiltersmethenablePluginmethdisablePluginmethgetServerclassPluginManagermethPluginManagermethPluginManagermethoperator=meth~PluginManagermethregisterLoadermethgetPluginmethgetPluginsmethisPluginEnabledmethisPluginEnabledmethloadPluginmethloadPluginsmethloadPluginsmethenablePluginmethenablePluginsmethdisablePluginmethdisablePluginsmethclearPluginsmethcallEventmethregisterEventmethgetPermissionmethaddPermissionmethremovePermissionmethremovePermissionmethgetDefaultPermissionsmethrecalculatePermissionDefaultsmethsubscribeToPermissionmethunsubscribeFromPermissionmethgetPermissionSubscriptionsmethsubscribeToDefaultPermsmethunsubscribeFromDefaultPermsmethgetDefaultPermSubscriptionsmethgetPermissionsclassServicemeth~ServiceclassServiceManagermeth~ServiceManagermethregisterServicemethunregisterAllmethunregistermethunregistermethgetmethloadenumPluginLoadOrderenumServicePriority