Skip to content

Commit 1a04b84

Browse files
authored
Merge branch 'dev' into feat/update
2 parents 1e7cb69 + e3dc7ac commit 1a04b84

17 files changed

Lines changed: 138 additions & 103 deletions

File tree

‎.github/workflows/reusable-build.yml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ jobs:
2929
echo "describe=$describe" >> $GITHUB_ENV
3030
3131
- name: Setup .NET SDK
32-
uses: actions/setup-dotnet@v4
32+
uses: actions/setup-dotnet@v5
3333
with:
34-
dotnet-version: '9.0.x'
34+
dotnet-version: 10.0.x
3535

3636
- name: Update Help
3737
continue-on-error: true
@@ -60,7 +60,7 @@ jobs:
6060
run: |
6161
dotnet publish "Plain Craft Launcher 2/Plain Craft Launcher 2.vbproj" \
6262
-p:Configuration=${{ inputs.configuration }} -p:Platform=${{ inputs.architecture }} \
63-
-p:DeleteExistingFiles=true -o ./artifact --self-contained false
63+
-p:DeleteExistingFiles=true -o ./artifact --no-self-contained
6464
6565
- name: Upload the Build Artifact
6666
uses: actions/upload-artifact@v4

‎PCL.Test/Network/DohConnection.cs‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using System;
2+
using System.Net;
3+
using System.Net.Http;
4+
using System.Threading.Tasks;
5+
using Microsoft.VisualStudio.TestTools.UnitTesting;
6+
using PCL.Core.Net;
7+
8+
namespace PCL.Test.Network;
9+
10+
[TestClass]
11+
public class DohConnection
12+
{
13+
[TestMethod]
14+
public async Task TestDohConnection()
15+
{
16+
using var client = new HttpClient(new SocketsHttpHandler()
17+
{
18+
ConnectCallback = HostConnectionHandler.Instance.GetConnectionAsync
19+
}
20+
);
21+
var request = new HttpRequestMessage(HttpMethod.Get, "https://www.cloudflare.com/cdn-cgi/trace");
22+
request.Version = HttpVersion.Version30;
23+
using var response = await client.SendAsync(request, TestContext.CancellationTokenSource.Token);
24+
Assert.IsTrue(response.IsSuccessStatusCode);
25+
Assert.IsTrue(response.Content.Headers.ContentLength > 0);
26+
Console.WriteLine(await response.Content.ReadAsStringAsync(TestContext.CancellationTokenSource.Token));
27+
}
28+
29+
public TestContext TestContext { get; set; }
30+
}

‎PCL.Test/PCL.Test.csproj‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>net8.0-windows10.0.17763.0</TargetFramework>
3+
<TargetFramework>net8.0-windows</TargetFramework>
44
<OutputType>Library</OutputType>
5-
<LangVersion>13.0</LangVersion>
5+
<LangVersion>14.0</LangVersion>
66
<Nullable>enable</Nullable>
77
<Configuration Condition="'$(Configuration)' == ''">Debug</Configuration>
88
<Platform Condition="'$(Platform)' == ''">AnyCPU</Platform>
@@ -13,6 +13,7 @@
1313
<Copyright>Copyright © PCL Community 2025</Copyright>
1414
<AssemblyVersion>1.0.0.0</AssemblyVersion>
1515
<FileVersion>1.0.0.0</FileVersion>
16+
<EnableWindowsTargeting>true</EnableWindowsTargeting>
1617
<UseWPF>true</UseWPF>
1718
</PropertyGroup>
1819
<PropertyGroup>

‎Plain Craft Launcher 2.slnx‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
<Platform Name="ARM64" />
99
<Platform Name="x64" />
1010
</Configurations>
11-
<Project Path="PCL.Core\PCL.Core.csproj" Type="Classic C#"/>
12-
<Project Path="PCL.Core\SourceGenerators\PCL.Core.SourceGenerators.csproj" Type="Classic C#" />
13-
<Project Path="PCL.Test\PCL.Test.csproj" Type="Classic C#">
14-
<Configuration Solution="*|*" Project="*|*|NoBuild" />
11+
<Project Path="PCL.Core\PCL.Core.csproj" Type="C#" />
12+
<Project Path="PCL.Core\SourceGenerators\PCL.Core.SourceGenerators.csproj" Type="C#" />
13+
<Project Path="PCL.Test\PCL.Test.csproj" Type="C#">
14+
<Build Solution="*|*" Project="false" />
1515
</Project>
16-
<Project Path="Plain Craft Launcher 2\Plain Craft Launcher 2.vbproj" Type="Classic VB" />
16+
<Project Path="Plain Craft Launcher 2\Plain Craft Launcher 2.vbproj" Type="VB" />
1717
</Solution>

‎Plain Craft Launcher 2/Controls/FontSelector.xaml.vb‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ Public Class FontSelector
4242
Private Sub LoadFonts()
4343
Dispatcher.BeginInvoke(Async Function() As Task
4444
ComboFont.IsEnabled = False
45+
_isInitializing = True
4546
CustomFontCollection.Add(New CustomFontProperties() With {.Name = "加载中..."})
4647
ComboFont.SelectedIndex = 0
4748
Dim availableFonts As New List(Of KeyValuePair(Of String, FontFamily))
@@ -86,9 +87,11 @@ Public Class FontSelector
8687
_pendingFontTag = Nothing
8788
SelectedFontTag = pendingTag
8889
End If
90+
_isInitializing = False
8991
End Function)
9092
End Sub
9193

94+
Private _isInitializing As Boolean = False
9295
Private _pendingFontTag As String = Nothing
9396

9497
Public Property SelectedFontTag As String
@@ -104,13 +107,17 @@ Public Class FontSelector
104107
_pendingFontTag = value
105108
Return
106109
End If
107-
110+
111+
_isInitializing = True
112+
108113
Dim targetSelection = CustomFontCollection.FirstOrDefault(Function(i) i.Tag = value)
109114
If targetSelection Is Nothing Then
110115
ComboFont.SelectedIndex = 0
111116
Else
112117
ComboFont.SelectedItem = targetSelection
113118
End If
119+
120+
_isInitializing = False
114121
End Set
115122
End Property
116123

@@ -133,7 +140,9 @@ Public Class FontSelector
133140
End Property
134141

135142
Private Sub ComboFont_SelectionChanged(sender As Object, e As SelectionChangedEventArgs) Handles ComboFont.SelectionChanged
136-
RaiseEvent SelectionChanged(sender, e)
143+
If Not _isInitializing Then
144+
RaiseEvent SelectionChanged(sender, e)
145+
End If
137146
End Sub
138147

139148
End Class

‎Plain Craft Launcher 2/Controls/MyImage.vb‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ Public Class MyImage
118118
End If
119119
'从缓存加载网络图片
120120
Dim Url As String = Source
121-
Dim Retried As Boolean = False
122121
Dim TempPath As String = GetTempPath(Url)
123122
Dim TempFile As New FileInfo(TempPath)
124123
Dim EnableCache As Boolean = Me.EnableCache
@@ -133,9 +132,10 @@ Public Class MyImage
133132
ActualSource = LoadingSource '显示加载中图片
134133
TempDownloadingPath = TempPath & RandomUtils.NextInt(0, 10000000)
135134
Directory.CreateDirectory(GetPathFromFullPath(TempPath)) '重新实现下载,以避免携带 Header(#5072)
136-
Using fs As New FileStream(TempDownloadingPath, FileMode.Create)
135+
Using fs As New FileStream(TempDownloadingPath, FileMode.Create, FileAccess.ReadWrite, FileShare.Read)
137136
Using response = Await HttpRequestBuilder.Create(Url, HttpMethod.Get).
138137
WithHttpVersionOption(HttpVersion.Version30).
138+
WithDefaultHeaderOption(False).
139139
SendAsync()
140140
If response.IsSuccess Then
141141
Using nfs = Await response.AsStreamAsync()
@@ -145,11 +145,14 @@ Public Class MyImage
145145
Using fallbackResponse = Await HttpRequestBuilder.
146146
Create(FallbackSource, HttpMethod.Get).
147147
WithHttpVersionOption(HttpVersion.Version30).
148+
WithDefaultHeaderOption(False).
148149
SendAsync(True)
149-
fs.SetLength(0)
150-
Using fallbackNfs = Await fallbackResponse.AsStreamAsync()
151-
Await fallbackNfs.CopyToAsync(fs)
152-
End Using
150+
If fallbackResponse.IsSuccess Then
151+
fs.SetLength(0)
152+
Using fallbackNfs = Await fallbackResponse.AsStreamAsync()
153+
Await fallbackNfs.CopyToAsync(fs)
154+
End Using
155+
End If
153156
End Using
154157
End If
155158
End Using

‎Plain Craft Launcher 2/FormMain.xaml.vb‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,6 @@ Public Class FormMain
248248
Catch ex As Exception
249249
Log(ex, "清理自动更新文件失败")
250250
End Try
251-
GetCoR() '获取区域限制状态
252251
GetSystemInfo()
253252
End Sub, "Start Loader", ThreadPriority.Lowest)
254253

‎Plain Craft Launcher 2/Modules/Base/ModBase.vb‎

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ Public Module ModBase
1919
#Region "声明"
2020

2121
'下列版本信息由更新器自动修改
22-
Public Const VersionBaseName As String = "2.13.4-beta.1" '不含分支前缀的显示用版本名
22+
Public Const VersionBaseName As String = "2.13.4-beta.2" '不含分支前缀的显示用版本名
2323
Public Const VersionStandardCode As String = "2.13.4." & VersionBranchCode
2424
Public Const UpstreamVersion As String = "2.10.5" '上游版本
2525
Public ReadOnly CommitHash As String = If(EnvironmentInterop.GetSecret("GITHUB_SHA", False), "native") 'Commit Hash
2626
Public ReadOnly CommitHashShort As String = If(CommitHash = "native", "native", CommitHash.Substring(0, 7)) 'Commit Hash,取前 7 位
27-
Public Const VersionCode As Integer = 414 '内部版本号
27+
Public Const VersionCode As Integer = 415 '内部版本号
2828
'自动生成的版本信息
2929
#If DEBUG Then
3030
Public Const VersionBranchName As String = "Debug"
@@ -2034,15 +2034,6 @@ RetryDir:
20342034
Inherits Exception
20352035
End Class
20362036

2037-
Public IsRestrictedFeatAllowed As Boolean = False
2038-
''' <summary>
2039-
''' 获取区域限制状态,用于判断是否允许使用部分区域限制功能。
2040-
''' </summary>
2041-
Public Sub GetCoR()
2042-
If TimeZoneInfo.Local.Id = "China Standard Time" AndAlso
2043-
(CultureInfo.CurrentCulture.Name = "zh-CN" OrElse CultureInfo.CurrentUICulture.Name = "zh-CN") Then IsRestrictedFeatAllowed = True
2044-
End Sub
2045-
20462037
Private Uuid As Integer = 1
20472038
Private UuidLock As Object
20482039
''' <summary>
@@ -2220,6 +2211,7 @@ NextElement:
22202211
''' 为防止线程互锁,请仅在开始加载动画、从 UI 获取输入时使用!
22212212
''' </summary>
22222213
Public Sub RunInUiWait(Action As Action)
2214+
If Application.Current Is Nothing Then Exit Sub
22232215
If RunInUi() Then
22242216
Action()
22252217
Else
@@ -2231,12 +2223,11 @@ NextElement:
22312223
''' 如果当前并非 UI 线程,也不阻断当前线程的执行。
22322224
''' </summary>
22332225
Public Sub RunInUi(Action As Action, Optional ForceWaitUntilLoaded As Boolean = False)
2234-
If ForceWaitUntilLoaded Then
2235-
Application.Current.Dispatcher.InvokeAsync(Action, Threading.DispatcherPriority.Loaded)
2236-
ElseIf RunInUi() Then
2226+
If Application.Current Is Nothing Then Exit Sub
2227+
If RunInUi() Then
22372228
Action()
22382229
Else
2239-
Application.Current.Dispatcher.InvokeAsync(Action)
2230+
Application.Current.Dispatcher.InvokeAsync(Action, If(ForceWaitUntilLoaded, Threading.DispatcherPriority.Loaded, Threading.DispatcherPriority.Normal))
22402231
End If
22412232
End Sub
22422233
''' <summary>

‎Plain Craft Launcher 2/Modules/Minecraft/ModLaunch.vb‎

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -293,31 +293,15 @@ NextInner:
293293
End If
294294
#End If
295295
'正版购买提示
296-
If CurrentLaunchOptions?.SaveBatch Is Nothing AndAlso '保存脚本时不提示
297-
Not Setup.Get("HintBuy") AndAlso SelectedProfile.Type <> McLoginType.Ms Then
298-
If IsRestrictedFeatAllowed Then
299-
RunInNewThread(
300-
Sub()
301-
Select Case Setup.Get("SystemLaunchCount")
302-
Case 3, 8, 15, 30, 50, 70, 90, 110, 130, 180, 220, 280, 330, 380, 450, 550, 660, 750, 880, 950, 1100, 1300, 1500, 1700, 1900
303-
If MyMsgBox("你已经启动了 " & Setup.Get("SystemLaunchCount") & " 次 Minecraft 啦!" & vbCrLf &
304-
"如果觉得 Minecraft 还不错,可以购买正版支持一下,毕竟开发游戏也真的很不容易……不要一直白嫖啦。" & vbCrLf & vbCrLf &
305-
"在登录一次正版账号后,就不会再出现这个提示了!",
306-
"考虑一下正版?", "支持正版游戏!", "下次一定") = 1 Then
307-
OpenWebsite("https://www.xbox.com/zh-cn/games/store/minecraft-java-bedrock-edition-for-pc/9nxp44l49shj")
308-
End If
309-
End Select
310-
End Sub, "Buy Minecraft")
311-
Else
312-
Select Case MyMsgBox("你必须先登录正版账号才能启动游戏!", "正版验证", "购买正版", "试玩", "返回",
296+
If Not ProfileList.Any(Function(x) x.Type = McLoginType.Ms) Then
297+
Select Case MyMsgBox("你必须先登录正版账号才能启动游戏!", "正版验证", "购买正版", "试玩", "返回",
313298
Button1Action:=Sub() OpenWebsite("https://www.xbox.com/zh-cn/games/store/minecraft-java-bedrock-edition-for-pc/9nxp44l49shj"))
314-
Case 2
315-
Hint("游戏将以试玩模式启动!", HintType.Critical)
316-
CurrentLaunchOptions.ExtraArgs.Add("--demo")
317-
Case 3
318-
Throw New Exception("$$")
319-
End Select
320-
End If
299+
Case 2
300+
Hint("游戏将以试玩模式启动!", HintType.Critical)
301+
CurrentLaunchOptions.ExtraArgs.Add("--demo")
302+
Case 3
303+
Throw New Exception("$$")
304+
End Select
321305
End If
322306
End Sub
323307

@@ -594,7 +578,6 @@ SkipLogin:
594578
'结束
595579
McLoginMsRefreshTime = TimeUtils.GetTimeTick()
596580
ProfileLog("正版验证完成")
597-
Setup.Set("HintBuy", True) '关闭正版购买提示
598581
If IsSkipAuth Then
599582
Data.Progress = 0.99
600583
Data.Output = New McLoginResult With {.AccessToken = SelectedProfile.AccessToken,

0 commit comments

Comments
 (0)