> ## Documentation Index
> Fetch the complete documentation index at: https://developers.duelsplus.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Examples

> Example plugins that demonstrate the Plugin API

The [plugin-api repo](https://github.com/duelsplus/plugin-api) includes example plugins that demonstrate the API. You can copy and adapt them for your own plugins.

## opponent-tracker

Fetches and displays opponent stats when a game starts. Tracks your personal W/L record against each opponent using persistent storage.

**API used:** `players.fetchStatsByUsername()`, `events.on('opponent:detected')`, `storage`, `commands.register()`

## session-overlay

Shows your session stats on the action bar while in-game, with a configurable update interval.

**API used:** `stats.getSessionStats()`, `stats.getDailyStats()`, `scheduler.setInterval()`, `client.sendActionBar()`, `gameState.isInGame()`

## auto-glhf

Sends a customizable "glhf" message at the start of each game with a configurable delay. Configurable via `/glhf on|off|set <message>|delay <ms>`.

**API used:** `events.on('game:start')`, `events.on('opponent:detected')`, `scheduler.setTimeout()`, `client.sendGameChat()`, `gameState.isPrivateMatch`, `storage`, `commands.register()`

## game-logger

Records every game with details (mode, map, result, opponents, duration). View history with `/gamelog`.

**API used:** `events`, `players.getOpponents()`, `scoreboard.getTeams()`, `stats`, `storage`, `gameState.getGamePhase()`, `gameState.bridgeTeam`

## lobby-spy

Scans lobby players for stats and alerts when high-WLR opponents are detected with a title and sound.

**API used:** `players.getLobbyPlayers()`, `players.fetchStatsByUsername()`, `scoreboard.getPlayerTeam()`, `settings.onChange()`, `packets.onClientbound()`, `client.sendTitle()`, `client.playSound()`

## match-alerts

Plays sounds and titles for game events: starts, victories, defeats, winstreak milestones. Optional auto-requeue after victory.

**API used:** `events` (game:start, game:victory, game:defeat, lobby:join, server:change), `stats.getSessionStats()`, `scheduler.setTimeout()`, `client.playSound()`, `client.sendTitle()`, `client.sendGameChat()`, `storage`, `commands.register()`

***

Example source code lives in the [`plugin-api/examples/`](https://github.com/duelsplus/plugin-api/tree/master/examples) directory of the [repo](https://github.com/duelsplus/plugin-api). Each example is a self-contained plugin you can build and drop into `~/.duelsplus/plugins/` to try.
