Railway 是一款基于 Metro 的 Minecraft 列车运营插件。在原有车站管理的基础上,它引入了固定行车间隔、列车编组和自动调度系统,让玩家体验真实的到站、停靠与离站流程。
核心特性
- 基于 Metro:继承车站管理、UI 提示、音效系统及多语言支持。
- 兼容 Folia:声明为
folia-supported: true;请在目标服务器环境中通过负载测试进行验证。
- 自动调度:根据行车间隔生成列车,支持环线/单程运行模式。
- 三种控制模式:运动学(Kinematic)、反应式(Reactive)、牵引绳(Leashed)。
- 虚拟调度:本地模式下按需生成列车以节省服务器性能。
- 车站 HUD:实时显示下一班列车倒计时,支持 Title/ActionBar/Hologram 显示。
- 权限管理:线路和站点支持所有者和管理员系统。
配置
默认配置文件位于 config.yml。未来更新将扩展 lines.yml 以支持每条线路独立的 service.* 字段。
核心配置项
服务配置 (service)
service:
mode: local # 运行模式:local (虚拟时刻表) | global (常驻实体)
default_headway_seconds: 120 # 默认行车间隔(秒)
default_dwell_ticks: 100 # 默认停站时间(刻)
default_train_cars: 3 # 默认列车编组长度(车厢数)
heartbeat_interval_ticks: 1 # 服务心跳周期(刻)
metrics:
log_interval_ticks: 0 # 服务指标日志间隔(0 = 禁用)
通用设置 (settings)
settings:
default_language: en_US # 默认语言 (en_US / zh_CN)
cart_speed: 0.4 # 默认车厢速度(可被线路 max_speed 覆盖)
train_spacing: 1.6 # 编组内车厢间距(格)
safe_speed_mode: true # 弯道/坡道自动限速(防止脱轨)
control:
default_mode: kinematic # 全局默认控制模式
leash: # 牵引绳模式配置
mob_type: ALLAY # 牵引物类型 (ALLAY/FOX/WOLF 等)
update_interval_ticks: 1 # 牵引物更新间隔
offset_y: 0.2 # 牵引物垂直偏移量
selection:
tool: GOLDEN_HOE # 站点区域选择工具
interact:
type: SUBTITLE # 轨道预计到达时间显示类型:ACTIONBAR, TITLE, SUBTITLE
stay_ticks: 60 # 显示持续时间(刻)
chunk_loading: # 全局模式区块加载策略
enabled: true
radius: 2 # 每节车厢周围的加载半径(区块)
forward_preload_radius: 1 # 前方预加载半径
only_when_moving: false # 仅在移动时加载
update_interval_ticks: 10 # 刷新间隔
旅行时间估算 (travel_time)
travel_time:
enabled: true # 启用贝叶斯估算
default_section_seconds: 20.0 # 默认区间旅行时间
prior_strength: 4.0 # 先验强度(虚拟样本数量)
outlier_sigma: 3.0 # 异常值过滤阈值(sigma)
decay_per_day: 0.95 # 每日衰减因子
use_unboarded_samples: false # 是否使用未上车样本
unboarded_weight: 0.2 # 未上车样本权重
本地模式配置 (local)
local:
activation_radius: 96 # 触发生成的玩家半径(格)
spawn_lead_ticks: 120 # 目标到达提前时间(刻)
suppress_threshold_seconds: 10.0 # 已有列车进站时的抑制阈值(秒)
virtualization:
enabled: true # 启用虚拟化
idle_ticks: 200 # 回收无需求列车的等待时间(刻)
lookahead_stops: 2 # 检查需求的站点数量
物理引擎配置 (physics)
physics:
lead_kinematic: true # 头车由运动学驱动
lookahead_blocks: 4 # 轨道几何前瞻距离(格)
trail_seconds: 10 # 轨迹缓冲时长(秒)
smoothing_lerp: 0.15 # 平滑插值系数(0=瞬间,0.3=平滑)
snap_to_rail: true # 吸附至铁轨中心
strict_when_has_passenger: true # 载有乘客时严格对齐
position_only_mode: false # 仅位置模式(用于电影效果/展示)
车站 UI 配置 (titles)
支持 stop_continuous(车站 HUD)、arrive_stop(到站)、terminal_stop(终点站)、departure(行程信息)、waiting(等待发车)场景。完整配置请参阅 config.yml。
音效配置 (sounds)
支持 departure(发车)、arrival(到达)、station_arrival(车站到达)、waiting(等待)音效序列。完整配置请参阅 config.yml。
记分板配置 (scoreboard)
scoreboard:
enabled: true # 启用记分板(与 Folia 不兼容)
styles:
current_stop: "&f" # 当前站点样式
next_stop: "&a" # 下一站点样式
other_stops: "&7" # 其他站点样式
line_symbol: "●" # 线路符号
提示:插件启动时会自动填充 config.yml 中缺失的键(保留现有值)。语言文件也会自动合并新条目。升级时无需手动更新配置。
从本版本开始,旧的 settings.consist.* 设置已被弃用并移除,已整合至 physics.* 中。
lines.yml 示例(计划扩展):
red:
name: Red Line
color: "&c"
ordered_stop_ids: [r1, r2, r3, r4]
terminus_name: "To R4"
max_speed: 0.6
service:
enabled: true
headway_seconds: 90
dwell_ticks: 100
train_cars: 4
direction_mode: bi_directional # bi_directional | circular | single_direction
first_departure_tick: 200
命令
基本命令
/rail - 显示主帮助菜单
/rail reload - 重新加载配置和数据,重建线路服务
/rail gui - 打开服务器范围的线路 GUI 面板
/rail line status [lineId] - 查看全局或特定线路状态
/rail line list - 列出所有线路摘要
/rail stop list - 列出所有站点配置状态
线路管理 (/rail line)
/rail line - 显示线路管理帮助
/rail line create <id> <name> - 创建新线路
/rail line delete <id> - 删除线路
/rail line list - 列出所有线路
/rail line stops <id> - 列出线路上的所有站点(包括站点位置状态)
/rail line control <id> <kinematic|leashed|reactive> - 设置线路的控制模式
/rail line rename <id> <name> - 重命名线路
/rail line setcolor <id> <&code> - 设置线路颜色(例如 &c 表示红色)
/rail line addstop <id> <stopId> [index] - 向线路添加站点
/rail line delstop <id> <stopId> - 从线路移除站点
/rail line service <id> <enable|disable> - 启用/禁用线路服务
/rail line setheadway <id> <seconds> - 设置发车间隔
/rail line setdwell <id> <ticks> - 设置停站时间
/rail line settraincars <id> <count> - 设置编组长度
/rail line setterminus <id> <name> - 设置终点站名称
/rail line setmaxspeed <id> <speed> - 设置最高速度
/rail line setowner <id> <uuid> - 设置线路所有者
/rail line trust <id> <uuid> - 添加管理员
/rail line untrust <id> <uuid> - 移除管理员
站点管理 (/rail stop)
/rail stop - 显示站点管理帮助
/rail stop create <id> [name] - 创建新站点
/rail stop delete <id> - 删除站点
/rail stop list - 列出所有站点
/rail stop tp <id> - 传送至站点
/rail stop rename <id> <name> - 重命名站点
/rail stop setcorners <id> - 设置站点区域(使用金锄头选择角落)
/rail stop setpoint [id] [yaw] - 在当前地点设置站点坐标(如果在站点内则 id 可选,支持自定义偏航角)
/rail stop allowline <id> <lineId> - 允许线路穿过站点
/rail stop denyline <id> <lineId> - 禁止线路穿过站点
/rail stop addtransfer <id> <lineId> - 添加换乘线路
/rail stop deltransfer <id> <lineId> - 移除换乘线路
/rail stop settitle <id> <type> <field> <value> - 设置自定义标题
/rail stop deltitle <id> <type> - 移除自定义标题
/rail stop setowner <id> <uuid> - 设置站点所有者
/rail stop trust <id> <uuid> - 添加管理员
/rail stop untrust <id> <uuid> - 移除管理员
所有命令均支持 Tab 补全。
所有命令反馈和提示均已集成到语言系统中,将根据玩家选择的语言输出文本。
权限
railway.admin - 使用所有管理命令(默认:OP)
railway.use - 使用基本插件功能(如乘坐火车等,默认:所有玩家)
railway.line.create - 允许玩家创建新线路(默认:false)
railway.stop.create - 允许玩家创建新站点(默认:false)
线路和站点支持所有者和管理员系统。可以通过 setowner、trust 和 untrust 命令管理权限。OP 和拥有 railway.admin 权限的玩家可绕过所有权检查。
运行模式
- local(默认):“虚拟时刻表 + 邻近生成”。仅在玩家附近生成列车实体,平衡沉浸感与性能。支持虚拟化回收(自动清除无需求的列车)。
- global:基于发车间隔持续运行的常驻实体。支持移动窗口区块加载,以确保列车在整个路线上正常运行。
控制模式
- kinematic:车头完全接管运动。跟随车厢严格遵循轨迹。在弯道/斜坡上稳定,保持乘客同步。推荐用于高速线路和精确调度。
- reactive:基于原版物理学的间距控制。实时校正以保持编组一致性。平衡原版手感与同步性。适合低速观光线路。
- leashed:通过拴绳生物进行视觉连接。轻量级控制,兼容 TrainCarts 和其他插件。适合展示和兼容性场景。
所有控制模式均支持线路限速(max_speed)、弯道/斜坡的安全限速以及严格的乘客同步。
Metro 迁移指南
Railway 直接兼容 Metro 数据文件。迁移步骤如下:
- 安装 Railway 插件。
- 删除
Metro/config.yml(建议使用 Railway 生成的新配置)。
- 将
Metro/lines.yml 和 Metro/stops.yml 复制到 Railway/ 目录。
- 重启服务器。
- 使用
/rail line list 确认线路已加载。
Folia 支持
本插件声明为 Folia 兼容(plugin.yml 中为 folia-supported: true)。由于性能和调度器行为可能因环境而异,在生产部署前请进行全面回归测试和负载测试。
物理参考
TrainCarts, Metro
Railway is a Minecraft train operation plugin based on Metro. Building upon the original station management, it introduces Fixed Headway, Train Consists, and Automated Dispatching systems, allowing players to experience realistic arrival, docking, and departure processes.
Core Features
- Based on Metro: Inherits station management, UI prompts, sound systems, and multi-language support.
- Folia Compatibility: Declared as
folia-supported: true; validate with load testing on your target server setup.
- Automated Dispatching: Generates trains based on headway, supporting loop/single-direction operations.
- Three Control Modes: Kinematic, Reactive, Leashed.
- Virtual Dispatching: Local mode generates trains on demand to save server performance.
- Station HUD: Real-time countdown for next train, supporting Title/ActionBar/Hologram.
- Permission Management: Lines and stops support owner and admin systems.
Configuration
The default configuration is located in config.yml. Future updates will extend lines.yml to support per-line service.* fields.
Core Configuration Items
Service Configuration (service)
service:
mode: local # Run mode: local (virtual timetable) | global (always-on entities)
default_headway_seconds: 120 # Default headway (seconds)
default_dwell_ticks: 100 # Default dwell time (ticks)
default_train_cars: 3 # Default consist length (number of cars)
heartbeat_interval_ticks: 1 # Service heartbeat period (ticks)
metrics:
log_interval_ticks: 0 # Service metrics log interval (0 = disabled)
General Settings (settings)
settings:
default_language: en_US # Default language (en_US / zh_CN)
cart_speed: 0.4 # Default cart speed (can be overridden by line max_speed)
train_spacing: 1.6 # Spacing between cars in a consist (blocks)
safe_speed_mode: true # Automatic speed limit on curves/slopes (prevents derailment)
control:
default_mode: kinematic # Global default control mode
leash: # Leash mode configuration
mob_type: ALLAY # Leash holder mob type (ALLAY/FOX/WOLF etc.)
update_interval_ticks: 1 # Leash holder update interval
offset_y: 0.2 # Leash holder vertical offset
selection:
tool: GOLDEN_HOE # Stop area selection tool
interact:
type: SUBTITLE # Display type for rail ETA: ACTIONBAR, TITLE, SUBTITLE
stay_ticks: 60 # Display duration in ticks
chunk_loading: # Global mode chunk loading strategy
enabled: true
radius: 2 # Loading radius around each car (chunks)
forward_preload_radius: 1 # Forward preload radius
only_when_moving: false # Only load when moving
update_interval_ticks: 10 # Refresh interval
Travel Time Estimation (travel_time)
travel_time:
enabled: true # Enable Bayesian estimation
default_section_seconds: 20.0 # Default section travel time
prior_strength: 4.0 # Prior strength (virtual sample count)
outlier_sigma: 3.0 # Outlier filtering threshold (sigma)
decay_per_day: 0.95 # Daily decay factor
use_unboarded_samples: false # Whether to use unboarded samples
unboarded_weight: 0.2 # Unboarded sample weight
Local Mode Configuration (local)
local:
activation_radius: 96 # Player radius to trigger spawning (blocks)
spawn_lead_ticks: 120 # Target arrival lead time (ticks)
suppress_threshold_seconds: 10.0 # Suppression threshold if a train is arriving (seconds)
virtualization:
enabled: true # Enable virtualization
idle_ticks: 200 # Time to wait before recycling demand-free trains
lookahead_stops: 2 # Number of stops to check for demand
Physics Engine Configuration (physics)
physics:
lead_kinematic: true # Lead car driven kinematically
lookahead_blocks: 4 # Rail geometry lookahead blocks
trail_seconds: 10 # Trail buffer duration (seconds)
smoothing_lerp: 0.15 # Smoothing interpolation factor (0=instant, 0.3=smooth)
snap_to_rail: true # Snap to rail center
strict_when_has_passenger: true # Strict alignment when carrying passengers
position_only_mode: false # Position-only mode (cinematic/display use)
Station UI Configuration (titles)
Supports stop_continuous (Station HUD), arrive_stop (Arrival), terminal_stop (Terminus), departure (Journey Info), waiting (Waiting for departure) scenarios. See config.yml for full configuration.
Sound Configuration (sounds)
Supports departure, arrival, station_arrival, waiting sound sequences. See config.yml for full configuration.
Scoreboard Configuration (scoreboard)
scoreboard:
enabled: true # Enable scoreboard (Incompatible with Folia)
styles:
current_stop: "&f" # Current stop style
next_stop: "&a" # Next stop style
other_stops: "&7" # Other stops style
line_symbol: "●" # Line symbol
Tip: The plugin will automatically populate missing keys in config.yml on startup (preserving your existing values). Language files will also automatically merge new entries. No manual config updates are needed for upgrades.
Starting from this version, old settings.consist.* settings are deprecated and removed, consolidated into physics.*.
lines.yml example (Planned extension):
red:
name: Red Line
color: "&c"
ordered_stop_ids: [r1, r2, r3, r4]
terminus_name: "To R4"
max_speed: 0.6
service:
enabled: true
headway_seconds: 90
dwell_ticks: 100
train_cars: 4
direction_mode: bi_directional # bi_directional | circular | single_direction
first_departure_tick: 200
Commands
Basic Commands
/rail - Show main help menu
/rail reload - Reload configuration and data, rebuild line services
/rail gui - Open server-wide line GUI panel
/rail line status [lineId] - View global or specific line status
/rail line list - List all lines summary
/rail stop list - List all stops configuration status
Line Management (/rail line)
/rail line - Show line management help
/rail line create <id> <name> - Create new line
/rail line delete <id> - Delete line
/rail line list - List all lines
/rail line stops <id> - List all stops on a line (including stop point status)
/rail line control <id> <kinematic|leashed|reactive> - Set control mode for line
/rail line rename <id> <name> - Rename line
/rail line setcolor <id> <&code> - Set line color (e.g. &c for red)
/rail line addstop <id> <stopId> [index] - Add stop to line
/rail line delstop <id> <stopId> - Remove stop from line
/rail line service <id> <enable|disable> - Enable/Disable line service
/rail line setheadway <id> <seconds> - Set headway
/rail line setdwell <id> <ticks> - Set dwell time
/rail line settraincars <id> <count> - Set consist length
/rail line setterminus <id> <name> - Set terminus name
/rail line setmaxspeed <id> <speed> - Set max speed
/rail line setowner <id> <uuid> - Set line owner
/rail line trust <id> <uuid> - Add administrator
/rail line untrust <id> <uuid> - Remove administrator
Stop Management (/rail stop)
/rail stop - Show stop management help
/rail stop create <id> [name] - Create new stop
/rail stop delete <id> - Delete stop
/rail stop list - List all stops
/rail stop tp <id> - Teleport to stop
/rail stop rename <id> <name> - Rename stop
/rail stop setcorners <id> - Set stop region (use Golden Hoe to select corners)
/rail stop setpoint [id] [yaw] - Set stop point at current location (id optional if inside a stop, supports custom yaw)
/rail stop allowline <id> <lineId> - Allow line to pass through stop
/rail stop denyline <id> <lineId> - Deny line from passing through stop
/rail stop addtransfer <id> <lineId> - Add transfer line
/rail stop deltransfer <id> <lineId> - Remove transfer line
/rail stop settitle <id> <type> <field> <value> - Set custom title
/rail stop deltitle <id> <type> - Remove custom title
/rail stop setowner <id> <uuid> - Set stop owner
/rail stop trust <id> <uuid> - Add administrator
/rail stop untrust <id> <uuid> - Remove administrator
All commands support Tab completion.
All command feedback and prompts are integrated into the language system and will output text according to the player's selected language.
Permissions
railway.admin - Use all admin commands (Default: OP)
railway.use - Use basic plugin features (riding trains etc., Default: All players)
railway.line.create - Allow players to create new lines (Default: false)
railway.stop.create - Allow players to create new stops (Default: false)
Lines and stops support an owner and admin system. Permissions can managed via setowner, trust, and untrust commands. OPs and players with railway.admin permission can bypass ownership checks.
Run Modes
- local (Default): "Virtual Timetable + Proximity Spawning". Generates train entities only near players, balancing immersion and performance. Supports virtualization recycling (automatically clears trains with no demand).
- global: Always-on entities running continuously based on headway. Supports moving window chunk loading to ensure trains run normally throughout the route.
Control Modes
- kinematic: Lead car completely takes over movement. Followers strictly follow the trail. Stable on curves/slopes, keeps passengers synchronized. Recommended for high-speed lines and precise dispatching.
- reactive: Spacing control based on vanilla physics. Real-time correction to maintain consist. Balances vanilla feel and synchronization. Suitable for low-speed sightseeing lines.
- leashed: Visual connection via leashed mobs. Lightweight control, compatible with TrainCarts and other plugins. Suitable for displays and compatibility scenarios.
All control modes support line speed limits (max_speed), safe speed limits on curves/slopes, and strict passenger synchronization.
Metro Migration Guide
Railway is directly compatible with Metro data files. Migration steps:
- Install Railway plugin.
- Delete
Metro/config.yml (Recommended to use the new config generated by Railway).
- Copy
Metro/lines.yml and Metro/stops.yml to the Railway/ directory.
- Restart server.
- Use
/rail line list to confirm lines are loaded.
Folia Support
This plugin is declared Folia-compatible (folia-supported: true in plugin.yml). Because performance and scheduler behavior can vary by environment, run full regression and load tests before production rollout.
Physics Reference
TrainCarts, Metro
评论 0
登录后参与评分
还没有评论,来抢沙发吧