Skip to content

Commit

Permalink
lang: 2.8.9
Browse files Browse the repository at this point in the history
  • Loading branch information
tangge233 committed Oct 16, 2024
1 parent f66b2c2 commit d44d350
Show file tree
Hide file tree
Showing 20 changed files with 133 additions and 99 deletions.
44 changes: 10 additions & 34 deletions Plain Craft Launcher 2/Modules/Base/ModBase.vb
Original file line number Diff line number Diff line change
Expand Up @@ -1348,19 +1348,18 @@ RetryDir:
Dim Stack As String = If(StackList.Any, vbCrLf & Join(StackList, vbCrLf), "")

'常见错误(记得同时修改下面的)
Dim CommonReason As String = GetCommonExceptionReason(InnerEx, Desc)
Dim CommonReason As String = Nothing
If TypeOf InnerEx Is TypeLoadException OrElse TypeOf InnerEx Is BadImageFormatException OrElse TypeOf InnerEx Is MissingMethodException OrElse TypeOf InnerEx Is NotImplementedException OrElse TypeOf InnerEx Is TypeInitializationException Then
CommonReason = "PCL 的运行环境存在问题。请尝试重新安装 .NET Framework 4.6.2 然后再试。若无法安装,请先卸载较新版本的 .NET Framework,然后再尝试安装。"
CommonReason = GetLang("LangModBaseExceptionBadEnvironment")
ElseIf TypeOf InnerEx Is UnauthorizedAccessException Then
CommonReason = "PCL 的权限不足。请尝试右键 PCL,选择以管理员身份运行。"
CommonReason = GetLang("LangModBaseExceptionUnauthorizedAccessException")
ElseIf TypeOf InnerEx Is OutOfMemoryException Then
CommonReason = "你的电脑运行内存不足,导致 PCL 无法继续运行。请在关闭一部分不需要的程序后再试。"
CommonReason = GetLang("LangModBaseExceptionOutOfMemoryException")
ElseIf TypeOf InnerEx Is Runtime.InteropServices.COMException Then
CommonReason = "由于操作系统或显卡存在问题,导致出现错误。请尝试重启 PCL。"
CommonReason = GetLang("LangModBaseExceptionCOMException")
ElseIf {"远程主机强迫关闭了", "远程方已关闭传输流", "未能解析此远程名称", "由于目标计算机积极拒绝",
"操作已超时", "操作超时", "服务器超时", "连接超时"}.Any(Function(s) Desc.Contains(s)) Then
CommonReason = "你的网络环境不佳,导致难以连接到服务器。请检查网络,多重试几次,或尝试使用 VPN。"
CommonReason = GetLang("LangModBaseExceptionBadNetwork")
End If

'获取错误类型
Expand Down Expand Up @@ -1399,16 +1398,16 @@ RetryDir:
'常见错误(记得同时修改上面的)
Dim CommonReason As String = Nothing
If TypeOf InnerEx Is TypeLoadException OrElse TypeOf InnerEx Is BadImageFormatException OrElse TypeOf InnerEx Is MissingMethodException OrElse TypeOf InnerEx Is NotImplementedException OrElse TypeOf InnerEx Is TypeInitializationException Then
CommonReason = "PCL 的运行环境存在问题。请尝试重新安装 .NET Framework 4.6.2 然后再试。若无法安装,请先卸载较新版本的 .NET Framework,然后再尝试安装。"
CommonReason = GetLang("LangModBaseExceptionBadEnvironment")
ElseIf TypeOf InnerEx Is UnauthorizedAccessException Then
CommonReason = "PCL 的权限不足。请尝试右键 PCL,选择以管理员身份运行。"
CommonReason = GetLang("LangModBaseExceptionUnauthorizedAccessException")
ElseIf TypeOf InnerEx Is OutOfMemoryException Then
CommonReason = "你的电脑运行内存不足,导致 PCL 无法继续运行。请在关闭一部分不需要的程序后再试。"
CommonReason = GetLang("LangModBaseExceptionOutOfMemoryException")
ElseIf TypeOf InnerEx Is Runtime.InteropServices.COMException Then
CommonReason = "由于操作系统或显卡存在问题,导致出现错误。请尝试重启 PCL。"
CommonReason = GetLang("LangModBaseExceptionCOMException")
ElseIf {"远程主机强迫关闭了", "远程方已关闭传输流", "未能解析此远程名称", "由于目标计算机积极拒绝",
"操作已超时", "操作超时", "服务器超时", "连接超时"}.Any(Function(s) Desc.Contains(s)) Then
CommonReason = "你的网络环境不佳,导致难以连接到服务器。请检查网络,多重试几次,或尝试使用 VPN。"
CommonReason = GetLang("LangModBaseExceptionBadNetwork")
End If

'构造输出信息
Expand All @@ -1420,29 +1419,6 @@ RetryDir:
End If
End Function

''' <summary>
''' 常见错误(把上面的聚合起来了)
''' </summary>
''' <param name="InnerEx"></param>
''' <param name="Desc"></param>
''' <returns></returns>
Public Function GetCommonExceptionReason(InnerEx As Exception, Desc As String) As String
Dim CommonReason As String = Nothing
If TypeOf InnerEx Is TypeLoadException OrElse TypeOf InnerEx Is MissingMethodException OrElse TypeOf InnerEx Is NotImplementedException OrElse TypeOf InnerEx Is TypeInitializationException Then
CommonReason = GetLang("LangModBaseExceptionBadEnvironment")
ElseIf TypeOf InnerEx Is UnauthorizedAccessException Then
CommonReason = GetLang("LangModBaseExceptionUnauthorizedAccessException")
ElseIf TypeOf InnerEx Is OutOfMemoryException Then
CommonReason = GetLang("LangModBaseExceptionOutOfMemoryException")
ElseIf TypeOf InnerEx Is Runtime.InteropServices.COMException Then
CommonReason = GetLang("LangModBaseExceptionCOMException")
ElseIf {"远程主机强迫关闭了", "远程方已关闭传输流", "未能解析此远程名称", "由于目标计算机积极拒绝",
"操作已超时", "操作超时", "服务器超时", "连接超时"}.Any(Function(s) Desc.Contains(s)) Then
CommonReason = GetLang("LangModBaseExceptionBadNetwork")
End If
Return CommonReason
End Function

''' <summary>
''' 返回一个枚举对应的字符串。
''' </summary>
Expand Down
6 changes: 3 additions & 3 deletions Plain Craft Launcher 2/Modules/Base/ModValidate.vb
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ Public Class ValidateFolderName
Dim InvalidStrCheck As String = New ValidateExceptSame({"CON", "PRN", "AUX", "CLOCK$", "NUL", "COM0", "COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8", "COM9", "LPT0", "LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", "LPT9"}, GetLang("LangModValidateNoSpacialFolderName"), True).Validate(Str)
If Not InvalidStrCheck = "" Then Return InvalidStrCheck
'检查 NTFS 8.3 文件名(#4505)
If RegexCheck(Str, ".{2,}~\d") Then Return "文件夹名不能包含这一特殊格式!"
If RegexCheck(Str, ".{2,}~\d") Then Return GetLang("LangModValidateFileNoSpecialName")
'检查文件夹重名
Dim Arr As New List(Of String)
If PathIgnore IsNot Nothing Then
Expand Down Expand Up @@ -294,7 +294,7 @@ Public Class ValidateFileName
Dim InvalidStrCheck As String = New ValidateExceptSame({"CON", "PRN", "AUX", "CLOCK$", "NUL", "COM0", "COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8", "COM9", "LPT0", "LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", "LPT9"}, GetLang("LangModValidateFileNoContent"), True).Validate(Str)
If Not InvalidStrCheck = "" Then Return InvalidStrCheck
'检查 NTFS 8.3 文件名(#4505)
If RegexCheck(Str, ".{2,}~\d") Then Return "文件名不能包含这一特殊格式!"
If RegexCheck(Str, ".{2,}~\d") Then Return GetLang("LangModValidateFileNoSpecialName")
'检查文件重名
If ParentFolder IsNot Nothing Then
Dim DirInfo As New DirectoryInfo(ParentFolder)
Expand Down Expand Up @@ -361,7 +361,7 @@ Fin:
Dim InvalidStrCheck As String = New ValidateExceptSame({"CON", "PRN", "AUX", "CLOCK$", "NUL", "COM0", "COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8", "COM9", "LPT0", "LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", "LPT9"}, GetLang("LangModValidateNoSpacialFolderName")).Validate(SubStr)
If Not InvalidStrCheck = "" Then Return InvalidStrCheck
'检查 NTFS 8.3 文件名(#4505)
If RegexCheck(Str, ".{2,}~\d") Then Return "文件夹名不能包含这一特殊格式!"
If RegexCheck(Str, ".{2,}~\d") Then Return GetLang("LangModValidateFileNoSpecialName")
Next
Return ""
End Function
Expand Down
30 changes: 15 additions & 15 deletions Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ Public Module ModDownloadLib
ToolTipService.SetVerticalOffset(BtnInfo, 30)
ToolTipService.SetHorizontalOffset(BtnInfo, 2)
AddHandler BtnInfo.Click, AddressOf McDownloadMenuLog
Dim BtnServer As New MyIconButton With {.LogoScale = 1, .Logo = Logo.IconButtonServer, .ToolTip = "下载服务端"}
Dim BtnServer As New MyIconButton With {.LogoScale = 1, .Logo = Logo.IconButtonServer, .ToolTip = GetLang("LangDownloadServer")}
ToolTipService.SetPlacement(BtnServer, Primitives.PlacementMode.Center)
ToolTipService.SetVerticalOffset(BtnServer, 30)
ToolTipService.SetHorizontalOffset(BtnServer, 2)
Expand All @@ -185,7 +185,7 @@ Public Module ModDownloadLib
ToolTipService.SetVerticalOffset(BtnInfo, 30)
ToolTipService.SetHorizontalOffset(BtnInfo, 2)
AddHandler BtnInfo.Click, AddressOf McDownloadMenuLog
Dim BtnServer As New MyIconButton With {.LogoScale = 1, .Logo = Logo.IconButtonServer, .ToolTip = "下载服务端"}
Dim BtnServer As New MyIconButton With {.LogoScale = 1, .Logo = Logo.IconButtonServer, .ToolTip = GetLang("LangDownloadServer")}
ToolTipService.SetPlacement(BtnServer, Primitives.PlacementMode.Center)
ToolTipService.SetVerticalOffset(BtnServer, 30)
ToolTipService.SetHorizontalOffset(BtnServer, 2)
Expand Down Expand Up @@ -221,22 +221,22 @@ Public Module ModDownloadLib

'重复任务检查
For Each OngoingLoader In LoaderTaskbar.ToList()
If OngoingLoader.Name <> $"Minecraft {Id} 服务端下载" Then Continue For
Hint("该服务端正在下载中!", HintType.Critical)
If OngoingLoader.Name <> GetLang("LangModDownloadLibTaskDownloadServer", Id) Then Continue For
Hint(GetLang("LangModDownloadLibTaskDownloadServerHintDownloading"), HintType.Critical)
Exit Sub
Next

Dim Loaders As New List(Of LoaderBase)
'下载版本 JSON 文件
Loaders.Add(New LoaderDownload("下载版本 JSON 文件", New List(Of NetFile) From {
Loaders.Add(New LoaderDownload(GetLang("LangModDownloadLibTaskMcDownloadJson"), New List(Of NetFile) From {
New NetFile(DlSourceLauncherOrMetaGet(JsonUrl), VersionFolder & Id & ".json", New FileChecker(CanUseExistsFile:=False, IsJson:=True))
}) With {.ProgressWeight = 2})
'构建服务端
Loaders.Add(New LoaderTask(Of String, List(Of NetFile))("构建服务端",
Loaders.Add(New LoaderTask(Of String, List(Of NetFile))(GetLang("LangModDownloadLibTaskDownloadServerGetDownloadUrl"),
Sub(Task As LoaderTask(Of String, List(Of NetFile)))
'分析服务端 JAR 文件下载地址
Dim McVersion As New McVersion(VersionFolder)
If McVersion.JsonObject("downloads") Is Nothing OrElse McVersion.JsonObject("downloads")("server") Is Nothing OrElse McVersion.JsonObject("downloads")("server")("url") Is Nothing Then Throw New Exception($"{Id} 版本没有提供服务端文件")
If McVersion.JsonObject("downloads") Is Nothing OrElse McVersion.JsonObject("downloads")("server") Is Nothing OrElse McVersion.JsonObject("downloads")("server")("url") Is Nothing Then Throw New Exception(GetLang("LangModDownloadLibExceptionTaskDownloadServerNoResource", Id))
Dim JarUrl As String = McVersion.JsonObject("downloads")("server")("url")
Dim Checker As New FileChecker(MinSize:=1024, ActualSize:=If(McVersion.JsonObject("downloads")("server")("size"), -1), Hash:=McVersion.JsonObject("downloads")("server")("sha1"))
Task.Output = New List(Of NetFile) From {New NetFile(DlSourceLauncherOrMetaGet(JarUrl), VersionFolder & Id & "-server.jar", Checker)}
Expand All @@ -260,10 +260,10 @@ pause"
End Sub
) With {.ProgressWeight = 0.5, .Show = False})
'下载服务端文件
Loaders.Add(New LoaderDownload("下载服务端文件", New List(Of NetFile)) With {.ProgressWeight = 5})
Loaders.Add(New LoaderDownload(GetLang("LangModDownloadLibTaskDownloadServerDownloading"), New List(Of NetFile)) With {.ProgressWeight = 5})

'启动
Dim Loader As New LoaderCombo(Of String)("Minecraft " & Id & " 服务端下载", Loaders) With {.OnStateChanged = AddressOf DownloadStateSave}
Dim Loader As New LoaderCombo(Of String)(GetLang("LangModDownloadLibTaskDownloadServer", Id), Loaders) With {.OnStateChanged = AddressOf DownloadStateSave}
Loader.Start(Id)
LoaderTaskbarAdd(Loader)
FrmMain.BtnExtraDownload.ShowRefresh()
Expand All @@ -290,25 +290,25 @@ pause"

'重复任务检查
For Each OngoingLoader In LoaderTaskbar.ToList()
If OngoingLoader.Name <> $"Minecraft {Id} 下载" Then Continue For
Hint("该版本正在下载中!", HintType.Critical)
If OngoingLoader.Name <> GetLang("LangModDownloadLibTaskMcDownload") Then Continue For
Hint(GetLang("LangModDownloadLibHintInstanceDownloading"), HintType.Critical)
Exit Sub
Next

Dim Loaders As New List(Of LoaderBase)
'下载版本 JSON 文件
Loaders.Add(New LoaderDownload("下载版本 JSON 文件", New List(Of NetFile) From {
Loaders.Add(New LoaderDownload(GetLang("LangModDownloadLibTaskMcDownloadJson"), New List(Of NetFile) From {
New NetFile(DlSourceLauncherOrMetaGet(JsonUrl), VersionFolder & Id & ".json", New FileChecker(CanUseExistsFile:=False, IsJson:=True))
}) With {.ProgressWeight = 2})
'获取支持库文件地址
Loaders.Add(New LoaderTask(Of String, List(Of NetFile))("分析核心 JAR 文件下载地址",
Loaders.Add(New LoaderTask(Of String, List(Of NetFile))(GetLang("LangModDownloadLibTaskMcDownloadJarUrl"),
Sub(Task) Task.Output = New List(Of NetFile) From {DlClientJarGet(New McVersion(VersionFolder), False)}
) With {.ProgressWeight = 0.5, .Show = False})
'下载支持库文件
Loaders.Add(New LoaderDownload("下载核心 JAR 文件", New List(Of NetFile)) With {.ProgressWeight = 5})
Loaders.Add(New LoaderDownload(GetLang("LangModDownloadLibTaskMcDownloadJar"), New List(Of NetFile)) With {.ProgressWeight = 5})

'启动
Dim Loader As New LoaderCombo(Of String)("Minecraft " & Id & " 下载", Loaders) With {.OnStateChanged = AddressOf DownloadStateSave}
Dim Loader As New LoaderCombo(Of String)(GetLang("LangModDownloadLibTaskMcDownload", Id), Loaders) With {.OnStateChanged = AddressOf DownloadStateSave}
Loader.Start(Id)
LoaderTaskbarAdd(Loader)
FrmMain.BtnExtraDownload.ShowRefresh()
Expand Down
Loading

0 comments on commit d44d350

Please sign in to comment.