Interface ServerPlugin<T, G, C>

Represents a server plugin.

interface ServerPlugin<T, G, C> {
    author: string;
    defaultConfig?: C;
    dependencies?: Record<string, string>;
    events?: EventRegistration<T, keyof T, G>[];
    name: string;
    onDisable?: ((bus: EventBus<T, G>, logger: Logger<never, boolean>) => C | Promise<C>);
    onEnable?: ((cfg: C, bus: EventBus<T, G>, logger: Logger<never, boolean>) => void | Promise<void>);
    repository?: string;
    serverVersion: string;
    version: string;
}

Type Parameters

  • T extends O

    The server events, a record mapping event names to their payload types.

  • G extends O

    The game state, a record mapping defining the types of the game state object.

  • C extends O | void

    The configuration type for the plugin.

Properties

author: string

The author of the plugin.

defaultConfig?: C

The default configuration for the plugin.

dependencies?: Record<string, string>

Dependencies for the plugin. If a dependency is not met, the plugin will not be loaded. This will influence the order in which plugins are loaded.

{ "other-plugin": ">=1.0.0 <2.0.0" }
events?: EventRegistration<T, keyof T, G>[]

An array of event registrations that the plugin listens to.

name: string

The name of the plugin.

onDisable?: ((bus: EventBus<T, G>, logger: Logger<never, boolean>) => C | Promise<C>)

An function that is called when the plugin is disabled.

Type declaration

    • (bus, logger): C | Promise<C>
    • Parameters

      • bus: EventBus<T, G>

        The event bus.

      • logger: Logger<never, boolean>

        The logger.

      Returns C | Promise<C>

      The configuration to save or null if no configuration should be saved.

onEnable?: ((cfg: C, bus: EventBus<T, G>, logger: Logger<never, boolean>) => void | Promise<void>)

An function that is called when the plugin is enabled.

Type declaration

    • (cfg, bus, logger): void | Promise<void>
    • Parameters

      • cfg: C

        The current configuration loaded from the configuration file.

      • bus: EventBus<T, G>

        The event bus.

      • logger: Logger<never, boolean>

        The logger.

      Returns void | Promise<void>

repository?: string

Git repository URL for the plugin.

serverVersion: string

A valid semver range that specifies the version of the server that the plugin is compatible with.

">=1.0.0 <2.0.0"
version: string

The version of the plugin, following the semver specification.