HhmRoomObject

Extends the RoomObject provided by the native Haxball API.

Description

Extends the RoomObject provided by the native Haxball API.

Members


_plugins :Object.<Number, external:haxball-room-trapper.TrappedRoom>

Maps plugin IDs to trapped room instances.

Description

Maps plugin IDs to trapped room instances.

Details

_pluginsDisabled :Array.<Number>

Array of disabled plugin IDs.

Description

Array of disabled plugin IDs.

Details
Array.<Number>

_pluginIds :Object.<String, Number>

Maps plugin names to plugin IDs.

Description

Maps plugin names to plugin IDs.

Details
Object.<String, Number>

_pluginManager :PluginManager

Associated plugin manager.

Description

Associated plugin manager.

Details

Methods


addEventStateValidator( handlerNames, validator ) → {HhmRoomObject}

Add an event state validator function for the given handler names.

Description

Add an event state validator function for the given handler names.

Parameters
Name Type Description
handlerNames string | Array.<string>

Event handler names.

validator function

Validator function.

Returns

Fluent interface.

Details

TrappedRoomManager.addEventStateValidator


addPostEventHandlerHook( handlerNames, hook ) → {HhmRoomObject}

Add a hook for the given handler name that is executed after plugin event handlers.

Description

Add a hook for the given handler name that is executed after plugin event handlers.

Parameters
Name Type Description
handlerNames string

Event handler name.

hook function

Hook function.

Returns

Fluent interface.


addPreEventHandlerHook( handlerNames, hook ) → {HhmRoomObject}

Add a hook for the given handler name that is executed before plugin event handlers.

Description

Add a hook for the given handler name that is executed before plugin event handlers.

Parameters
Name Type Description
handlerNames string | Array.<string>

Event handler name(s).

hook function

Hook function.

Returns

Fluent interface.

Details

TrappedRoomManager#addPreEventHandlerHook


extend( name, element ) → {boolean}

Extends the global room object with an attribute or function.

Description

Extends the global room object with an attribute or function.

Please use very sparingly, this is primarily meant for workarounds or functions that should be part of the room API but aren't (yet).

If you try to pass a non-function and the room already had an attribute with the same name, the extension will fail and false will be returned.

The plugin room and previously defined function (if any) are passed in a destructuring first argument.

Parameters
Name Type Description
name string

Name of the room property that is being added or extended.

element function | *

New value for the given property, either a Function (extension will never fail) or any other type (extension will fail if property exists).

Returns

true if the extension was successful, false if not

Details

getConfig( [ paramName ] ) → {Object|undefined|*}

Returns the configuration of this plugin.

Description

Returns the configuration of this plugin.

If no parameter name is given, the whole config object is returned.

Parameters
Name Type Attributes Description
paramName string <optional>

Configuration parameter name. If undefined, complete config is returned.

Returns

Configuration object or value of the given configuration parameter or undefined if no such configuration parameter exists.

Details

getHandlerNames() → {Array.<string>}

Returns the handler names specific to this plugin.

Description

Returns the handler names specific to this plugin.

Returns

Handler names for this plugin.


getId() → {number}

Returns the plugin ID.

Description

Returns the plugin ID.

Returns

Plugin ID.

Details

getName() → {string}

Returns the name of the plugin, or the ID if the plugin has no name.

Description

Returns the name of the plugin, or the ID if the plugin has no name.

Returns

Plugin name or ID (as a string) if the plugin has no name.

Details

<static> getParentRoom() → {external:native-api.RoomObject}

Returns the parent room object.

Description

Returns the parent room object.

Returns

Parent room object, in most cases this is the native headless API room object.

Details

<static> getPlugin( [ pluginName [, create ] ] ) → {external:haxball-room-trapper.TrappedRoom|undefined}

Returns the trapped room for the given plugin.

Description

Returns the trapped room for the given plugin.

Parameters
Name Type Attributes Description
pluginName string <optional>

Name of the plugin or undefined to create new plugin.

create boolean <optional>

true if a new plugin should be created if it does not exist. If no pluginName was given, this parameter is ignored and a new plugin is created.

Returns

Plugin room proxy or undefined if the plugin was not found and create is false.


<static> getPluginManager() → {PluginManager}

Returns the associated plugin manager.

Description

Returns the associated plugin manager.

Returns

Associated plugin manager.

Details

getPluginSpec() → {external:haxball-room-trapper.TrappedRoom.pluginSpec}

Returns the plugin specification for this plugin.

Description

Returns the plugin specification for this plugin.

Details

getPropertyNames() → {Array.<string>}

Returns the property names specific to this plugin.

Description

Returns the property names specific to this plugin.

Returns

Plugin-specific property names.


getSourceCode() → {string}

Returns the plugin source code.

Description

Returns the plugin source code.

Returns

Plugin source code.

Details

getSourceHash() → {number}

Returns the hash of the plugin source code.

Description

Returns the hash of the plugin source code.

Returns

32-bit positive integer hash

Details

hasName() → {boolean}

Returns whether this plugin has a name.

Description

Returns whether this plugin has a name.

Returns

Whether the plugin has a name.

Details

<static> hasPlugin() → {boolean}

Returns whether a valid plugin with the given name exists.

Description

Returns whether a valid plugin with the given name exists.

Returns

Whether a valid plugin with the given name exists.


isEnabled() → {boolean}

Returns whether this plugin is enabled.

Description

Returns whether this plugin is enabled.

A plugin can only be enabled once it has been fully loaded.

Returns

Whether this plugin is enabled.

Details

isLoaded() → {boolean}

Returns whether the plugin has been fully loaded.

Description

Returns whether the plugin has been fully loaded.

A plugin is loaded when all of its dependencies have been loaded and its onRoomLink handler has been executed.

Returns

Whether the plugin has been fully loaded.

Details

log( message, level )

Convenience logging function which will include the plugin name.

Description

Convenience logging function which will include the plugin name.

Will not log to the room, but only to the browser console.

Parameters
Name Type Description
message string

Message to be logged.

level string

Log level.

Details

setConfig( [ paramName [, value ] ] )

Sets the given configuration parameter to the given value.

Description

Sets the given configuration parameter to the given value.

If no parameter name was given, an event will be triggered that the configuration was changed.

If an object is passed as the paramName, the whole config will be overwritten and an event will be triggered.

Parameters
Name Type Attributes Description
paramName string <optional>

Name of the configuration parameter.

value * <optional>

New value of the configuration parameter.


setName( name )

Sets a new name for this plugin.

Description

Sets a new name for this plugin.

Parameters
Name Type Description
name string

New plugin name.

Details

<static> triggerEvent( eventHandlerName, ...args ) → {boolean}

Triggers an event with the given name and arguments.

Description

Triggers an event with the given name and arguments.

Parameters
Name Type Attributes Description
eventHandlerName string

Name of the event handler to be triggered.

args * <repeatable>

Event arguments.

Returns

false if one of the event handlers returned false, true otherwise.