Update .gitignore to include sync-mods-from-client.ps1 for better management of server scripts and update Minecraft instance configuration to reflect the latest mod loader details.
This commit is contained in:
@@ -0,0 +1,98 @@
|
||||
#!/usr/bin/env pwsh
|
||||
# Копирует *.jar из ../mods в ./mods (тот же инстанс).
|
||||
# Не копирует jar, если имя совпадает с одним из шаблонов ниже (только клиент).
|
||||
# Шаблоны — как в PowerShell -like: * и ? (регистр не важен).
|
||||
# Выключенные NeoForge (*.jar.disabled) фильтром *.jar не подхватываются.
|
||||
# Односторонняя синхронизация: клиент -> сервер. Лишние jar на сервере не удаляются.
|
||||
param(
|
||||
[switch] $DryRun
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
# Дополняй при установке новых клиентских модов.
|
||||
$ClientOnlyJarLikePatterns = @(
|
||||
'BadOptimizations-*'
|
||||
'BetterF3-*'
|
||||
'BHMenu-*'
|
||||
'catalogue-*'
|
||||
'clientcrafting-*'
|
||||
'Controlling-*'
|
||||
'defaultoptions-*'
|
||||
'dynamic-fps-*'
|
||||
'entity_model_features_*'
|
||||
'entity_texture_features_*'
|
||||
'entityculling-*'
|
||||
'fast-ip-ping-*'
|
||||
'fancymenu_*'
|
||||
'gpumemleakfix-*'
|
||||
'ImmediatelyFast-*'
|
||||
'iris-*'
|
||||
'konkrete_*'
|
||||
'loadingbackgrounds-*'
|
||||
'mace3d-*'
|
||||
'melody_*'
|
||||
'MouseTweaks-*'
|
||||
'reeses-sodium-options-*'
|
||||
'sodium-neoforge-*'
|
||||
'sodiumextras-*'
|
||||
'sodiumoptionsapi-*'
|
||||
'time_on_display-*'
|
||||
'ToastControl-*'
|
||||
)
|
||||
|
||||
function Test-ClientOnlyJarName([string] $fileName) {
|
||||
foreach ($pattern in $ClientOnlyJarLikePatterns) {
|
||||
if ($fileName -like $pattern) {
|
||||
return $true
|
||||
}
|
||||
}
|
||||
return $false
|
||||
}
|
||||
|
||||
$instanceRoot = Split-Path $PSScriptRoot -Parent
|
||||
$src = Join-Path $instanceRoot "mods"
|
||||
$dst = Join-Path $PSScriptRoot "mods"
|
||||
|
||||
if (-not (Test-Path -LiteralPath $src)) {
|
||||
Write-Error "Клиентские моды не найдены: $src"
|
||||
}
|
||||
|
||||
if (-not (Test-Path -LiteralPath $dst)) {
|
||||
if ($DryRun) {
|
||||
Write-Host "[dry-run] Создал бы папку: $dst"
|
||||
} else {
|
||||
New-Item -ItemType Directory -Path $dst -Force | Out-Null
|
||||
}
|
||||
}
|
||||
|
||||
$copied = [System.Collections.Generic.List[string]]::new()
|
||||
$skippedClient = 0
|
||||
|
||||
foreach ($jar in Get-ChildItem -LiteralPath $src -File -Filter "*.jar") {
|
||||
if (Test-ClientOnlyJarName $jar.Name) {
|
||||
$skippedClient++
|
||||
if ($DryRun) {
|
||||
Write-Host "[dry-run] пропуск (клиент): $($jar.Name)"
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
$destPath = Join-Path $dst $jar.Name
|
||||
$copied.Add($jar.Name) | Out-Null
|
||||
|
||||
if ($DryRun) {
|
||||
Write-Host "[dry-run] $($jar.FullName) -> $destPath"
|
||||
continue
|
||||
}
|
||||
|
||||
Copy-Item -LiteralPath $jar.FullName -Destination $destPath -Force
|
||||
}
|
||||
|
||||
Write-Host ("Синхронизировано {0} jar: клиент -> Server/mods." -f $copied.Count)
|
||||
if ($skippedClient -gt 0) {
|
||||
Write-Host ("Пропущено клиентских (по списку в скрипте): {0}" -f $skippedClient)
|
||||
}
|
||||
if ($copied.Count -gt 0 -and $VerbosePreference -eq "Continue") {
|
||||
$copied | Sort-Object | ForEach-Object { Write-Host " $_" }
|
||||
}
|
||||
Reference in New Issue
Block a user