## Installation

1.  ```shell
    dnf copr enable kaidelorenzo/minecraft-server
    ```

2.  ```shell
    dnf install minecraft-server-java
    ```

    or

    ```shell
    dnf install minecraft-server-fabric
    ```

    or

    ```shell
    dnf install minecraft-server-bedrock
    ```

    The standalone launchers can also be installed directly:

    ```shell
    dnf install minecraft-java-server minecraft-fabric-server geyser-standalone mcxboxbroadcast-standalone
    ```

    RPM descriptions record the exact upstream application version locked by
    each wrapper. The same information is exposed through `wrapped(...)`
    virtual capabilities:

    ```shell
    rpm -qi geyser-standalone
    rpm -q --provides geyser-standalone | grep 'wrapped('
    rpm -q --provides minecraft-server-fabric | grep 'wrapped('
    ```

### Uninstallation

1.  ```shell
    dnf remove minecraft-server-java
    ```

    or

    ```shell
    dnf remove minecraft-server-fabric
    ```

    or

    ```shell
    dnf remove minecraft-server-bedrock
    ```

2.  ```shell
    dnf copr remove kaidelorenzo/minecraft-server
    ```

3.  Delete the `net.minecraft.JavaServer`, `net.fabricmc.FabricServer`, and
    `net.minecraft.BedrockServer` directories
    from the `$XDG_DATA_HOME` and `$XDG_CONFIG_HOME` directories (see
    [XDG Base Directory Specification](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html))
4.  Delete any manually created configuration files

## Simple Usage

### Start the server

#### from the terminal shell

```shell
java <JVM options> -jar /usr/lib/java/minecraft-server-java.jar <Minecraft options>
```

or

```shell
java <JVM options> -jar /usr/lib/java/minecraft-server-fabric.jar <Minecraft options>
```

or

```shell
minecraft-server-bedrock <Bedrock options>
```

The low-level version-locked wrapper jars can be run directly with:

```shell
java <JVM options> -jar /usr/lib/java/minecraft-java-server-wrapper.jar --nogui
java <JVM options> -jar /usr/lib/java/minecraft-fabric-server-wrapper.jar --nogui
java <JVM options> -jar /usr/lib/java/geyser-standalone-wrapper.jar <Geyser options>
java <JVM options> -jar /usr/lib/java/mcxboxbroadcast-standalone-wrapper.jar <MCXboxBroadcast options>
```

The wrapper jars use standard Java command-line syntax: JVM options go before
`-jar`, and application arguments go after the wrapper jar. Both sets of
arguments are preserved when the version-locked application jar is launched:

```text
java <JVM options> -jar wrapper.jar <args>
  -> java <JVM options> -jar <version-locked.jar> <args>
```

The Bedrock wrapper passes all arguments directly to the version-locked server
executable. On first launch it downloads the exact locked archive with an
application-specific HTTP user agent, verifies its SHA-256 checksum, and stages
the complete distribution before publishing the executable. Distribution
updates preserve `server.properties`, `allowlist.json`, `permissions.json`, and
`packetlimitconfig.json` while refreshing upstream-owned runtime assets.

#### with systemd

```shell
systemctl --user enable --now minecraft-server-java
```

or

```shell
systemctl --user enable --now minecraft-server-fabric
```

or

```shell
systemctl --user enable --now minecraft-server-bedrock
```

Geyser and MCXboxBroadcast do not install systemd units because their upstream
standalone applications do not provide the same verified shutdown behavior as
the Minecraft supervisors. Basic, unsupported reference units are available in
`example systemd unit files/` for users who accept that limitation.

To enable auto launch on system start for the currently logged in user:

```shell
loginctl enable-linger
```

<https://wiki.archlinux.org/title/Systemd/User#Automatic_start-up_of_systemd_user_instances>

To view output:

```shell
journalctl --user-unit minecraft-server-java
```

or

```shell
journalctl --user-unit minecraft-server-fabric
```

or

```shell
journalctl --user-unit minecraft-server-bedrock
```

Use the `--follow` option to continually view messages

To send commands:

-   One at a time:

    ```shell
    echo "help" > $XDG_RUNTIME_DIR/minecraft-server-java.stdin
    ```

    or

    ```shell
    echo "help" > $XDG_RUNTIME_DIR/minecraft-server-fabric.stdin
    ```

    or

    ```shell
    echo "help" > $XDG_RUNTIME_DIR/minecraft-server-bedrock.stdin
    ```

-   One after the other (with history via up/down arrows) while viewing the server output:

    ```shell
    journalctl --user-unit minecraft-server-java --follow & rlwrap cat > $XDG_RUNTIME_DIR/minecraft-server-java.stdin
    help
    help list
    list
    <ctrl+c/d>/^C/D
    # exiting the shell should stop the journalctl job (exit)
    # to manually stop it do the following
    # find the id of the background journalctl job (it's 1 in this case)
    jobs 
    # connect to it
    fg 1
    <ctrl+c>/^C
    ```

    or

    ```shell
    journalctl --user-unit minecraft-server-fabric --follow & rlwrap cat > $XDG_RUNTIME_DIR/minecraft-server-fabric.stdin
    help
    help list
    list
    <ctrl+c/d>/^C/D
    # exiting the shell should stop the journalctl job (exit)
    # to manually stop it do the following
    # find the id of the background journalctl job (it's 1 in this case)
    jobs 
    # connect to it
    fg 1
    <ctrl+c>/^C
    ```

    or

    ```shell
    journalctl --user-unit minecraft-server-bedrock --follow & rlwrap cat > $XDG_RUNTIME_DIR/minecraft-server-bedrock.stdin
    help
    help list
    list
    <ctrl+c/d>/^C/D
    # exiting the shell should stop the journalctl job (exit)
    # to manually stop it do the following
    # find the id of the background journalctl job (it's 1 in this case)
    jobs 
    # connect to it
    fg 1
    <ctrl+c>/^C
    ```
