# Commands
Chain registers two top-level commands: `/chain` and `/unchain`. Both use the CommandAPI for tab completion and entity selector support.
---
## /chain
The base command for creating chains between entities.
| Subcommand | Usage | Permission | Description |
|---|---|---|---|
| *(single target)* | `/chain <target>` | `lodestone.chain.commands.chain` | Chains the executing player to the specified entity. Player only. |
| *(multi target)* | `/chain <target> <targets>` | `lodestone.chain.commands.chain` | Chains the first target entity to each entity in the targets selector. Can be run from console. |
| `version` | `/chain version` | *(none)* | Displays the current Chain plugin version. |
| `set_max_distance` | `/chain set_max_distance <value>` | `lodestone.chain.commands.chain` | Sets the maximum chain distance (0-64 blocks). Persists to config. Player only. |
| `reload` | `/chain reload` | `lodestone.chain.commands.chain` | Reloads the configuration from disk. |
### Entity Selectors
The `<target>` argument accepts a single entity selector (e.g., `@e[type=pig,limit=1,sort=nearest]`). The `<targets>` argument accepts a multi-entity selector (e.g., `@a[distance=..10]`).
### Examples
```
/chain @e[type=pig,limit=1,sort=nearest]
/chain @e[type=zombie,limit=1] @a[distance=..20]
/chain set_max_distance 5
```
---
## /unchain
Removes chains from entities.
| Usage | Permission | Description |
|---|---|---|
| `/unchain <targets>` | `lodestone.chain.commands.unchain` | Removes all chains from the specified entities. |
If a player runs `/unchain` targeting themselves and they are chained, the chain is removed. If the targeted entity is not chained, an error message is displayed.
### Examples
```
/unchain @s
/unchain @a
/unchain @e[type=pig]
```
---
## Permissions Summary
| Permission | Description |
|---|---|
| `lodestone.chain.commands.chain` | Access to the `/chain` command and all subcommands. |
| `lodestone.chain.commands.unchain` | Access to the `/unchain` command. |
---
## Related Pages
- [[Chain/Server Owners/Overview]] — Plugin overview and installation
- [[Chain/Server Owners/Configuration]] — Config file reference