Class ApiPlugins

  • All Implemented Interfaces:
    org.pf4j.PluginManager

    
    public final class ApiPlugins
    extends JarPluginManager
                        

    Manager for ServerPackCreator plugins. In itself it doesn't do much. It gathers lists of all available extensions for TabExtension,PreGenExtension,PreZipExtension and PostGenExtension so they can then be run during server pack generation and during initialization of the GUI.

    Author:

    Griefed

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final <T extends Any> List<T> getAllExtensionsOfPlugin(PluginWrapper plugin, Class<T> type) Get all extension of the specified type for the specified plugin.
      ExtensionFactory createExtensionFactory()
      PluginFactory createPluginFactory()
      final Optional<CommentedConfig> getPluginConfig(String pluginId) Get the global plugin configuration for an plugin of the passed ID.
      final Unit runPreGenExtensions(PackConfig packConfig, String destination) Run any and all Pre-Server Pack-Generation extensions, using the passed configuration model and the destination at which the server pack is to be generated and stored at.
      final Unit runPreZipExtensions(PackConfig packConfig, String destination) Run any and all Pre-ZIP-archive creation extensions, using the passed configuration model and the destination at which the server pack is to be generated and stored at.
      final Unit runPostGenExtensions(PackConfig packConfig, String destination) Run any and all Post-server pack-generation extensions, using the passed configuration model and the destination at which the server pack is to be generated and stored at.
      final Unit addTabExtensionTabs(JTabbedPane tabbedPane) Add any and all additional tabs to the ServerPackCreator tabbed pane (main GUI).
      final List<ExtensionConfigPanel> getConfigPanels(ServerPackConfigTab serverPackConfigTab) Create config panels for the passed server pack configuration tab.
      final ConfigCheck runConfigCheckExtensions(PackConfig packConfig, ConfigCheck configCheck) Run any and all configuration-check extensions, using the passed configuration model and the destination at which the server pack is to be generated and stored at.
      final Optional<File> getPluginConfigFile(String pluginId) Get the configuration-file for a plugin, if it exists.
      • Methods inherited from class org.pf4j.AbstractPluginManager

        addPlugin, checkPluginId, checkPluginState, createExtensionFinder, createPluginDescriptorFinder, createPluginLoader, createPluginRepository, createPluginStatusProvider, createPluginWrapper, createPluginsRoot, createVersionManager, firePluginStateEvent, getExtensionClasses, getExtensionFactory, getExtensions, getPluginClassLoaders, getPluginDescriptorFinder, getPluginFactory, getPluginLabel, getPluginLabel, getPluginLoader, getPlugins, getPluginsRoot, getPluginsRoots, getResolveRecoveryStrategy, getResolvedPlugins, getRuntimeMode, getStartedPlugins, getSystemVersion, getUnresolvedPlugins, getVersion, getVersionManager, idForPath, initialize, isExactVersionAllowed, isPluginDisabled, isPluginValid, loadPluginFromPath, resolveDependencies, resolvePlugins, setExactVersionAllowed, setResolveRecoveryStrategy, setSystemVersion, stopPlugin, unloadPlugin, unloadPlugin, validatePluginDescriptor
      • Methods inherited from class org.pf4j.PluginManager

        addPluginStateListener, deletePlugin, disablePlugin, enablePlugin, getExtensionClassNames, getExtensionClasses, getExtensionClasses, getExtensionClasses, getExtensions, getExtensions, getExtensions, getPlugin, getPluginClassLoader, isDevelopment, isNotDevelopment, loadPlugin, loadPlugins, removePluginStateListener, startPlugin, startPlugins, stopPlugin, stopPlugins, unloadPlugin, unloadPlugins, whichPlugin
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ApiPlugins

        ApiPlugins(TomlParser tomlParser, ApiProperties apiProperties, VersionMeta versionMeta, Utilities utilities)
        Parameters:
        tomlParser - To read plugin-configurations, so they can be provided to extensions.
        apiProperties - ServerPackCreator settings to be provided to extensions.
        versionMeta - Version meta to be provided to extensions.
        utilities - Utilities to be provided to extensions.
    • Method Detail

      • getPluginConfig

         final Optional<CommentedConfig> getPluginConfig(String pluginId)

        Get the global plugin configuration for an plugin of the passed ID. The configuration is wrapped in an Optional, because an plugin may not provide a global configuration. If you intend on using a global configuration for your plugin, make sure to check whether it is present before trying to use it!

        Parameters:
        pluginId - The plugin ID of the...well...plugin.
        Returns:

        The global plugin configuration, wrapped in an Optional.

      • runPreGenExtensions

         final Unit runPreGenExtensions(PackConfig packConfig, String destination)

        Run any and all Pre-Server Pack-Generation extensions, using the passed configuration model and the destination at which the server pack is to be generated and stored at.

        Parameters:
        packConfig - The configuration model from which to create the server pack.
        destination - The destination at which the server pack will be generated and stored at.
      • runPreZipExtensions

         final Unit runPreZipExtensions(PackConfig packConfig, String destination)

        Run any and all Pre-ZIP-archive creation extensions, using the passed configuration model and the destination at which the server pack is to be generated and stored at.

        Parameters:
        packConfig - The configuration model from which to create the server pack.
        destination - The destination at which the server pack will be generated and stored at.
      • runPostGenExtensions

         final Unit runPostGenExtensions(PackConfig packConfig, String destination)

        Run any and all Post-server pack-generation extensions, using the passed configuration model and the destination at which the server pack is to be generated and stored at.

        Parameters:
        packConfig - The configuration model from which to create the server pack.
        destination - The destination at which the server pack will be generated and stored at.
      • addTabExtensionTabs

         final Unit addTabExtensionTabs(JTabbedPane tabbedPane)

        Add any and all additional tabs to the ServerPackCreator tabbed pane (main GUI). You may use this to add tabs to your own JTabbedPane, if you so desire. Could be pretty awesome to have your plugins extra tabs in a separate window!

        Parameters:
        tabbedPane - The tabbed pane to which the additional panels should be added to as tabs.
      • getConfigPanels

         final List<ExtensionConfigPanel> getConfigPanels(ServerPackConfigTab serverPackConfigTab)

        Create config panels for the passed server pack configuration tab. Note that this method does NOT add the panels to the tab, it only creates them and passes the server pack config tab object-reference to each config panel, so they, in turn, may use any available fields and methods for their own operations. A given server pack config tab needs to add the panels which are returned by this method, so a user may make their configurations accordingly.

        Parameters:
        serverPackConfigTab - The server pack configuration tab to which the config panels are to be added.
        Returns:

        A list of config panels specifically created for the passed server pack configuration-tab.

      • runConfigCheckExtensions

         final ConfigCheck runConfigCheckExtensions(PackConfig packConfig, ConfigCheck configCheck)

        Run any and all configuration-check extensions, using the passed configuration model and the destination at which the server pack is to be generated and stored at.

        Parameters:
        packConfig - The configuration model containing the server pack and plugin configurations to check.
        configCheck - Collection of encountered errors, if any, for convenient result-checks.
        Returns:

        true if any custom check detected an error with the configuration. Only return false when not a single check errored.

      • getPluginConfigFile

         final Optional<File> getPluginConfigFile(String pluginId)

        Get the configuration-file for a plugin, if it exists. This is wrapped in an Optional, because not every plugin may provide a configuration-file to use globally for the relevant plugins settings. If you intend on using a global configuration, make sure to check whether the file is present, before moving on!

        Parameters:
        pluginId - The plugin ID with which to identify the correct config-file to return.
        Returns:

        The config-file corresponding to the ID of the plugin, wrapped in an Optional.