# Plugins

First-party plugins provide reusable World Code features. Import a plugin from `@plugins/<name>` in your entry file or another project file:

```ts
import { setTimeout, getRandomItem } from "@plugins/helpers"
import { debugLog } from "@plugins/debug"
```

Importing a plugin also loads its callbacks. Plugin callbacks run before callbacks with the same name in your own code, so both of these `tick` callbacks run:

```ts
import { setTimeout } from "@plugins/helpers"

tick = () => {
    /* Your tick code */
}
```

If callbacks return a value, your callback's return value takes precedence over the plugin's. Avoid replacing a useful plugin return by accident, particularly in callbacks such as `onPlayerChat` and `onRespawnRequest`.

Plugins may import other plugins. Their dependencies are loaded automatically, so importing `@plugins/sessionBasedGame` also loads the helpers it needs.

## Available plugins

- `@plugins/helpers` exports `setTimeout`, `setInterval`, `clearTimeout`, `clearInterval`, `forceLoadChunk`, `randomInt`, `shuffleArray`, and `getRandomItem`.
- `@plugins/dialogue` exports `sayDialogue`, which shows a player a line of dialogue for a while, and `clearDialogue`. See [Dialogue](https://bloxd.io/docs/how-to-dialogue.md).
- `@plugins/debug` exports `debugLog`.
- `@plugins/sessionBasedGame` provides a lobby-to-game lifecycle, teams, spectators, map loading, optional map voting, optional team choosing, and automatic game resets.

The editor's autocomplete and the read-only plugin source files are the reference for the latest exports and option types.
