new PluginController()

Description

Class for controlling Haxball Headless Manager (HHM) plugins.

Methods


<async> getPlugins() → {Promise.<Array.<PluginData>>}

Description

Returns loaded plugins.

Returns
  • Array of plugins.

<async> getPlugin( name ) → {Promise.<?PluginData>}

Description

Returns PluginData of the given plugin name.

Parameters
Name Type Description
name string

Name of the plugin.

Returns
  • Data of the plugin or null if plugin was not found.

<async> enablePlugin( name ) → {Promise.<boolean>}

Description

Enables a HHM plugin with the given name.

Parameters
Name Type Description
name string

Name of the plugin

Returns
  • true if plugin was enabled, false otherwise.

<async> disablePlugin( name [, recursive ] ) → {Promise.<Array.<number>>}

Description

Disables a HHM plugin with the given name.

If the name is an Array then it disables all the plugins in the given order.

Parameters
Name Type Attributes Default Description
name string

Name the plugin.

recursive boolean <optional>
false

If true all the plugins that depend on the plugin will get disabled also.

Returns
  • Array of disabled plugin IDs or empty array if the plugin could not be disabled or was already disabled.

<async> getPluginsThatDependOn( name [, recursive [, includeDisabled ] ] ) → {Promise.<Array.<PluginData>>}

Description

Gets a list of plugins that depend on the given plugin.

Parameters
Name Type Attributes Default Description
name string

Name or id of the plugin.

recursive boolean <optional>
true

Finds indirect dependencies also.

includeDisabled boolean <optional>
false

Include disabled plugins

Returns
  • Array of plugins.

<async> hasPlugin( name ) → {Promise.<boolean>}

Description

Checks if the room has a plugin with given name loaded.

Parameters
Name Type Description
name string

Name of the plugin.

Returns
  • true if it had the plugin, false if not.

<async> addPlugin( plugin [, pluginConfig ] ) → {Promise.<number>}

Description

Adds a new plugin.

If the plugin is string, then it will be loaded from the available repositories.

If the plugin is Plugin, then it will be loaded from contents of Plugin.

Parameters
Name Type Attributes Description
plugin string | Plugin

Plugins name if loading from repositories or plugin definition if loading it from an object.

pluginConfig object <optional>

Configuration options for the plugin.

Returns
  • Plugin ID if the plugin and all of its dependencies have been loaded, -1 otherwise.

<async> removePlugin( pluginName [, safe ] ) → {Promise.<boolean>}

Description

Removes a plugin.

Parameters
Name Type Attributes Default Description
pluginName string

Plugins name.

safe boolean <optional>
true

Remove plugin safely (see HHM PluginManager#removePlugin).

Returns
  • Whether the removal was successful.

<async> setPluginConfig( pluginConfig [, pluginName ] )

Description

Sets the rooms plugin config. Merges the new config with the old one.

Tries to load plugins that are not loaded from the available repositories and removes the loaded plugins that are not in the given config.

If pluginName is given then only config for the given plugin is set.

Parameters
Name Type Attributes Description
pluginConfig object

Room wide config or plugins config.

pluginName string <optional>

Name of the plugin if wanting to change config of only one plugin.


<async> getPluginConfig( [ pluginName ] ) → {Promise.<object>}

Description

Returns the plugin config for all loaded plugins in the room or if pluginName is given, then return the config for that plugin.

Parameters
Name Type Attributes Description
pluginName string <optional>

The name of the plugin.

Returns
  • The config object of plugin(s).

<async> reloadPlugin( pluginName [, safe ] ) → {boolean}

Description

Reloads a plugin from the configured repositories.

This is a wrapper around the HHM PluginManager.reloadPlugin method. See https://github.com/saviola777/haxball-headless-manager/blob/master/src/classes/PluginManager.js#L565

Parameters
Name Type Attributes Default Description
pluginName string

Plugin name to be reloaded.

safe boolean <optional>
true

Whether to disable dependent plugins before unloading the given plugin.

Returns

Whether the plugin was successfully reloaded

Throws

If the given plugin is not loaded or if safe mode was enabled but the plugin can't be disabled.