Server-In-Server
一个 Velocity 插件,用于直接从代理启动和管理 Minecraft 服务器实例作为子进程。在单个 YAML 文件中配置服务器——该插件自动处理启动、停止、自动重启、端口分配和代理注册。
工作原理
当 Velocity 启动时,插件会读取 plugins/server-in-server/config.yml。对于每个配置了 auto-start: true 的服务器,它会生成一个新的 Java 进程来运行指定的服务器 jar,生成带有正确端口的 server.properties,可选择接受 EULA,将服务器注册到 Velocity 代理中,并将其添加到 velocity.toml。如果服务器崩溃,插件可以按配置的次数自动重启它。
快速开始
- 将插件 jar 放入
plugins/
- 启动 Velocity —— 插件会创建一个带有默认配置的
plugins/server-in-server/config.yml
- 编辑
config.yml 以匹配你的服务器 jar 和设置
- 在 Velocity 控制台中运行
/sis reload 以应用更改
配置
全局设置
auto-eula: false
lobby-server: "lobby"
| 字段 |
默认值 |
描述 |
auto-eula |
false |
如果为 true,会自动为每个服务器创建包含 eula=true 的 eula.txt。如果为 false,你必须手动接受 EULA。 |
lobby-server |
"" |
玩家首次加入代理时连接到的服务器名称。留空以禁用。 |
服务器条目
servers:
- name: "lobby"
jar: "servers/lobby/server.jar"
directory: "servers/lobby"
port: 0
flags: "-Xmx1G -Xms512M"
auto:
start: true
restart: true
retry-count: 0
stop:
command: "stop"
wait-to-stop: true
wait: 10
| 字段 |
默认值 |
描述 |
name |
— |
在 Velocity 和路由中使用的服务器名称 |
jar |
— |
服务器 jar 的路径(相对于代理目录,或绝对路径) |
directory |
"servers/<name>" |
服务器进程的工作目录 |
port |
0 |
服务器端口。0 = 自动分配 (velocityPort + 2 + index) |
flags |
"-Xmx1G -Xms512M" |
传递给 java 的命令参数,位于 -jar 之前 |
auto.start |
true |
当 Velocity (重新) 启动时启动此服务器 |
auto.restart |
false |
当服务器停止/崩溃时自动重启服务器 |
auto.retry-count |
0 |
最大重启尝试次数。0 = 无限重启 |
stop.command |
"stop" |
通过 stdin 发送以优雅停止服务器的命令 |
stop.wait-to-stop |
true |
如果为 true,则在强制杀死之前等待进程退出 |
stop.wait |
10 |
强制杀死前等待的秒数(仅在 wait-to-stop 为 true 时有效) |
命令
所有命令都使用 /sis 前缀,可以从 Velocity 控制台或由具有相应权限的玩家运行。
| 命令 |
描述 |
/sis start <server> |
启动已配置的服务器 |
/sis stop <server> |
优雅地停止正在运行的服务器 |
/sis restart <server> |
停止然后启动服务器 |
/sis forcestop |
终止所有子进程并关闭 Velocity |
/sis reload |
重新加载配置,停止所有服务器,启动自动启动的服务器 |
/sis list |
显示所有已配置的服务器及其状态和端口 |
/sis com <server> <command> |
向正在运行的服务器发送控制台命令 |
端口自动分配
如果 port 为 0,插件计算如下:
port = velocityBindPort + 2 + serverIndex
其中 serverIndex 是服务器在 servers 列表中的位置(从 0 开始)。
Velocity 在端口 25565 上的示例:
| 索引 |
服务器 |
计算的端口 |
| 0 |
lobby |
25567 |
| 1 |
survival |
25568 |
| 2 |
creative |
25569 |
velocity.toml 集成
每次启动和重新加载时,插件都会扫描 velocity.toml 中的 [servers] 部分,并为所有已配置的服务器添加或更新条目。保留其他服务器的现有条目。如果不存在 [servers] 部分,则会在文件末尾创建它。
要求
- Java 21+
- Velocity 3.5.0-SNAPSHOT(或兼容的 3.x 版本)
Server-In-Server
A Velocity plugin that launches and manages Minecraft server instances as child processes directly from the proxy. Configure servers in a single YAML file — the plugin handles starting, stopping, auto-restarting, port assignment, and proxy registration automatically.
How it works
When Velocity starts, the plugin reads plugins/server-in-server/config.yml. For each configured server with auto-start: true, it spawns a new Java process running the specified server jar, generates server.properties with the correct port, optionally accepts the EULA, registers the server in Velocity's proxy, and adds it to velocity.toml. If a server crashes, the plugin can auto-restart it a configurable number of times.
Quick start
- Place the plugin jar in
plugins/
- Start Velocity — the plugin creates
plugins/server-in-server/config.yml with a default config
- Edit
config.yml to match your server jars and settings
- Run
/sis reload in the Velocity console to apply changes
Configuration
Global settings
auto-eula: false
lobby-server: "lobby"
| Field |
Default |
Description |
auto-eula |
false |
If true, creates eula.txt with eula=true automatically for every server. If false, you must accept the EULA manually. |
lobby-server |
"" |
Server name to connect players to when they first join the proxy. Leave empty to disable. |
Server entries
servers:
- name: "lobby"
jar: "servers/lobby/server.jar"
directory: "servers/lobby"
port: 0
flags: "-Xmx1G -Xms512M"
auto:
start: true
restart: true
retry-count: 0
stop:
command: "stop"
wait-to-stop: true
wait: 10
| Field |
Default |
Description |
name |
— |
Server name used in Velocity and for routing |
jar |
— |
Path to the server jar (relative to the proxy directory, or absolute) |
directory |
"servers/<name>" |
Working directory for the server process |
port |
0 |
Server port. 0 = auto-assign (velocityPort + 2 + index) |
flags |
"-Xmx1G -Xms512M" |
JVM arguments passed to java before -jar |
auto.start |
true |
Start this server when Velocity (re)starts |
auto.restart |
false |
Restart the server automatically when it stops/crashes |
auto.retry-count |
0 |
Max restart attempts. 0 = infinite restarts |
stop.command |
"stop" |
Command sent via stdin to gracefully stop the server |
stop.wait-to-stop |
true |
If true, wait for the process to exit before force killing |
stop.wait |
10 |
Seconds to wait before force killing (only if wait-to-stop is true) |
Commands
All commands use the /sis prefix and can be run from the Velocity console or by players with appropriate permissions.
| Command |
Description |
/sis start <server> |
Start a configured server |
/sis stop <server> |
Gracefully stop a running server |
/sis restart <server> |
Stop then start a server |
/sis forcestop |
Kill all child processes and shut down Velocity |
/sis reload |
Reload config, stop all servers, start auto-start ones |
/sis list |
Show all configured servers with their status and ports |
/sis com <server> <command> |
Send a console command to a running server |
Port auto-assignment
If port is 0, the plugin calculates it as:
port = velocityBindPort + 2 + serverIndex
Where serverIndex is the server's position in the servers list (0-based).
Example with Velocity on port 25565:
| Index |
Server |
Calculated port |
| 0 |
lobby |
25567 |
| 1 |
survival |
25568 |
| 2 |
creative |
25569 |
velocity.toml integration
On every startup and reload, the plugin scans velocity.toml for the [servers] section and adds or updates entries for all configured servers. Existing entries for other servers are preserved. If the [servers] section does not exist, it is created at the end of the file.
Requirements
- Java 21+
- Velocity 3.5.0-SNAPSHOT (or compatible 3.x)
评论 0
登录后参与评分
还没有评论,来抢沙发吧