From 9bc39f8a95401c305bc455c7e4bf33135f2150b7 Mon Sep 17 00:00:00 2001 From: ENC_Euphony <2330458484@qq.com> Date: Sun, 3 Aug 2025 18:40:52 +0800 Subject: [PATCH] =?UTF-8?q?fix(ModDownload):=20=E4=BF=AE=E5=A4=8Dmc?= =?UTF-8?q?=E5=90=8C=E4=B8=80=E7=89=88=E6=9C=AC=E6=9B=B4=E6=96=B0=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E5=8F=AF=E8=83=BD=E5=A4=9A=E6=AC=A1=E5=87=BA=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Modules/Minecraft/ModDownload.vb | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb b/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb index f2f9923..f543811 100644 --- a/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb +++ b/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb @@ -196,6 +196,7 @@ ''' Public DlClientListMojangLoader As New LoaderTask(Of String, DlClientListResult)("DlClientList Mojang", AddressOf DlClientListMojangMain) Private IsNewClientVersionHinted As Boolean = False + Private ReadOnly HintLock As New Object() ' 线程安全锁 Private Sub DlClientListMojangMain(Loader As LoaderTask(Of String, DlClientListResult)) Dim StartTime As Long = GetTimeTick() Dim Json As JObject = GetJson(NetRequestByClientRetry("https://launchermeta.mojang.com/mc/game/version_manifest.json")) @@ -215,15 +216,24 @@ '解析更新提示(Release) Dim Version As String = Json("latest")("release") If Setup.Get("ToolUpdateRelease") AndAlso Not Setup.Get("ToolUpdateReleaseLast") = "" AndAlso Version IsNot Nothing AndAlso Not Setup.Get("ToolUpdateReleaseLast") = Version Then - McDownloadClientUpdateHint(Version, Json) - IsNewClientVersionHinted = True + SyncLock HintLock + If Not IsNewClientVersionHinted Then ' 在锁内再次检查 + McDownloadClientUpdateHint(Version, Json) + IsNewClientVersionHinted = True + End If + End SyncLock End If McVersionHighest = Version.Split(".")(1) Setup.Set("ToolUpdateReleaseLast", Version) '解析更新提示(Snapshot) Version = Json("latest")("snapshot") - If Setup.Get("ToolUpdateSnapshot") AndAlso Not Setup.Get("ToolUpdateSnapshotLast") = "" AndAlso Version IsNot Nothing AndAlso Not Setup.Get("ToolUpdateSnapshotLast") = Version AndAlso Not IsNewClientVersionHinted Then - McDownloadClientUpdateHint(Version, Json) + If Setup.Get("ToolUpdateSnapshot") AndAlso Not Setup.Get("ToolUpdateSnapshotLast") = "" AndAlso Version IsNot Nothing AndAlso Not Setup.Get("ToolUpdateSnapshotLast") = Version Then + SyncLock HintLock + If Not IsNewClientVersionHinted Then ' 在锁内再次检查 + McDownloadClientUpdateHint(Version, Json) + IsNewClientVersionHinted = True + End If + End SyncLock End If Setup.Set("ToolUpdateSnapshotLast", If(Version, "Nothing")) Catch ex As Exception