Interface PluginManager


public interface PluginManager
Manages loading and retrieving plugins.
  • Method Details

    • getPlugin

      @Nonnull Optional<PluginContainer> getPlugin(@Nonnull String id)
      Get a plugin by its ID.
      Parameters:
      id - the plugin ID
      Returns:
      the plugin container, or empty if not found
    • fromInstance

      @Nonnull Optional<PluginContainer> fromInstance(@Nonnull Object instance)
      Get a plugin container from a plugin instance.

      This is useful when you have a reference to a plugin's main class instance and need to get its container metadata.

      Parameters:
      instance - the plugin instance
      Returns:
      the plugin container, or empty if not found
    • getPlugins

      @Nonnull Collection<PluginContainer> getPlugins()
      Get all loaded plugins.
      Returns:
      an unmodifiable collection of all plugins
    • isLoaded

      boolean isLoaded(@Nonnull String id)
      Check if a plugin is loaded.
      Parameters:
      id - the plugin ID
      Returns:
      true if the plugin is loaded
    • getPluginsDirectory

      @Nonnull Path getPluginsDirectory()
      Get the plugin directory where plugins are loaded from.
      Returns:
      the plugins directory
    • addPluginPath

      void addPluginPath(@Nonnull Path path)
      Add a path to scan for plugins.
      Parameters:
      path - the path to add
    • addToClasspath

      void addToClasspath(@Nonnull Object plugin, @Nonnull Path file)
      Add a JAR file to a plugin's classpath at runtime.

      This allows plugins to dynamically load additional dependencies after initialization, such as database drivers or other libraries.

      Parameters:
      plugin - the plugin instance requesting the classpath addition
      file - the path to the JAR file to add