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

# Common Java server commands

> Use common Minecraft Java Edition administration commands from the Purpify console or in-game chat.

Run commands without `/` in the Purpify game panel console. In Minecraft chat, add `/` and use an account with sufficient [operator access](/java/manage-players).

## Player and world commands

| Task                                | Console command                      |
| ----------------------------------- | ------------------------------------ |
| Change a player's game mode         | `gamemode MODE PLAYER`               |
| Teleport a player to another player | `teleport PLAYER DESTINATION_PLAYER` |
| Teleport a player to coordinates    | `teleport PLAYER X Y Z`              |
| Give an item                        | `give PLAYER ITEM [AMOUNT]`          |
| Clear a player's inventory          | `clear PLAYER`                       |
| Set the default game mode           | `defaultgamemode MODE`               |
| Change the difficulty               | `difficulty DIFFICULTY`              |
| Save the world immediately          | `save-all`                           |

Replace the uppercase placeholders with real values. Valid modes are `survival`, `creative`, `adventure`, and `spectator`. Valid difficulties are `peaceful`, `easy`, `normal`, and `hard`. Player names containing spaces are not valid Java Edition usernames.

## Set the world spawn

Stand at the intended location and run this in Minecraft chat:

```text theme={"dark"}
/setworldspawn
```

From the console, provide coordinates and an optional dimension:

```text theme={"dark"}
execute in minecraft:overworld run setworldspawn <x> <y> <z>
```

The individual respawn point created by a bed, respawn anchor, or `spawnpoint` is separate from the world spawn.

## Target selectors

Use selectors carefully because a command can affect many players.

| Selector | Target                                                                                      |
| -------- | ------------------------------------------------------------------------------------------- |
| `@a`     | All players                                                                                 |
| `@p`     | Nearest player to the command source                                                        |
| `@r`     | Random player                                                                               |
| `@s`     | The entity running the command; behavior from the console may differ from an in-game player |

<Warning>
  Test destructive commands on a backup or a limited target first. Commands such as `clear`, `kill`, and large `fill` operations can cause irreversible changes.
</Warning>
