龙腾猫跃 10 месяцев назад
Родитель
Сommit
a674630f54

+ 2 - 1
Plain Craft Launcher 2/Controls/MyImage.vb

@@ -126,7 +126,8 @@
             Try
                 '下载
                 NetDownloadByLoader(
-                    If(FallbackSource?.StartsWithF("http") AndAlso Source <> FallbackSource, {Source, FallbackSource}, {Source}),
+                    If(FallbackSource IsNot Nothing AndAlso FallbackSource.StartsWithF("http") AndAlso Source <> FallbackSource,
+                        {Source, FallbackSource}, {Source}),
                     TempPath, SimulateBrowserHeaders:=True)
                 ActualSource = TempPath
                 If Not EnableCache Then File.Delete(TempPath)

+ 8 - 2
Plain Craft Launcher 2/FormMain.xaml.vb

@@ -118,6 +118,12 @@ Public Class FormMain
         '3:BUG+ IMP* FEAT-
         '2:BUG* IMP-
         '1:BUG-
+        If LastVersion < 378 Then 'Snapshot 2.12.1
+            If LastVersion >= 377 Then
+                FeatureList.Add(New KeyValuePair(Of Integer, String)(1, "修复:在版本列表中存在 OptiFine 时可能无法加载版本列表"))
+                BugCount += 2
+            End If
+        End If
         If LastVersion < 377 Then 'Snapshot 2.12.0
             If LastVersion >= 373 Then
                 FeatureList.Add(New KeyValuePair(Of Integer, String)(5, "删除:暂时隐藏联机入口……不过只是暂时关闭,它还会回来的!"))
@@ -125,8 +131,8 @@ Public Class FormMain
             FeatureList.Add(New KeyValuePair(Of Integer, String)(3, "新增:适配新的 Minecraft 版本号系统与 Unobfuscated 版本"))
             FeatureList.Add(New KeyValuePair(Of Integer, String)(2, "优化:巨幅优化各个下载页面和 Mod 管理页面的性能"))
             FeatureList.Add(New KeyValuePair(Of Integer, String)(1, "优化:更换披风时会显示当前使用的披风"))
-            FeatureCount += 31
-            BugCount += 27
+            FeatureCount += 33
+            BugCount += 29
         End If
         If LastVersion < 375 Then 'Snapshot 2.11.2
             'If LastVersion >= 373 Then

+ 4 - 5
Plain Craft Launcher 2/Modules/Base/ModBase.vb

@@ -14,13 +14,13 @@ Public Module ModBase
 #Region "声明"
 
     '下列版本信息由更新器自动修改
-    Public Const VersionBaseName As String = "2.12.0" '不含分支前缀的显示用版本名
-    Public Const VersionStandardCode As String = "2.12.0." & VersionBranchCode '标准格式的四段式版本号
+    Public Const VersionBaseName As String = "2.12.1" '不含分支前缀的显示用版本名
+    Public Const VersionStandardCode As String = "2.12.1." & VersionBranchCode '标准格式的四段式版本号
     Public Const CommitHash As String = "" 'Commit Hash,由 GitHub Workflow 自动替换
 #If BETA Then
     Public Const VersionCode As Integer = 372 'Release
 #Else
-    Public Const VersionCode As Integer = 377 'Snapshot
+    Public Const VersionCode As Integer = 378 'Snapshot
 #End If
     '自动生成的版本信息
     Public Const VersionDisplayName As String = VersionBranchName & " " & VersionBaseName
@@ -589,8 +589,7 @@ Public Module ModBase
     ''' </summary>
     Public Function ReadReg(Key As String, Optional DefaultValue As String = "") As String
         Try
-            Dim SubKey = My.Computer.Registry.CurrentUser.OpenSubKey("Software\" & RegFolder, False)
-            Return If(SubKey?.GetValue(Key), DefaultValue)
+            Return If(My.Computer.Registry.CurrentUser.OpenSubKey("Software\" & RegFolder, False)?.GetValue(Key), DefaultValue)
         Catch ex As Exception
             Log(ex, "读取注册表出错:" & Key, LogLevel.Hint)
             Return DefaultValue

+ 1 - 1
Plain Craft Launcher 2/Modules/Minecraft/ModComp.vb

@@ -561,7 +561,7 @@
                     Dim EndName = McVersion.DropToVersion(EndDrop)
                     If StartDrop = EndDrop Then
                         Segments.Add(StartName)
-                    ElseIf AllDrops?.Any AndAlso StartDrop >= AllDrops.First Then
+                    ElseIf AllDrops IsNot Nothing AndAlso StartDrop >= AllDrops.First Then
                         If EndDrop < 100 Then
                             Segments.Clear()
                             Segments.Add("全版本")

+ 7 - 5
Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb

@@ -152,14 +152,16 @@
 #Region "DlClientList | Minecraft 客户端 版本列表"
 
     ''' <summary>
-    ''' 所有正式版的 Minecraft Drop 序数,按从高到低排列。
-    ''' Nothing 代表从未完成过获取。
+    ''' 所有正式版的 Minecraft Drop 序数。
+    ''' 若从未完成过获取,返回 Nothing;否则必定存在元素,且从高到低排列。
     ''' </summary>
     Public Property AllDrops As List(Of Integer)
         Get
-            If _AllDrops Is Nothing Then _AllDrops = Setup.Get("CacheDrops").ToString.Split(","c).Select(Function(d) CInt(d)).ToList()
-            If Not _AllDrops.Any Then _AllDrops = Nothing
-            Return _AllDrops
+            If _AllDrops Is Nothing Then
+                _AllDrops = Setup.Get("CacheDrops").ToString.
+                    Split(",".ToCharArray, StringSplitOptions.RemoveEmptyEntries).Select(Function(d) CInt(Val(d))).ToList()
+            End If
+            Return If(_AllDrops.Any, _AllDrops, Nothing) '不要将 _AllDrops 再设为 Nothing,以防止反复获取设置尝试初始化
         End Get
         Set(value As List(Of Integer))
             _AllDrops = value

+ 1 - 1
Plain Craft Launcher 2/Modules/Minecraft/ModJava.vb

@@ -730,7 +730,7 @@ Wait:
             TargetEntry = Components.Property(Loader.Input)
         Else '模糊匹配
             TargetEntry = Components.Properties.FirstOrDefault(
-                Function(c) c.Value?.ToArray.FirstOrDefault()?("version")("name").ToString.StartsWithF(Loader.Input))
+                Function(c) c.Value IsNot Nothing AndAlso c.Value.ToArray.FirstOrDefault()?("version")("name").ToString.StartsWithF(Loader.Input))
             If TargetEntry Is Nothing Then Throw New Exception($"未能找到所需的 Java {Loader.Input}")
         End If
         Dim TargetComponent = TargetEntry.Value.ToArray.FirstOrDefault

+ 3 - 3
Plain Craft Launcher 2/Modules/Minecraft/ModMinecraft.vb

@@ -158,7 +158,7 @@ Public Module ModMinecraft
 
 #Region "版本处理"
 
-    Public Const McInstanceCacheVersion As Integer = 32
+    Public Const McInstanceCacheVersion As Integer = 33
 
     Private _McInstanceSelected As McInstance
     ''' <summary>
@@ -1013,10 +1013,10 @@ ExitDataLoad:
                 '字母编号,如 G2 中的 G(7)
                 Dim Result As Integer = Asc(OptiFine.ToUpper.First) - Asc("A"c) + 1
                 '末尾数字,如 C5 beta4 中的 5
-                Result *= Result * 100
+                Result *= 100
                 Result += Val(RegexSeek(Right(OptiFine, OptiFine.Length - 1), "[0-9]+"))
                 '测试标记(正式版为 99,Pre[x] 为 50+x,Beta[x] 为 x)
-                Result *= Result * 100
+                Result *= 100
                 If OptiFine.ContainsF("pre", True) Then Result += 50
                 If OptiFine.ContainsF("pre", True) OrElse OptiFine.ContainsF("beta", True) Then
                     If Val(Right(OptiFine, 1)) = 0 AndAlso Right(OptiFine, 1) <> "0" Then

+ 1 - 1
Plain Craft Launcher 2/Modules/Minecraft/ModMod.vb

@@ -115,7 +115,7 @@ Public Module ModMod
             End Get
             Set(value As String)
                 If _Version IsNot Nothing AndAlso RegexCheck(_Version, "[0-9.\-]+") Then Return
-                If value?.ContainsF("version", True) Then value = "version" '需要修改的标识
+                If value IsNot Nothing AndAlso value.ContainsF("version", True) Then value = "version" '需要修改的标识
                 _Version = value
             End Set
         End Property

+ 1 - 1
Plain Craft Launcher 2/Modules/Minecraft/ModModpack.vb

@@ -278,7 +278,7 @@ Retry:
                     If ModJson("modules").Any Then 'modules 可能返回 null(#1006)
                         Dim ModuleNames = CType(ModJson("modules"), JArray).Select(Function(l) l("name").ToString).ToList
                         If ModuleNames.Contains("META-INF") OrElse ModuleNames.Contains("mcmod.info") OrElse
-                           ModJson?("FileName")?.ToString?.EndsWithF(".jar", True) Then
+                           ModJson?("FileName")?.ToString.EndsWithF(".jar", True) Then
                             TargetFolder = "mods" : Type = CompType.Mod
                         ElseIf ModuleNames.Contains("pack.mcmeta") Then
                             TargetFolder = "resourcepacks" : Type = CompType.ResourcePack

+ 2 - 2
Plain Craft Launcher 2/Modules/ModEvent.vb

@@ -175,10 +175,10 @@ Public Class CustomEvent
     Public Shared Sub Raise(Type As EventType, Arg As String)
         If Type = EventType.None Then Return
         Log($"[Control] 执行自定义事件:{Type}, {Arg}")
+        If Arg Is Nothing Then Arg = ""
+        Dim Args As String() = Arg.Split("|")
         Try
-            Dim Args As String() = If(Arg?.Split("|"), {""})
             Select Case Type
-
                 Case EventType.打开网页
                     Arg = Arg.Replace("\", "/")
                     If Not Arg.Contains("://") OrElse Arg.StartsWithF("file", True) Then '为了支持更多协议(#2200)

+ 1 - 2
Plain Craft Launcher 2/Modules/ModMain.vb

@@ -792,8 +792,7 @@ NextFile:
         '查看现有设置
         Using ReadOnlyKey = My.Computer.Registry.CurrentUser.OpenSubKey(REG_KEY, False)
             If ReadOnlyKey IsNot Nothing Then
-                Dim CurrentValue = ReadOnlyKey.GetValue(Executeable)
-                If REG_VALUE = CurrentValue?.ToString() Then
+                If REG_VALUE = ReadOnlyKey.GetValue(Executeable)?.ToString() Then
                     Log($"[System] 无需调整显卡设置:{Executeable}")
                     Return
                 End If

+ 1 - 0
Plain Craft Launcher 2/Modules/ModMusic.vb

@@ -261,6 +261,7 @@
 
     ''' <summary>
     ''' 当前正在播放的 NAudio.Wave.WaveOutEvent。
+    ''' 如果为它赋了类别,则会没有必要地加载 NAudio.dll。
     ''' </summary>
     Public MusicNAudio = Nothing
     ''' <summary>

+ 2 - 2
Plain Craft Launcher 2/My Project/AssemblyInfo.vb

@@ -51,6 +51,6 @@ Imports System.Runtime.InteropServices
 ' 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
 ' 方法是按如下所示使用“*”
 
-<Assembly: AssemblyVersion("2.12.0.0")>
-<Assembly: AssemblyFileVersion("2.12.0.0")>
+<Assembly: AssemblyVersion("2.12.1.0")>
+<Assembly: AssemblyFileVersion("2.12.1.0")>
 <Assembly: NeutralResourcesLanguage("")>

+ 1 - 1
Plain Craft Launcher 2/Pages/PageDownload/Comp/PageComp.xaml.vb

@@ -111,7 +111,7 @@ Public Class PageComp
         IsFirstLoaded = True
         CType(Parent, MyPageRight).PageLoaderInit(Load, PanLoad, PanContent, PanAlways, Loader, AddressOf Load_OnFinish, AddressOf LoaderInput)
         '将最高 Drop 加入筛选
-        If AllDrops?.Any AndAlso AllDrops.First > 250 Then
+        If AllDrops IsNot Nothing AndAlso AllDrops.First > 250 Then
             Dim HighestVersion As String = McVersion.DropToVersion(AllDrops.First)
             If CType(TextSearchVersion.Items(1), MyComboBoxItem).Content.ToString <> HighestVersion Then '0 是全部
                 TextSearchVersion.Items.Insert(1, New MyComboBoxItem With {.Content = HighestVersion})