Interface PluginContext
public interface PluginContext
Everything a plugin receives from the server, handed over in
Plugin.onLoad(PluginContext).- Since:
- 0.1.0
-
Method Summary
Modifier and TypeMethodDescriptionGets the folder reserved for this plugin's files,plugins/<id>, creating it when missing.events()Gets the event bus bound to this plugin.logger()Returns the logger of this plugin, namedplugin/<id>.meta()Returns the metadata read from the plugin'sfidorial.json.Opens a resource bundled inside this plugin's jar, relative to the jar root.server()Returns the running server.services()Gets the service registry.
-
Method Details
-
meta
PluginMeta meta()Returns the metadata read from the plugin'sfidorial.json.- Returns:
- the metadata read from the plugin's
fidorial.json - Since:
- 0.1.0
-
server
-
events
EventBus events()Gets the event bus bound to this plugin.Every subscription made through it belongs to the plugin and is released when the plugin is disabled, whatever the thread it was made from.
- Returns:
- the plugin-bound event bus
- Since:
- 0.1.0
-
services
ServiceRegistry services()Gets the service registry.Pass the
Plugininstance as the owner of what you register, so it is released when the plugin is disabled.- Returns:
- the service registry
- Since:
- 0.1.0
-
logger
ComponentLogger logger()Returns the logger of this plugin, namedplugin/<id>.- Returns:
- the logger of this plugin, named
plugin/<id> - Since:
- 0.1.0
-
dataFolder
Path dataFolder()Gets the folder reserved for this plugin's files,plugins/<id>, creating it when missing.- Returns:
- the data folder
- Throws:
UncheckedIOException- if the folder cannot be created- Since:
- 0.1.0
-
resource
Opens a resource bundled inside this plugin's jar, relative to the jar root.- Parameters:
path- path to the resource, relative to the jar root- Returns:
- an input stream for the resource, or
nullif no entry exists at that path - Since:
- 0.1.0
- API Note:
- The caller owns the returned stream and is responsible for closing it, typically via try-with-resources
-