2.8.5
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
Imports System.IO.Compression
|
||||
Imports Newtonsoft.Json
|
||||
|
||||
Public Module ModLaunch
|
||||
|
||||
@@ -671,6 +670,7 @@ LoginFinish:
|
||||
Url:=Data.Input.BaseUrl & "/validate",
|
||||
Method:="POST",
|
||||
Data:=RequestData.ToString(0),
|
||||
Headers:=New Dictionary(Of String, String) From {{"Accept-Language", "zh_CN"}},
|
||||
ContentType:="application/json; charset=utf-8") '没有返回值的
|
||||
'将登录结果输出
|
||||
Data.Output.AccessToken = AccessToken
|
||||
@@ -694,6 +694,7 @@ LoginFinish:
|
||||
""name"":""" & Setup.Get("Cache" & Data.Input.Token & "Name") & """},", "") & "
|
||||
""accessToken"":""" & Setup.Get("Cache" & Data.Input.Token & "Access") & """,
|
||||
""clientToken"":""" & Setup.Get("Cache" & Data.Input.Token & "Client") & """}",
|
||||
Headers:=New Dictionary(Of String, String) From {{"Accept-Language", "zh_CN"}},
|
||||
ContentType:="application/json; charset=utf-8"))
|
||||
'将登录结果输出
|
||||
If LoginJson("selectedProfile") Is Nothing Then Throw New Exception("选择的角色 " & Setup.Get("Cache" & Data.Input.Token & "Name") & " 无效!")
|
||||
@@ -711,16 +712,6 @@ LoginFinish:
|
||||
Setup.Set("Cache" & Data.Input.Token & "Pass", Data.Input.Password)
|
||||
McLaunchLog("刷新登录成功(Refresh, " & Data.Input.Token & ")")
|
||||
End Sub
|
||||
|
||||
Public Class AuthErrorResponse
|
||||
Public Property [error] As String
|
||||
Public Property errorMessage As String
|
||||
End Class
|
||||
Private Function ParseErrorResponse(ex As Exception) As AuthErrorResponse
|
||||
Dim SplitEx As String = ex.ToString().Split(vbCrLf)(1).Split("-")(0).ToString().Trim()
|
||||
Dim JsonEx As AuthErrorResponse = JsonConvert.DeserializeObject(Of AuthErrorResponse)(SplitEx)
|
||||
Return JsonEx
|
||||
End Function
|
||||
Private Function McLoginRequestLogin(ByRef Data As LoaderTask(Of McLoginServer, McLoginResult)) As Boolean
|
||||
Try
|
||||
Dim NeedRefresh As Boolean = False
|
||||
@@ -730,13 +721,11 @@ LoginFinish:
|
||||
New JProperty("username", Data.Input.UserName),
|
||||
New JProperty("password", Data.Input.Password),
|
||||
New JProperty("requestUser", True))
|
||||
Dim LHeaders As New Dictionary(Of String, String)
|
||||
LHeaders.Add("Accept-Language", "zh_CN")
|
||||
Dim LoginJson As JObject = GetJson(NetRequestRetry(
|
||||
Url:=Data.Input.BaseUrl & "/authenticate",
|
||||
Method:="POST",
|
||||
Data:=RequestData.ToString(0),
|
||||
Headers:=LHeaders,
|
||||
Headers:=New Dictionary(Of String, String) From {{"Accept-Language", "zh_CN"}},
|
||||
ContentType:="application/json; charset=utf-8"))
|
||||
'检查登录结果
|
||||
If LoginJson("availableProfiles").Count = 0 Then
|
||||
@@ -796,13 +785,19 @@ LoginFinish:
|
||||
Catch ex As Exception
|
||||
Dim AllMessage As String = GetExceptionSummary(ex)
|
||||
Log(ex, "登录失败原始错误信息", LogLevel.Normal)
|
||||
'读取服务器返回的错误
|
||||
If TypeOf ex Is ResponsedWebException Then
|
||||
Dim ErrorMessage As String = Nothing
|
||||
Try
|
||||
ErrorMessage = GetJson(DirectCast(ex, ResponsedWebException).Response)("errorMessage")
|
||||
Catch
|
||||
End Try
|
||||
If Not String.IsNullOrWhiteSpace(ErrorMessage) Then Throw New Exception("$登录失败:" & ErrorMessage)
|
||||
End If
|
||||
'通用关键字检测
|
||||
If AllMessage.Contains("403") Then
|
||||
Select Case Data.Input.Type
|
||||
Case McLoginType.Auth
|
||||
Dim ErrorResponse As AuthErrorResponse = ParseErrorResponse(ex)
|
||||
If (ErrorResponse.errorMessage <> "") Then
|
||||
Throw New Exception("$登录失败,以下为认证服务器提供的信息:" & vbCrLf & $" - {ErrorResponse.errorMessage}")
|
||||
End If
|
||||
Throw New Exception("$登录失败,以下为可能的原因:" & vbCrLf &
|
||||
" - 输入的账号或密码错误。" & vbCrLf &
|
||||
" - 登录尝试过于频繁,导致被暂时屏蔽。请不要操作,等待 10 分钟后再试。" & vbCrLf &
|
||||
@@ -1349,20 +1344,28 @@ LoginFinish:
|
||||
Dim WrapperPath As String = BaseDir & "\JavaWrapper.jar"
|
||||
Log("[Java] 选定的 Java Wrapper 路径:" & WrapperPath)
|
||||
SyncLock ExtractJavaWrapperLock '避免 OptiFine 和 Forge 安装时同时释放 Java Wrapper 导致冲突
|
||||
Dim IsWrapperWritten As Boolean = WriteFile(WrapperPath, GetResources("JavaWrapper"))
|
||||
If Not IsWrapperWritten AndAlso File.Exists(WrapperPath) Then
|
||||
'以下为 #4243 的修复,因为未知原因 Java Wrapper 可能变为只读文件
|
||||
Log("[Java] Java Wrapper 文件释放失败,但文件已存在,将在删除后尝试重新生成", LogLevel.Debug)
|
||||
Try
|
||||
File.Delete(WrapperPath)
|
||||
IsWrapperWritten = WriteFile(WrapperPath, GetResources("JavaWrapper"))
|
||||
Catch ex As Exception
|
||||
Log(ex, "Java Wrapper 文件重新释放失败,将尝试更换文件名重新生成")
|
||||
WrapperPath = BaseDir & "\JavaWrapper2.jar"
|
||||
IsWrapperWritten = WriteFile(WrapperPath, GetResources("JavaWrapper"))
|
||||
End Try
|
||||
End If
|
||||
If Not IsWrapperWritten Then Throw New FileNotFoundException("释放 Java Wrapper 失败,请查看 PCL 日志查找详细信息")
|
||||
Try
|
||||
WriteFile(WrapperPath, GetResources("JavaWrapper"))
|
||||
Catch ex As Exception
|
||||
If File.Exists(WrapperPath) Then
|
||||
'因为未知原因 Java Wrapper 可能变为只读文件(#4243)
|
||||
Log(ex, "Java Wrapper 文件释放失败,但文件已存在,将在删除后尝试重新生成", LogLevel.Developer)
|
||||
Try
|
||||
File.Delete(WrapperPath)
|
||||
WriteFile(WrapperPath, GetResources("JavaWrapper"))
|
||||
Catch ex2 As Exception
|
||||
Log(ex2, "Java Wrapper 文件重新释放失败,将尝试更换文件名重新生成", LogLevel.Developer)
|
||||
WrapperPath = BaseDir & "\JavaWrapper2.jar"
|
||||
Try
|
||||
WriteFile(WrapperPath, GetResources("JavaWrapper"))
|
||||
Catch ex3 As Exception
|
||||
Throw New FileNotFoundException("释放 Java Wrapper 最终尝试失败", ex3)
|
||||
End Try
|
||||
End Try
|
||||
Else
|
||||
Throw New FileNotFoundException("释放 Java Wrapper 失败", ex)
|
||||
End If
|
||||
End Try
|
||||
End SyncLock
|
||||
Return WrapperPath
|
||||
End Function
|
||||
|
||||
Reference in New Issue
Block a user