Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NeoForge 支持 #4045

Merged
merged 39 commits into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
7ba79db
feat(neoforge): 添加了 NeoForge 的安装选项,并支持获取版本列表
Pigeon0v0 Jun 15, 2024
e731ef6
ui: 显示 NeoForge 版本属性(测试版 / 稳定版)
Pigeon0v0 Jun 15, 2024
8d9dc47
fix: NeoForge 版本列表排序,但是抽象实现
Pigeon0v0 Jun 15, 2024
655364b
fix: 一处逻辑判断错误,但未解决版本判断错误的问题
Pigeon0v0 Jun 15, 2024
65d21d4
Installer 下载和代码清理
Pigeon0v0 Jun 15, 2024
31e391f
optimize: version name and icon
JingHai-Lingyun Jun 15, 2024
d8fe599
fix: 所有版本都显示为测试版 / 正式版
Pigeon0v0 Jun 15, 2024
0e0335e
ui: 添加 NeoForge 手动安装 Tab
Pigeon0v0 Jun 16, 2024
f4b1e3e
feat: 正式支持 NeoForge 自动安装
Pigeon0v0 Jun 16, 2024
27825ed
Update PageDownloadInstall.xaml.vb
JingHai-Lingyun Jun 16, 2024
d305dd3
fix: 版本列表不能正常显示核心 NeoForge 版本
Pigeon0v0 Jun 16, 2024
c31e3b5
Merge branch 'neoforge' into neoforge
Pigeon0v0 Jun 16, 2024
030c498
Merge pull request #2 from JingHai-Lingyun/neoforge
Pigeon0v0 Jun 16, 2024
66182f2
fix: Icon 显示及其导致的崩溃问题
Pigeon0v0 Jun 16, 2024
f3079dd
feat: NeoForge 整合包安装
Pigeon0v0 Jun 16, 2024
9c64dc0
尝试修复 NeoForge 手动安装包列表加载不出的问题,但是失败了
Pigeon0v0 Jun 16, 2024
9dab0b8
改一行注释
Pigeon0v0 Jun 16, 2024
136803f
fix: 回滚修改,修复版本列表问题
Pigeon0v0 Jun 16, 2024
f83afdb
fix: 1.20.1 NeoForge 下载地址拼接可能有误(如果版本为 1.20.1 则硬编码以避免问题)
Pigeon0v0 Jun 21, 2024
e0ae696
chores: 界面文本更改,现在安装的是 NeoForge 还是 Forge 更清晰了
Pigeon0v0 Jun 21, 2024
3bc3416
fix: 1.20.1 NeoForge 安装失败(Json 路径错误)
Pigeon0v0 Jun 21, 2024
7d50ed1
fix: 1.20.1 NeoForge 近期版本无法安装(Json 路径错误)
Pigeon0v0 Jun 21, 2024
70a6b6a
chores: 删除调试用信息
Pigeon0v0 Jun 21, 2024
61ac627
fix: 1.20.1 NeoForge 无法安装(Json 路径拼接错误)
Pigeon0v0 Jun 22, 2024
3f5c292
feat(neoforge): NeoForge 官方源版本列表
Pigeon0v0 Jun 26, 2024
707b6ee
fix: NeoForge 手动安装版本列表不能正常加载(修完了)
Pigeon0v0 Jun 26, 2024
2cfa9b2
feat: NeoForge BMCLAPI 版本列表获取
Pigeon0v0 Jun 26, 2024
ee10caa
fix: NeoForge 官方源不可用
Pigeon0v0 Jun 26, 2024
6efaa09
fix: 官方源总是 Fallback 到 BMCLAPI
Pigeon0v0 Jun 27, 2024
ac6ed8d
chores: Clean up
Pigeon0v0 Jun 27, 2024
1b53489
fix: BMCLAPI 获取支持的 Neo 列表时会意外的包含 1.20
Pigeon0v0 Jun 27, 2024
b61081f
:ok_hand: 修改一些龙猫的审查
youzi-2333 Jun 27, 2024
f98578f
Merge pull request #4 from youzi-2333/pigeon-neoforge
Pigeon0v0 Jun 27, 2024
a54cfef
代码清理
Pigeon0v0 Jun 27, 2024
cf43244
refactor: 合并 Forge 和 NeoForge 部分代码
Pigeon0v0 Jun 28, 2024
4dba7c9
chores: 代码可读性和相关优化
Pigeon0v0 Jun 28, 2024
3c44a55
refactor: NeoForge BMCLAPI 版本列表(爱来自 bangbang93)
Pigeon0v0 Jun 30, 2024
bec5ddd
chores: 代码清理
Pigeon0v0 Jun 30, 2024
7921184
chores: 一些判断和命名修改
Pigeon0v0 Jun 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Plain Craft Launcher 2/Controls/MyCard.vb
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,16 @@
ForgeDownloadListItemPreload(Stack, Stack.Tag, AddressOf ForgeSave_Click, True)
Case 8
CompFilesCardPreload(Stack, Stack.Tag)
Case 13
Dim LoadingPickaxe As New MyLoading With {.Text = "正在获取版本列表", .Margin = New Thickness(5)}
Dim Loader = New LoaderTask(Of String, List(Of DlNeoForgeVersionEntry))("DlNeoForgeVersion Main", AddressOf DlNeoForgeVersionMain)
LoadingPickaxe.State = Loader
Loader.Start(Stack.Tag)
AddHandler LoadingPickaxe.StateChanged, AddressOf FrmDownloadNeoForge.NeoForge_StateChanged
AddHandler LoadingPickaxe.Click, AddressOf FrmDownloadNeoForge.NeoForge_Click
Stack.Children.Add(LoadingPickaxe)
Case 14
NeoForgeDownloadListItemPreload(Stack, Stack.Tag, AddressOf NeoForgeSave_Click, True)
End Select
'实现控件虚拟化
For Each Data As Object In Stack.Tag
Expand Down Expand Up @@ -171,6 +181,9 @@
Stack.Children.Add(CType(Data, HelpEntry).ToListItem)
Case 12
Stack.Children.Add(FabricDownloadListItem(CType(Data, JObject), AddressOf FrmDownloadInstall.Fabric_Selected))
Case 13
Case 14
Stack.Children.Add(NeoForgeDownloadListItem(Data, AddressOf NeoForgeSave_Click, True))
Case Else
Log("未知的虚拟化种类:" & Type, LogLevel.Feedback)
End Select
Expand Down
1 change: 1 addition & 0 deletions Plain Craft Launcher 2/FormMain.xaml.vb
Original file line number Diff line number Diff line change
Expand Up @@ -1019,6 +1019,7 @@ Install:
DownloadClient = 4
DownloadOptiFine = 5
DownloadForge = 6
DownloadNeoForge = 13
DownloadFabric = 7
DownloadLiteLoader = 8
DownloadMod = 10
Expand Down
Binary file added Plain Craft Launcher 2/Images/Blocks/NeoForge.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
284 changes: 284 additions & 0 deletions Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,290 @@

#End Region

#Region "DlNeoForgeList | NeoForge Minecraft 版本列表"

Public Structure DlNeoForgeListResult
''' <summary>
''' 数据来源名称,如“Official”,“BMCLAPI”。
''' </summary>
Public SourceName As String
''' <summary>
''' 是否为官方的实时数据。
''' </summary>
Public IsOfficial As Boolean
''' <summary>
''' 获取到的数据。
''' </summary>
Public Value As List(Of String)
End Structure

''' <summary>
''' NeoForge 版本列表,主加载器。
''' </summary>
Public DlNeoForgeListLoader As New LoaderTask(Of Integer, DlNeoForgeListResult)("DlNeoForgeList Main", AddressOf DlNeoForgeListMain)
Private Sub DlNeoForgeListMain(Loader As LoaderTask(Of Integer, DlNeoForgeListResult))
Select Case Setup.Get("ToolDownloadVersion")
Case 0
DlSourceLoader(Loader, New List(Of KeyValuePair(Of LoaderTask(Of Integer, DlNeoForgeListResult), Integer)) From {
New KeyValuePair(Of LoaderTask(Of Integer, DlNeoForgeListResult), Integer)(DlNeoForgeListBmclapiLoader, 30),
New KeyValuePair(Of LoaderTask(Of Integer, DlNeoForgeListResult), Integer)(DlNeoForgeListOfficialLoader, 60)
}, Loader.IsForceRestarting)
Case 1
DlSourceLoader(Loader, New List(Of KeyValuePair(Of LoaderTask(Of Integer, DlNeoForgeListResult), Integer)) From {
New KeyValuePair(Of LoaderTask(Of Integer, DlNeoForgeListResult), Integer)(DlNeoForgeListOfficialLoader, 5),
New KeyValuePair(Of LoaderTask(Of Integer, DlNeoForgeListResult), Integer)(DlNeoForgeListBmclapiLoader, 35)
}, Loader.IsForceRestarting)
Case Else
DlSourceLoader(Loader, New List(Of KeyValuePair(Of LoaderTask(Of Integer, DlNeoForgeListResult), Integer)) From {
New KeyValuePair(Of LoaderTask(Of Integer, DlNeoForgeListResult), Integer)(DlNeoForgeListOfficialLoader, 60),
New KeyValuePair(Of LoaderTask(Of Integer, DlNeoForgeListResult), Integer)(DlNeoForgeListBmclapiLoader, 60)
}, Loader.IsForceRestarting)
End Select
End Sub

''' <summary>
''' NeoForge 版本列表,官方源。
''' </summary>
Public DlNeoForgeListOfficialLoader As New LoaderTask(Of Integer, DlNeoForgeListResult)("DlNeoForgeList Official", AddressOf DlNeoForgeListOfficialMain)
Private Sub DlNeoForgeListOfficialMain(Loader As LoaderTask(Of Integer, DlNeoForgeListResult))
Dim ResultLatest As String
Dim VersionsJArray As JArray
Try
ResultLatest = NetGetCodeByDownload("https://maven.neoforged.net/api/maven/versions/releases/net/neoforged/neoforge", UseBrowserUserAgent:=True, IsJson:=True)
Catch ex As Exception
If GetExceptionSummary(ex).Contains("(404)") Then
Throw New Exception("没有可用版本")
Else
Throw
End If
End Try
If ResultLatest.Length < 50 Then Throw New Exception("获取到的版本列表长度不足(" & ResultLatest & ")")
VersionsJArray = GetJson(ResultLatest)("versions")
Dim Versions As New List(Of String)
Versions.Add("1.20.1")
Try
For Each Token As String In VersionsJArray
Dim Version As String = Token.Replace("neoforge-", "")
Dim Inherit As String = $"1.{Version.Split(".")(0)}.{Token.Split(".")(1)}"
If Inherit.EndsWith(".0") Then Inherit = Inherit.Replace(".0", "")
Versions.Add(Inherit)
Next
Versions = Versions.Distinct().ToList()
Catch ex As Exception
Log(ex, LogLevel.Feedback)
End Try
If Not Versions.Any() Then Throw New Exception("没有可用版本")
Loader.Output = New DlNeoForgeListResult With {.IsOfficial = True, .SourceName = "NeoForge 官方源", .Value = Versions}
End Sub

''' <summary>
''' NeoForge 版本列表,BMCLAPI。
''' </summary>
Public DlNeoForgeListBmclapiLoader As New LoaderTask(Of Integer, DlNeoForgeListResult)("DlNeoForgeList Bmclapi", AddressOf DlNeoForgeListBmclapiMain)
Private Sub DlNeoForgeListBmclapiMain(Loader As LoaderTask(Of Integer, DlNeoForgeListResult))
Dim ResultLatest As String
Dim VersionsJArray As JArray
Try
ResultLatest = NetGetCodeByDownload("https://bmclapi2.bangbang93.com/neoforge/meta/api/maven/details/releases/net/neoforged/neoforge", UseBrowserUserAgent:=True, IsJson:=True)
Catch ex As Exception
If GetExceptionSummary(ex).Contains("(404)") Then
Throw New Exception("没有可用版本")
Else
Throw
End If
End Try
If ResultLatest.Length < 50 Then Throw New Exception("获取到的版本列表长度不足(" & ResultLatest & ")")
VersionsJArray = GetJson(ResultLatest)("name")
Dim Versions As New List(Of String)
Versions.Add("1.20.1")
Try
For Each Token As String In VersionsJArray("name")
Dim Version As String = Token.Replace("neoforge-", "")
Dim Inherit As String = $"1.{Version.Split(".")(0)}.{Token.Split(".")(1)}"
If Inherit.EndsWith(".0") Then Inherit = Inherit.Replace(".0", "")
Versions.Add(Inherit)
Next
Versions = Versions.Distinct().ToList()
Catch ex As Exception
Log(ex, LogLevel.Feedback)
End Try
If Not Versions.Any() Then Throw New Exception("没有可用版本")
Loader.Output = New DlNeoForgeListResult With {.IsOfficial = False, .SourceName = "BMCLAPI", .Value = Versions}
End Sub
#End Region

#Region "DlNeoForgeVersion | NeoForge 版本列表"

Public Class DlNeoForgeVersionEntry
''' <summary>
''' 完整的版本名,如 “neoforge-20.4.30-beta”。
''' </summary>
Public VersionName As String
''' <summary>
''' 对应的 Minecraft 版本,如“1.20.4”。
''' </summary>
Public Inherit As String
''' <summary>
''' 是否是 Beta 版。若未提供则默认为 False。
''' </summary>
Public IsBeta As Boolean = False
''' <summary>
''' 标准的版本号,如 “20.4.30”。
''' </summary>
Public VersionCode As String
Public Structure DlNeoForgeListResult
''' <summary>
''' 数据来源名称,如“Official”,“BMCLAPI”。
''' </summary>
Public SourceName As String
''' <summary>
''' 是否为官方的实时数据。
''' </summary>
Public IsOfficial As Boolean
''' <summary>
''' 获取到的数据。
''' </summary>
Public Value As JObject
End Structure
''' <summary>
''' 即将下载的文件全名。
''' </summary>
Public ReadOnly Property FileName As String
Get
If VersionCode.StartsWith("47.") Then 'NeoForge 1.20.1 的版本命名有些特殊...
Return "forge-" & "1.20.1" & "-" & VersionCode & If(IsBeta, "-beta", "") & "-" & "installer" & "." & "jar"
Else
Return "neoforge-" & VersionCode & If(IsBeta, "-beta", "") & "-" & "installer" & "." & "jar"
End If
End Get
End Property
''' <summary>
''' 文件扩展名
''' </summary>
Public ReadOnly Property FileSuffix As String = ".jar"
End Class
''' <summary>
''' NeoForge 版本列表,主加载器。
''' </summary>
Public Sub DlNeoForgeVersionMain(Loader As LoaderTask(Of String, List(Of DlNeoForgeVersionEntry)))
Dim DlNeoForgeVersionOfficialLoader As New LoaderTask(Of String, List(Of DlNeoForgeVersionEntry))("DlNeoForgeVersion Official", AddressOf DlNeoForgeVersionOfficialMain)
Dim DlNeoForgeVersionBmclapiLoader As New LoaderTask(Of String, List(Of DlNeoForgeVersionEntry))("DlNeoForgeVersion Bmclapi", AddressOf DlNeoForgeVersionBmclapiMain)
Select Case Setup.Get("ToolDownloadVersion")
Case 0
DlSourceLoader(Loader, New List(Of KeyValuePair(Of LoaderTask(Of String, List(Of DlNeoForgeVersionEntry)), Integer)) From {
New KeyValuePair(Of LoaderTask(Of String, List(Of DlNeoForgeVersionEntry)), Integer)(DlNeoForgeVersionBmclapiLoader, 30),
New KeyValuePair(Of LoaderTask(Of String, List(Of DlNeoForgeVersionEntry)), Integer)(DlNeoForgeVersionOfficialLoader, 60)
}, Loader.IsForceRestarting)
Case 1
DlSourceLoader(Loader, New List(Of KeyValuePair(Of LoaderTask(Of String, List(Of DlNeoForgeVersionEntry)), Integer)) From {
New KeyValuePair(Of LoaderTask(Of String, List(Of DlNeoForgeVersionEntry)), Integer)(DlNeoForgeVersionOfficialLoader, 5),
New KeyValuePair(Of LoaderTask(Of String, List(Of DlNeoForgeVersionEntry)), Integer)(DlNeoForgeVersionBmclapiLoader, 35)
}, Loader.IsForceRestarting)
Case Else
DlSourceLoader(Loader, New List(Of KeyValuePair(Of LoaderTask(Of String, List(Of DlNeoForgeVersionEntry)), Integer)) From {
New KeyValuePair(Of LoaderTask(Of String, List(Of DlNeoForgeVersionEntry)), Integer)(DlNeoForgeVersionOfficialLoader, 60),
New KeyValuePair(Of LoaderTask(Of String, List(Of DlNeoForgeVersionEntry)), Integer)(DlNeoForgeVersionBmclapiLoader, 60)
}, Loader.IsForceRestarting)
End Select
End Sub

''' <summary>
''' NeoForge 版本列表,官方源。
''' </summary>
Public Sub DlNeoForgeVersionOfficialMain(Loader As LoaderTask(Of String, List(Of DlNeoForgeVersionEntry)))
Dim ResultLatest As String
Dim ResultLegacy As String
Try
ResultLatest = NetGetCodeByDownload("https://maven.neoforged.net/api/maven/versions/releases/net/neoforged/neoforge", UseBrowserUserAgent:=True, IsJson:=True)
ResultLegacy = NetGetCodeByDownload("https://maven.neoforged.net/api/maven/versions/releases/net/neoforged/forge", UseBrowserUserAgent:=True, IsJson:=True)
Catch ex As Exception
If GetExceptionSummary(ex).Contains("(404)") Then
Throw New Exception("没有可用版本")
Else
Throw
End If
End Try
If ResultLatest.Length < 50 AndAlso ResultLegacy.Length < 50 Then Throw New Exception("获取到的版本列表长度不足(" & ResultLatest & ")")
Dim ResultLatestJson As JObject = GetJson(ResultLatest)
Dim ResultLegacyJson As JObject = GetJson(ResultLegacy)
Dim VersionsJArray As JArray
Dim IsLegacyNeo As Boolean = False
If Loader.Input IsNot Nothing AndAlso Loader.Input.ToString().Contains("1.20.1") Then
VersionsJArray = ResultLegacyJson("versions")
IsLegacyNeo = True
Else
VersionsJArray = ResultLatestJson("versions")
End If
Dim Versions As New List(Of DlNeoForgeVersionEntry)
Try
For Each Token As String In VersionsJArray
Dim StdVersion As String
Dim IsBeta As Boolean
Dim rawVersion As String = Token
If rawVersion.Contains("-beta") Then
StdVersion = Token.Replace("neoforge-", "").Replace("-beta", "").Replace("1.20.1-", "")
IsBeta = True
Else
StdVersion = Token.Replace("neoforge-", "").Replace("1.20.1-", "")
IsBeta = False
End If
Dim Inherit As String = $"1.{StdVersion.Split(".")(0)}.{StdVersion.Split(".")(1)}"
If Inherit.EndsWithF(".0") Then Inherit.Remove(Inherit.LastIndexOfF(".0"), 1)
Inherit = If(IsLegacyNeo, "1.20.1", Inherit)
Dim Entry = New DlNeoForgeVersionEntry
If Loader.Input IsNot Nothing Then
If IsLegacyNeo OrElse Inherit.Contains(Loader.Input.ToString().Replace("1.", "")) Then
Entry = New DlNeoForgeVersionEntry With {.VersionName = rawVersion, .Inherit = Inherit, .IsBeta = IsBeta, .VersionCode = StdVersion}
Versions.Add(Entry)
End If
Else
Entry = New DlNeoForgeVersionEntry With {.VersionName = rawVersion, .Inherit = Inherit, .IsBeta = IsBeta, .VersionCode = StdVersion}
Versions.Add(Entry)
End If
Next
Catch ex As Exception
Log(ex, LogLevel.Feedback)
End Try
If Not Versions.Any() Then Throw New Exception("没有可用版本")
Dim VersionsArray = Versions.ToList()
VersionsArray.Reverse()
Loader.Output = VersionsArray
End Sub

''' <summary>
''' NeoForge 版本列表,BMCLAPI。
''' </summary>
Public Sub DlNeoForgeVersionBmclapiMain(Loader As LoaderTask(Of String, List(Of DlNeoForgeVersionEntry)))
Dim Json As JArray = NetGetCodeByRequestRetry("https://bmclapi2.bangbang93.com/neoforge/list/" & Loader.Input, IsJson:=True)
Dim Versions As New List(Of DlNeoForgeVersionEntry)
Try
For Each Token As JObject In Json
Dim StdVersion As String
Dim IsBeta As Boolean
Dim rawVersion As String = Token("rawVersion")
If rawVersion.Contains("-beta") Then
StdVersion = Token("version").ToString().Replace("neoforge-", "").Replace("-beta", "").Replace("1.20.1-", "")
IsBeta = True
Else
StdVersion = Token("version").ToString().Replace("neoforge-", "").Replace("1.20.1-", "")
IsBeta = False
End If
Dim Inherit As String = Token("mcversion")
Dim Entry = New DlNeoForgeVersionEntry With {.VersionName = rawVersion, .Inherit = Inherit, .IsBeta = IsBeta, .VersionCode = StdVersion}
Versions.Add(Entry)
Next
Catch ex As Exception
MyMsgBox(ex.ToString(), "错误")
Throw New Exception("版本列表解析失败(" & Json.ToString & ")", ex)
End Try
If Not Versions.Any() Then Throw New Exception("没有可用版本")
Dim VersionsArray = Versions.ToList()
VersionsArray.Reverse()
Loader.Output = VersionsArray
End Sub

#End Region

#Region "DlLiteLoaderList | LiteLoader 版本列表"

Public Structure DlLiteLoaderListResult
Expand Down
Loading