Skip to content

Commit 16e09c7

Browse files
committed
2.9.3
1 parent 36cc718 commit 16e09c7

21 files changed

+1718
-682
lines changed

Plain Craft Launcher 2/FormMain.xaml.vb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ Public Class FormMain
1010
Dim FeatureList As New List(Of KeyValuePair(Of Integer, String))
1111
'统计更新日志条目
1212
#If BETA Then
13+
If LastVersion < 354 Then 'Release 2.9.3
14+
FeatureList.Add(New KeyValuePair(Of Integer, String)(3, "优化:Minecraft 会优先使用独立显卡运行"))
15+
FeatureList.Add(New KeyValuePair(Of Integer, String)(3, "优化:简化下载新版本第二步的 UI"))
16+
FeatureList.Add(New KeyValuePair(Of Integer, String)(2, "优化:使用新的版本隔离策略"))
17+
FeatureList.Add(New KeyValuePair(Of Integer, String)(2, "优化:添加了在全局启动设置与版本独立设置之间互相跳转的按钮"))
18+
FeatureCount += 20
19+
BugCount += 28
20+
End If
1321
If LastVersion < 352 Then 'Release 2.9.1
1422
FeatureList.Add(New KeyValuePair(Of Integer, String)(5, "新增:导出整合包功能"))
1523
FeatureList.Add(New KeyValuePair(Of Integer, String)(2, "优化:支持在超长路径下安装、启动游戏"))
@@ -58,6 +66,14 @@ Public Class FormMain
5866
'3:BUG+ IMP* FEAT-
5967
'2:BUG* IMP-
6068
'1:BUG-
69+
If LastVersion < 353 Then 'Snapshot 2.9.3
70+
If LastVersion = 352 Then
71+
FeatureList.Add(New KeyValuePair(Of Integer, String)(1, "修复:低版本 MC 没有声音"))
72+
FeatureList.Add(New KeyValuePair(Of Integer, String)(1, "修复:若不安装 Mod 加载器,则无法安装 OptiFine 1.14+"))
73+
End If
74+
FeatureCount += 8
75+
BugCount += 8
76+
End If
6177
If LastVersion < 352 Then 'Snapshot 2.9.2
6278
FeatureList.Add(New KeyValuePair(Of Integer, String)(3, "优化:Minecraft 会优先使用独立显卡运行"))
6379
FeatureList.Add(New KeyValuePair(Of Integer, String)(3, "优化:简化下载新版本第二步的 UI"))

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

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11
Imports System.Globalization
22
Imports System.IO.Compression
3+
Imports System.Reflection
34
Imports System.Runtime.CompilerServices
45
Imports System.Security.Cryptography
56
Imports System.Security.Principal
67
Imports System.Text.RegularExpressions
7-
Imports System.Windows.Markup
8+
Imports System.Xaml
89
Imports Newtonsoft.Json
910

1011
Public Module ModBase
1112

1213
#Region "声明"
1314

1415
'下列版本信息由更新器自动修改
15-
Public Const VersionBaseName As String = "2.9.2" '不含分支前缀的显示用版本名
16-
Public Const VersionStandardCode As String = "2.9.2." & VersionBranchCode '标准格式的四段式版本号
16+
Public Const VersionBaseName As String = "2.9.3" '不含分支前缀的显示用版本名
17+
Public Const VersionStandardCode As String = "2.9.3." & VersionBranchCode '标准格式的四段式版本号
1718
Public Const CommitHash As String = "" 'Commit Hash,由 GitHub Workflow 自动替换
1819
#If BETA Then
19-
Public Const VersionCode As Integer = 352 'Release
20+
Public Const VersionCode As Integer = 355 'Release
2021
#Else
21-
Public Const VersionCode As Integer = 353 'Snapshot
22+
Public Const VersionCode As Integer = 354 'Snapshot
2223
#End If
2324
'自动生成的版本信息
2425
Public Const VersionDisplayName As String = VersionBranchName & " " & VersionBaseName
@@ -1697,6 +1698,7 @@ RetryDir:
16971698
End Function
16981699
''' <summary>
16991700
''' 获取处于两个子字符串之间的部分,裁切尽可能多的内容。
1701+
''' 等效于 AfterLast 后接 BeforeFirst。
17001702
''' 如果未找到子字符串则不裁切。
17011703
''' </summary>
17021704
<Extension> Public Function Between(Str As String, After As String, Before As String, Optional IgnoreCase As Boolean = False) As String
@@ -2747,13 +2749,27 @@ Retry:
27472749
''' <summary>
27482750
''' 将 XML 转换为对应 UI 对象。
27492751
''' </summary>
2750-
Public Function GetObjectFromXML(Str As String)
2751-
Using Stream As New MemoryStream
2752+
Public Function GetObjectFromXML(Str As String) As Object
2753+
Using Stream As New MemoryStream(Encoding.UTF8.GetBytes(Str))
2754+
'类型检查
2755+
Using Reader As New XamlXmlReader(Stream)
2756+
While Reader.Read()
2757+
For Each BlackListType In {GetType(WebBrowser), GetType(Frame), GetType(MediaElement), GetType(ObjectDataProvider), GetType(XamlReader), GetType(Window), GetType(XmlDataProvider)}
2758+
If Reader.Type IsNot Nothing AndAlso BlackListType.IsAssignableFrom(Reader.Type.UnderlyingType) Then Throw New UnauthorizedAccessException($"不允许使用 {BlackListType.Name} 类型。")
2759+
If Reader.Value IsNot Nothing AndAlso Reader.Value = BlackListType.Name Then Throw New UnauthorizedAccessException($"不允许使用 {BlackListType.Name} 值。")
2760+
Next
2761+
For Each BlackListMember In {"Code", "FactoryMethod", "Static"}
2762+
If Reader.Member IsNot Nothing AndAlso Reader.Member.Name = BlackListMember Then Throw New UnauthorizedAccessException($"不允许使用 {BlackListMember} 成员。")
2763+
Next
2764+
End While
2765+
End Using
2766+
'实际的加载
2767+
Stream.Position = 0
27522768
Using Writer As New StreamWriter(Stream)
27532769
Writer.Write(Str)
27542770
Writer.Flush()
27552771
Stream.Position = 0
2756-
Return XamlReader.Load(Stream)
2772+
Return Markup.XamlReader.Load(Stream)
27572773
End Using
27582774
End Using
27592775
End Function

Plain Craft Launcher 2/Modules/Base/ModValidate.vb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,13 @@ Public Class ValidateExcept
150150
Public Property Excepts As ObjectModel.Collection(Of String) = New ObjectModel.Collection(Of String)
151151
Public Property ErrorMessage As String
152152
Public Sub New()
153-
ErrorMessage = "输入内容不能包含 %"
153+
ErrorMessage = "输入内容不能包含 %"
154154
End Sub '用于 XAML 初始化
155-
Public Sub New(Excepts As ObjectModel.Collection(Of String), Optional ErrorMessage As String = "输入内容不能包含 %")
155+
Public Sub New(Excepts As ObjectModel.Collection(Of String), Optional ErrorMessage As String = "输入内容不能包含 %")
156156
Me.Excepts = Excepts
157157
Me.ErrorMessage = ErrorMessage
158158
End Sub
159-
Public Sub New(Excepts As IEnumerable, Optional ErrorMessage As String = "输入内容不能包含 %")
159+
Public Sub New(Excepts As IEnumerable, Optional ErrorMessage As String = "输入内容不能包含 %")
160160
Me.Excepts = New ObjectModel.Collection(Of String)
161161
Me.ErrorMessage = ErrorMessage
162162
For Each Data As String In Excepts
@@ -185,12 +185,12 @@ Public Class ValidateExceptSame
185185
Public Property IgnoreCase As Boolean = False
186186
Public Sub New()
187187
End Sub
188-
Public Sub New(Excepts As ObjectModel.Collection(Of String), Optional ErrorMessage As String = "输入内容不能为 %", Optional IgnoreCase As Boolean = False)
188+
Public Sub New(Excepts As ObjectModel.Collection(Of String), Optional ErrorMessage As String = "输入内容不能为 %", Optional IgnoreCase As Boolean = False)
189189
Me.Excepts = Excepts
190190
Me.ErrorMessage = ErrorMessage
191191
Me.IgnoreCase = IgnoreCase
192192
End Sub
193-
Public Sub New(Excepts As IEnumerable, Optional ErrorMessage As String = "输入内容不能为 %", Optional IgnoreCase As Boolean = False)
193+
Public Sub New(Excepts As IEnumerable, Optional ErrorMessage As String = "输入内容不能为 %", Optional IgnoreCase As Boolean = False)
194194
Me.Excepts = New ObjectModel.Collection(Of String)
195195
For Each Data As String In Excepts
196196
Me.Excepts.Add(Data)

Plain Craft Launcher 2/Modules/Minecraft/ModCrash.vb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -563,8 +563,9 @@ Done:
563563
If LogCrash.Contains("has mods that were not found") AndAlso RegexCheck(LogCrash, "The Mod File [^\n]+optifine\\OptiFine[^\n]+ has mods that were not found") Then AppendReason(CrashReason.OptiFine与Forge不兼容)
564564
'Mod 导致的崩溃
565565
If LogCrash.Contains("-- MOD ") Then
566-
If LogCrash.Between("-- MOD ", "Failure message:").ContainsF(".jar", True) Then
567-
AppendReason(CrashReason.确定Mod导致游戏崩溃, If(RegexSeek(LogCrash, "(?<=Mod File: ).+"), "").TrimEnd((vbCrLf & " ").ToCharArray))
566+
Dim LogCrashMod As String = LogCrash.Between("-- MOD ", "Failure message:")
567+
If LogCrashMod.ContainsF(".jar", True) Then
568+
AppendReason(CrashReason.确定Mod导致游戏崩溃, If(RegexSeek(LogCrashMod, "(?<=Mod File: ).+"), "").TrimEnd((vbCrLf & " ").ToCharArray))
568569
Else
569570
AppendReason(CrashReason.Mod加载器报错, If(RegexSeek(LogCrash, "(?<=Failure message: )[\w\W]+?(?=\tMod)"), "").Replace(vbTab, " ").TrimEnd((vbCrLf & " ").ToCharArray))
570571
End If

Plain Craft Launcher 2/Modules/Minecraft/ModJava.vb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,13 +674,14 @@ Wait:
674674
'若该目录有 Java,则加入结果
675675
If File.Exists(Path & "javaw.exe") Then Results(Path) = Source
676676
'查找其下的所有文件夹
677+
'不应使用网易的 Java:https://github.com/Hex-Dragon/PCL2/issues/1279#issuecomment-2761489121
677678
Dim Keywords = {"java", "jdk", "env", "环境", "run", "软件", "jre", "mc", "dragon",
678679
"soft", "cache", "temp", "corretto", "roaming", "users", "craft", "program", "世界", "net",
679680
"游戏", "oracle", "game", "file", "data", "jvm", "服务", "server", "客户", "client", "整合",
680681
"应用", "运行", "前置", "mojang", "官启", "新建文件夹", "eclipse", "microsoft", "hotspot",
681682
"runtime", "x86", "x64", "forge", "原版", "optifine", "官方", "启动", "hmcl", "mod", "高清",
682683
"download", "launch", "程序", "path", "version", "baka", "pcl", "zulu", "local", "packages",
683-
"4297127d64ec6", "国服", "网易", "ext", "netease", "1.", "启动"}
684+
"4297127d64ec6", "1.", "启动"}
684685
For Each FolderInfo As DirectoryInfo In OriginalPath.EnumerateDirectories
685686
If FolderInfo.Attributes.HasFlag(FileAttributes.ReparsePoint) Then Continue For '跳过符号链接
686687
Dim SearchEntry = GetFolderNameFromPath(FolderInfo.Name).ToLower '用于搜索的字符串

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

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -220,21 +220,24 @@ NextInner:
220220
If CheckResult <> "" Then Throw New ArgumentException(CheckResult)
221221
#If BETA Then
222222
'求赞助
223-
RunInNewThread(
224-
Sub()
225-
Select Case Setup.Get("SystemLaunchCount")
226-
Case 10, 20, 40, 60, 80, 100, 120, 150, 200, 250, 300, 350, 400, 500, 600, 700, 800, 900, 1000, 1200, 1400, 1600, 1800, 2000
227-
If MyMsgBox("PCL 已经为你启动了 " & Setup.Get("SystemLaunchCount") & " 次游戏啦!" & vbCrLf &
228-
"如果 PCL 还算好用的话,能不能考虑赞助一下 PCL……" & vbCrLf &
229-
"如果没有大家的支持,PCL 很难在免费、无任何广告的情况下维持数年的更新(磕头)……!",
230-
Setup.Get("SystemLaunchCount") & " 次启动!", "支持 PCL!", "但是我拒绝") = 1 Then
231-
OpenWebsite("https://afdian.com/a/LTCat")
232-
End If
233-
End Select
234-
End Sub, "Donate")
223+
If CurrentLaunchOptions?.SaveBatch Is Nothing Then '保存脚本时不提示
224+
RunInNewThread(
225+
Sub()
226+
Select Case Setup.Get("SystemLaunchCount")
227+
Case 10, 20, 40, 60, 80, 100, 120, 150, 200, 250, 300, 350, 400, 500, 600, 700, 800, 900, 1000, 1200, 1400, 1600, 1800, 2000
228+
If MyMsgBox("PCL 已经为你启动了 " & Setup.Get("SystemLaunchCount") & " 次游戏啦!" & vbCrLf &
229+
"如果 PCL 还算好用的话,能不能考虑赞助一下 PCL……" & vbCrLf &
230+
"如果没有大家的支持,PCL 很难在免费、无任何广告的情况下维持数年的更新(磕头)……!",
231+
Setup.Get("SystemLaunchCount") & " 次启动!", "支持 PCL!", "但是我拒绝") = 1 Then
232+
OpenWebsite("https://afdian.com/a/LTCat")
233+
End If
234+
End Select
235+
End Sub, "Donate")
236+
End If
235237
#End If
236238
'正版购买提示
237-
If Not Setup.Get("HintBuy") AndAlso Setup.Get("LoginType") <> McLoginType.Ms Then
239+
If CurrentLaunchOptions?.SaveBatch Is Nothing AndAlso '保存脚本时不提示
240+
Not Setup.Get("HintBuy") AndAlso Setup.Get("LoginType") <> McLoginType.Ms Then
238241
If IsSystemLanguageChinese() Then
239242
RunInNewThread(
240243
Sub()
@@ -1347,6 +1350,12 @@ Retry:
13471350
Arguments += " " & McLaunchArgumentsGameNew(McVersionCurrent)
13481351
McLaunchLog("新版 Game 参数获取成功")
13491352
End If
1353+
'编码参数(#5818、#5892)
1354+
If McLaunchJavaSelected.VersionCode > 8 Then
1355+
If Not Arguments.Contains("-Dfile.encoding=") Then Arguments += " -Dfile.encoding=UTF-8"
1356+
If Not Arguments.Contains("-Dstdout.encoding=") Then Arguments += " -Dstdout.encoding=UTF-8"
1357+
If Not Arguments.Contains("-Dstderr.encoding=") Then Arguments += " -Dstderr.encoding=UTF-8"
1358+
End If
13501359
'替换参数
13511360
Dim ReplaceArguments = McLaunchArgumentsReplace(McVersionCurrent, Loader)
13521361
If String.IsNullOrWhiteSpace(ReplaceArguments("${version_type}")) Then
@@ -1899,7 +1908,6 @@ NextVersion:
18991908
'1.6 ~ 10 :zh_CN 时正常,zh_cn 时自动切换为英文
19001909
'1.11 ~ 12:zh_cn 时正常,zh_CN 时虽然显示了中文但语言设置会错误地显示选择英文
19011910
'1.13+ :zh_cn 时正常,zh_CN 时自动切换为英文
1902-
IniClearCache(SetupFileAddress) '清除缓存(#2294)
19031911
Dim CurrentLang As String = ReadIni(SetupFileAddress, "lang", "none")
19041912
Dim RequiredLang As String = If(CurrentLang = "none" OrElse Not Directory.Exists(McVersionCurrent.PathIndie & "saves"), '#3844,整合包可能已经自带了 options.txt
19051913
If(Setup.Get("ToolHelpChinese"), "zh_cn", "en_us"), CurrentLang.ToLower)

0 commit comments

Comments
 (0)