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

# Alert Datapack

> Install and manage the PopLock datapack that plays in-game countdown alerts before daily snapshots.

`poplock_datapack.zip` provides a single Minecraft function — `poplock:alert` — that plays a sound alert to all online players simultaneously. The snapshot script calls this function at each countdown interval before stopping the server for a daily snapshot.

## Countdown intervals

When the server is online at snapshot time, `snapshot.sh` broadcasts a message and triggers `poplock:alert` at the following intervals before shutdown:

| Time before shutdown | Broadcast message                                                 |
| -------------------- | ----------------------------------------------------------------- |
| 30 minutes           | Server will go down for a daily snapshot in 30 minutes.           |
| 15 minutes           | Server will go down for a daily snapshot in 15 minutes.           |
| 10 minutes           | Server will go down for a daily snapshot in 10 minutes.           |
| 5 minutes            | Server will go down for a daily snapshot in 5 minutes.            |
| 1 minute             | Server will go down for a daily snapshot in 1 minute!             |
| 30 seconds           | Server going down for snapshot in 30 seconds! Please log off now. |
| 15 seconds           | Server going down for snapshot in 15 seconds!                     |
| 5 seconds            | Server going down for snapshot in 5 seconds!                      |

The datapack function is used instead of a direct `playsound` command so that the per-player command feedback messages are suppressed in chat.

***

## Installation

<Steps>
  <Step title="Download the datapack">
    ```bash theme={null}
    sudo wget -O /usr/local/games/minecraft_server/java/world/datapacks/poplock_datapack.zip \
      https://github.com/Scyne/PopLockRP/raw/refs/heads/main/poplock_datapack.zip
    ```

    The `world/datapacks/` directory is created by the server on its first run. If you are installing the datapack before the server has launched for the first time, create the directory manually first:

    ```bash theme={null}
    mkdir -p /usr/local/games/minecraft_server/java/world/datapacks
    ```
  </Step>

  <Step title="Activate the datapack from the server console">
    Once the server is running, enable the datapack once:

    ```text theme={null}
    datapack enable "file/poplock_datapack.zip"
    ```

    The datapack loads automatically on every subsequent server restart — this command only needs to be run once.
  </Step>
</Steps>

***

## Updating the datapack

If Minecraft updates to a new version that changes the required pack format number, the datapack may stop loading and `snapshot.sh` will log errors when trying to call `poplock:alert`.

<Steps>
  <Step title="Re-download the datapack">
    ```bash theme={null}
    sudo wget -O /usr/local/games/minecraft_server/java/world/datapacks/poplock_datapack.zip \
      https://github.com/Scyne/PopLockRP/raw/refs/heads/main/poplock_datapack.zip
    ```
  </Step>

  <Step title="Reload datapacks without restarting">
    From the server console (attach with `serv console`):

    ```text theme={null}
    reload
    ```
  </Step>
</Steps>

<Note>
  If you see `Unknown function poplock:alert` in the snapshot log, the pack format number declared in `pack.mcmeta` inside the zip does not match your server version. To find the correct format number, run `version` in the server console, look up the corresponding pack format for that Minecraft release, then rebuild the datapack zip with the matching value in `pack.mcmeta` and re-download it.
</Note>
