Static
generateGenerate a random plugin ID.
Note that this will return one even if it is taken, see generateRandomPluginIdSafe if you need one that is not taken.
A random plugin ID.
Static
isCheck whether some object is a Hindenburg plugin.
Whether someObject is a Hindenburg plugin.
console.log(this.worker.pluginLoader.isHindenburgPlugin({})); // false
class MyPlugin extends WorkerPlugin {}
console.log(this.worker.pluginLoader.isHindenburgPlugin(MyPlugin)); // true
The object to check.
Static
isCheck whether an imported Hindenburg plugin is a room plugin to be loaded into rooms, extending RoomPlugin.
Whether pluginCtr is a room plugin.
.@HindenburgPlugin("hbplugin-fun-things")
class MyPlugin extends RoomPlugin {}
console.log(this.worker.pluginLoad.isRoomPlugin(MyPlugin)); // true
.@HindenburgPlugin("hbplugin-fun-things")
class MyPlugin extends WorkerPlugin {}
console.log(this.worker.pluginLoad.isRoomPlugin(MyPlugin)); // false
The plugin to check.
Static
isCheck whether an imported Hindenburg plugin is a worker plugin to be loaded globally, extending WorkerPlugin.
Whether pluginCtr is a global worker plugin.
.@HindenburgPlugin("hbplugin-fun-things")
class MyPlugin extends RoomPlugin {}
console.log(this.worker.pluginLoad.isWorkerPlugin(MyPlugin)); // false
.@HindenburgPlugin("hbplugin-fun-things")
class MyPlugin extends WorkerPlugin {}
console.log(this.worker.pluginLoad.isWorkerPlugin(MyPlugin)); // true
The plugin to check.
Import all plugins from the pluginDirectories, from both installed NPM plugins and local plugin folders.
Does not load any of the plugins into the worker or a room, see loadAllWorkerPlugins and loadAllRoomPlugins.
A map of all plugins that were imported.
const importedPlugins = this.worker.pluginDirectory.importFromDirectory();
console.log("Imported %s plugins!", importedPlugins.size);
Import a plugin via its ID, checking both installed NPM plugins and also local plugin folders.
The loaded plugin, or 'undefined' if unsuccessful (e.g. the module could not be found, or it was loaded but it was not a Hindenburg plugin).
const pluginCtr = await this.worker.pluginLoader.importFromId("hbplugin-fun-things");
if (!pluginCtr) {
console.log("Failed to load my plugin.");
return;
}
The ID of the plugin to import.
Import a plugin from its absolute path on the filesystem.
The imported plugin constructor, or false if the plugin failed to be imported or was not a Hindenburg plugin.
const pluginCtr = await this.worker.pluginLoader.importPlugin("/home/user/hindenburg/plugins/hbplugin-fun-things");
if (!pluginCtr) {
console.log("Failed to load my plugin!");
return;
}x
The path of the plugin to import.
Load a global worker plugin into the worker, does not regard PluginLoader.isEnabled, waits for onPluginLoad to be finish.
The plugin instance that was loaded.
If there was an attempt to load a plugin that isn't imported, or if the server tries load a worker plugin onto a room.
const importedPlugin = await this.worker.workerPlugins.get("hbplugin-fun-things");
await this.worker.pluginLoader.loadPlugin(importedPlugin);
const importedPlugin = await this.worker.workerPlugins.get("hbplugin-fun-things");
await this.worker.pluginLoader.loadPlugin(importedPlugin, this.room); // !! Attempted to load a worker plugin on a room or other non-worker object
await this.worker.pluginLoader.loadPlugin("hbplugin-what-the-hell"); // !! Plugin with ID 'hbplugin-what-the-hell' not imported
The plugin ID or class to load.
Load a room plugin into a room, does not regard PluginLoader.isEnabled, waits for onPluginLoad to be finish.
The plugin instance that was loaded.
If there was an attempt to load a plugin that isn't imported, or if the server tries load a room plugin onto the worker.
const importedPlugin = await this.worker.roomPlugins.get("hbplugin-fun-things");
await this.worker.pluginLoader.loadPlugin(importedPlugin, this.room);
const importedPlugin = await this.worker.roomPlugins.get("hbplugin-fun-things");
await this.worker.pluginLoader.loadPlugin(importedPlugin); // !! Attempted to load a room plugin on a worker or other non-room object
await this.worker.pluginLoader.loadPlugin("hbplugin-what-the-hell", this.room); // !! Plugin with ID 'hbplugin-what-the-hell' not imported
The plugin ID or class to load.
The room to load the plugin into.
Unload a global worker plugin from the worker, calls but doesn't wait for onPluginUnload to finish.
If there was an attempt to unload a plugin that isn't loaded.
this.worker.pluginLoader.unloadPlugin("hbplugin-fun-things");
this.worker.pluginLoader.unloadPlugin("hbplugin-what-the-hell"); // !! Plugin with id 'hbplugin-what-the-hell' not loaded
The plugin ID, class, or instance to unload.
Unload a room plugin from a room, calls but doesn't wait for onPluginUnload to finish.
If there was an attempt to unload a plugin that isn't loaded.
this.worker.pluginLoader.unloadPlugin("hbplugin-fun-things");
this.worker.pluginLoader.unloadPlugin("hbplugin-what-the-hell"); // !! Plugin with id 'hbplugin-what-the-hell' not loaded
The plugin ID, class, or instance to unload.
The room to unload the plugin from.
Create a plugin loader. Note that the worker instantiates one itself, see pluginLoader.
const pluginLoader = new PluginLoader(this.worker, "/home/user/hindenburg/plugins");
The worker that the plugin loader is for.
The base directory for installed plugins.
A map of every worker and room plugin that has been imported.
Readonly
pluginThe base directory for installed plugins.
Readonly
workerThe worker that this plugin loader is for.
Generated using TypeDoc
Service for the worker node to import plugins & load them globally or into specific rooms.
An "imported plugin" is a plugin which has actually been loaded into memory with require(), and a "loaded plugin" is a plugin which is enabled on a room or globally.