Interface PluginContext


public interface PluginContext
Everything a plugin receives from the server, handed over in Plugin.onLoad(PluginContext).
Since:
0.1.0
  • Method Details

    • meta

      PluginMeta meta()
      Returns the metadata read from the plugin's fidorial.json.
      Returns:
      the metadata read from the plugin's fidorial.json
      Since:
      0.1.0
    • server

      Server server()
      Returns the running server.
      Returns:
      the running server
      Since:
      0.1.0
    • 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 Plugin instance 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, named plugin/<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

      @Nullable InputStream resource(String path)
      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 null if 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