XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

XFEServerManager

【Java】我的世界XFE服务器管理器

公开
关注 0 Fork 0 Star 0
UTF-8
[CmdletBinding()]
param()

$ErrorActionPreference = 'Stop'
$rootDirectory = [System.IO.Path]::GetFullPath((Join-Path $PSScriptRoot '..'))

function Get-Sha256 {
    param([Parameter(Mandatory)][string]$Path)

    $stream = [System.IO.File]::OpenRead($Path)
    $algorithm = [System.Security.Cryptography.SHA256]::Create()
    try {
        return -join ($algorithm.ComputeHash($stream) | ForEach-Object { $_.ToString('x2') })
    }
    finally {
        $algorithm.Dispose()
        $stream.Dispose()
    }
}

$expected = [ordered]@{
    'gradle/wrapper/gradle-wrapper.jar' = '55243ef57851f12b070ad14f7f5bb8302daceeebc5bce5ece5fa6edb23e1145c'
    'platform/forge-1.20.1/gradle/wrapper/gradle-wrapper.jar' = 'ed2c26eba7cfb93cc2b7785d05e534f07b5b48b5e7fc941921cd098628abca58'
    'platform/forge-1.20.6/gradle/wrapper/gradle-wrapper.jar' = '2db75c40782f5e8ba1fc278a5574bab070adccb2d21ca5a6e5ed840888448046'
    'platform/forge-1.21.1/gradle/wrapper/gradle-wrapper.jar' = '2db75c40782f5e8ba1fc278a5574bab070adccb2d21ca5a6e5ed840888448046'
    'platform/forge-1.21.11/gradle/wrapper/gradle-wrapper.jar' = '497c8c2a7e5031f6aa847f88104aa80a93532ec32ee17bdb8d1d2f67a194a9c7'
}

foreach ($entry in $expected.GetEnumerator()) {
    $path = Join-Path $rootDirectory $entry.Key
    if (-not (Test-Path -LiteralPath $path -PathType Leaf)) {
        throw "Missing wrapper: $($entry.Key)"
    }
    $actual = Get-Sha256 -Path $path
    if ($actual -ne $entry.Value) {
        throw "Wrapper checksum mismatch for $($entry.Key): expected $($entry.Value), actual $actual"
    }
}

Write-Host 'All committed Gradle wrapper JARs match their pinned checksums.'