AutoServer
A Minecraft plugin for Velocity Proxy that automatically starts offline backend servers when players try to connect.
Install / Use
/learn @Artificial-720/AutoServerREADME
AutoServer
Overview
AutoServer is a Minecraft plugin designed for the Velocity Proxy. This plugin automatically starts offline backend servers when a player attempts to connect to them. It's perfect for server networks looking to save resources by keeping idle servers offline until needed.
Features
- Automatically starts backend servers when a player attempts to connect.
- Automatically stops local servers when no players are online.
- Manually start and stop backend servers using commands.
- Supports configuration hot reloading.
- Customizable messages.
Getting Started
This section will cover how to install and configure a minimal setup of AutoServer.
-
Downloading AutoServer Head over to installation section to get the latest version of AutoServer. After downloading AutoServer, place the JAR file into the
pluginsdirectory of your Velocity proxy. -
Launching for the first time Once you have placed AutoServer into the
pluginsdirectory, we need to restart Velocity to load the plugin. On the first launch AutoServer will generate a configuration fileautoserver/config.tomllocated in thepluginsdirectory. -
Configuring your servers Start by taking note of your
velocity.tomlfile looking for the[servers]section. How the servers are named needs to match exactly when configuring AutoServer.Open the
autoserver/config.tomlin a text editor and search for the[servers]section. This section specifies the servers that AutoServer will manage. Create a table for each server you want AutoServer to manage. For example if you have a server namedlobbyyou will create a table called[servers.lobby].Two routes you can head with configuring a server either a remote server or a local server. If you have a remote server you need to configure check out the Remote Backend section for more details. For the sake of this section we will handle a local server that we have a script for. This example local server is called
lobbyhere is a minimal settings to start the server using a script:[servers] [servers.lobby] # Path to the directory where the server runs. workingDirectory = "/home/user/minecraft/servers/lobby" # Command to start the "lobby" server. start = "bash start.sh" # Or if you have a Windows Batch Script # start = "start.bat" -
Repeat for each server Now repeat step 3 for each server you want to be managed by AutoServer. There is a lot of example commands in the Commands section of this document. To help you build a command that works for your situation.
Installation
- Download the latest version of
autoserver-velocity-1.x.x.jarfrom Modrinth. - Place the
.jarfile into your Velocitypluginsfolder. - Restart your Velocity Proxy to load the plugin.
Configuration
After the first launch, the plugin will generate a config.toml file in the plugins/autoserver directory. Modify this file to suit your setup.
Global
| Key | Type | Description |
|-------------------|-----------|----------------------------------------------|
| checkForUpdates | boolean | Should AutoServer check for updates on boot? |
| messages | table | Messages that will get sent to players. |
| servers | table | The configuration for each server. |
Messages
| Key | Type | Description |
|------------|----------|-----------------------------------------------------------------------------------------------------------|
| prefix | string | Prefix added to all messages displayed to the player. |
| starting | string | Message displayed to the player when they attempt to connect to a server that is currently offline. |
| failed | string | Message displayed to the player if the server fails to start or cannot be connected to. |
| notify | string | Message displayed to the player when the server is ready, indicating that they will be connected shortly. |
Servers
| Key | Type | Description |
|---------------------|-----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| startupDelay | int | Time in seconds to wait before attempting to connect a player after starting the server. |
| shutdownDelay | int | Time in seconds to wait before verifying whether the server has successfully shut down. |
| start | string | Command used to start the server locally. |
| stop | string | Command used to stop the server locally. |
| workingDirectory | string | Path to the directory where the server runs. |
| remote | boolean | Specifies whether the server is remote (true) or local (false). |
| port | int | Port number on which the remote server listens for the start command. |
| preserveQuotes | boolean | (Optional) Controls whether leading and trailing quotes are preserved, with quotes being removed by default on non-Windows systems unless explicitly set to true. |
| security | boolean | Specifies whether the remote server should use security on message (default: true) |
| autoShutdownDelay | int | Duration (in seconds) to wait before automatically shutting down the server; set to 0 to disable this feature. |
Command examples
Here are some command examples to help construct your start and stop commands.
Running Java command
To run the server using java:
start = "java -Xmx4G -Xms4G -jar server.jar nogui"
By default, this will run the process in the background. If you need to attach to the process, consider launching it in a new terminal session. On Linux, you can use x-terminal-emulator:
start = "x-terminal-emulator -e java -Xmx4G -Xms4G -jar server.jar nogui"
Using a Bash or sh Script
To run a script using Bash or sh:
start = "bash start.sh"
stop = "bash stop.sh"
Using screen
To run the server in a detached screen session:
start = "screen -DmS mc-example java -Xmx4G -Xms4G -jar server.jar nogui"
stop = "screen -p 0 -S mc-example -X stuff \"stop\r\""
Using tmux
To run the server in a new tmux session:
start = "tmux new -d -s mc-example 'java -Xmx4G -Xms4G -jar server.jar nogui'"
stop = "tmux send-keys -t mc-example 'stop' C-m"
Using systemd
If you have systemd service for your server, you can control it like this:
start = "systemctl start myserver"
stop = "systemctl stop myserver"
Note: You might have privilege issues with this.
Using Docker
To start and stop a server using Docker:
start = "docker start mc-example"
stop = "docker stop mc-example"
Windows
Using batch script
Be aware this runs in the background.
start = "start.bat"
Using start (Windows Command Prompt)
To launch the server in a new Command Prompt window:
start = "cmd.exe /c start \"ExampleTitle\" cmd /c java -Xmx4G -Xms4G -jar server.jar nogui"
Using PowerShell
To start the server in a new PowerShell window:
start = "powershell -Command Start-Process -FilePath 'java' -ArgumentList '-Xmx4G -Xms4G -jar server.jar nogui'"
To start the server in a hidden PowerShell window:
start = "powershell -WindowStyle Hidden -Command Start-Process -NoNewWindow -FilePath 'java' -ArgumentList '-Xmx4G -Xms4G -jar server.jar nogui'"
Using wt
To start the server in the same PowerShell window as a new tab do a command like this:
start = "wt -w 0 new-tab -d \"C:/path/to/directory\" \"C:/path/to/script/start.bat\""
The workingDirectory setting won't be effective for this command which is why working directory is passed in the command.
Using Task Scheduler
If you have a scheduled task to start your server:
start = "schtasks /run /tn \"MinecraftExampleTask\""
stop = "schtasks /end /tn \"MinecraftExampleTask\""
Do not use a batch script for this task if you want to use the stop command. It won't work because it will end the batch script but not the java process.
The workingDirectory setting won't be effective for this command. To set the working directory go into the Task Scheduler GUI and edit the task. There is a text box for the working directory called Start in.
Commands and Permissions
| Command | Description | Per
