Files
RustNotMC/rsx-server-core/scripts/run-server.ps1
T
sasheg dev fbd01df884 Чат и список игроков
- Протокол: Chat (что сказал сервер), ChatSend (что сказал клиент) и PlayerList
  (весь список игроков с их режимами).
- Сервер: сообщения уходят всем, а имя отправителя ставит сервер, поэтому подделать
  его нельзя. Список игроков уходит всем целиком, когда он меняется. Команды
  сервера: /help и /players.
- Клиент: перевод наших пакетов в игровые (SPacketChat и SPacketPlayerListItem),
  уходящий чат перехватывается патчем, список игроков обновляется по разнице
  (ушедших убираем, пришедших добавляем).
- Тесты: два игрока, один пишет - второй слышит с правильным именем; список
  игроков приходит обоим и меняется, когда кто-то выходит.

Попутно: run-server.ps1 теперь знает про rsx-plugin-api, иначе сервер не
запускался (нет класса Hitboxes в classpath).

Тесты: протокол 34, сервер 87. Форк собирается чисто.
2026-10-21 23:10:21 +03:00

63 lines
2.2 KiB
PowerShell

# Starts the server. Needs rsx-protocol and rsx-auth built first.
#
# ASCII only, for the same reason as the other scripts.
#
# run-server.ps1 [-Port 25565] [-Accounts path] [-Capacity 200] [-World path]
param(
[int]$Port = 25565,
[string]$Accounts = '',
[int]$Capacity = 200,
[string]$Name = 'RustNotMC',
[string]$Motd = 'a survival game',
[string]$Register = '',
[string]$Password = '',
[string]$World = '',
[long]$Seed = 0
)
$ErrorActionPreference = 'Stop'
$Repo = Split-Path -Parent $PSScriptRoot
if (-not $Repo) { $Repo = $PSCommandPath | Split-Path -Parent | Split-Path -Parent }
$Workspace = Split-Path -Parent $Repo
$Protocol = Join-Path $Workspace 'rsx-protocol\build\classes'
$Auth = Join-Path $Workspace 'rsx-auth\build\classes'
$PluginApi = Join-Path $Workspace 'rsx-plugin-api\build\classes'
$Server = Join-Path $Repo 'build\classes'
foreach ($dep in @($Protocol, $Auth, $PluginApi, $Server)) {
if (-not (Test-Path $dep)) {
Write-Host " Missing: $dep" -ForegroundColor Red
Write-Host ' Build rsx-protocol, rsx-auth and rsx-server-core first.' -ForegroundColor Red
exit 1
}
}
if (-not $Accounts) { $Accounts = Join-Path $Repo 'accounts.txt' }
if (-not $World) { $World = Join-Path $Repo 'world' }
if ($Register) {
& java -cp "$Protocol;$Auth;$PluginApi;$Server" net.rustnotmc.server.ServerMain `
--accounts $Accounts --register $Register --password $Password
exit $LASTEXITCODE
}
Write-Host ' rsx-protocol ' -NoNewline
Write-Host (Split-Path -Leaf $Protocol) -ForegroundColor DarkGray
Write-Host ' rsx-auth ' -NoNewline
Write-Host (Split-Path -Leaf $Auth) -ForegroundColor DarkGray
Write-Host ' rsx-server-core ' -NoNewline
Write-Host (Split-Path -Leaf $Server) -ForegroundColor DarkGray
Write-Host ''
Write-Host " accounts : $Accounts"
Write-Host " world : $World"
Write-Host " seed : $Seed"
Write-Host " port : $Port"
Write-Host " capacity : $Capacity"
Write-Host ''
& java -cp "$Protocol;$Auth;$PluginApi;$Server" net.rustnotmc.server.ServerMain `
--port $Port --accounts $Accounts --capacity $Capacity --name $Name --motd $Motd `
--world $World --seed $Seed
exit $LASTEXITCODE