Skip to content

Commit dcc5f58

Browse files
authored
feat(Proxy):允许选择不使用代理
1 parent 94e89f8 commit dcc5f58

File tree

4 files changed

+23
-13
lines changed

4 files changed

+23
-13
lines changed

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

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1420,13 +1420,13 @@ Retry:
14201420
End Try
14211421
End If
14221422

1423-
'添加 Java Wrapper 作为主 Jar
1424-
If McLaunchJavaSelected.VersionCode >= 9 Then DataList.Add("--add-exports cpw.mods.bootstraplauncher/cpw.mods.bootstraplauncher=ALL-UNNAMED")
1425-
DataList.Add("-Doolloo.jlw.tmpdir=""" & PathPure.TrimEnd("\") & """")
1426-
DataList.Add("-jar """ & ExtractJavaWrapper() & """")
14271423

1428-
'走系统代理(Java 9+)
1429-
If McLaunchJavaSelected.VersionCode >= 9 Then DataList.Add("-Djava.net.useSystemProxies=true")
1424+
'设置代理
1425+
If Setup.Get("VersionUseProxyV2", Version:=McVersionCurrent) IsNot Nothing Then
1426+
Dim ProxyAddress As New Uri(Setup.Get("SystemHttpProxy"))
1427+
DataList.Add($"-D{If(ProxyAddress.Scheme.ToString.StartsWithF("https:"), "https", "http")}.proxyHost={ProxyAddress.AbsoluteUri}")
1428+
DataList.Add($"-D{If(ProxyAddress.Scheme.ToString.StartsWithF("https:"), "https", "http")}.proxyPort={ProxyAddress.Port}")
1429+
End If
14301430
'是否使用 Java Wrapper
14311431
If Setup.Get("VersionAdvanceUseLaunchWrapperV2", Version) AndAlso Setup.Get("LaunchAdvanceUseLaunchWrapper") Then
14321432
DataList.Add("-Doolloo.jlw.tmpdir=""" & PathPure.TrimEnd("\") & """")
@@ -1494,11 +1494,16 @@ NextVersion:
14941494
End Try
14951495
End If
14961496

1497-
'添加 Java Wrapper 作为主 Jar
1497+
14981498
If McLaunchJavaSelected.VersionCode >= 9 Then DataList.Add("--add-exports cpw.mods.bootstraplauncher/cpw.mods.bootstraplauncher=ALL-UNNAMED")
14991499

1500-
'走系统代理(Java 9+)
1501-
If McLaunchJavaSelected.VersionCode >= 9 Then DataList.Add("-Djava.net.useSystemProxies=true")
1500+
'设置代理
1501+
If Setup.Get("VersionUseProxyV2", Version:=McVersionCurrent) IsNot Nothing Then
1502+
Dim ProxyAddress As New Uri(Setup.Get("SystemHttpProxy"))
1503+
DataList.Add($"-D{If(ProxyAddress.Scheme.ToString.StartsWithF("https:"), "https", "http")}.proxyHost={ProxyAddress.AbsoluteUri}")
1504+
DataList.Add($"-D{If(ProxyAddress.Scheme.ToString.StartsWithF("https:"), "https", "http")}.proxyPort={ProxyAddress.Port}")
1505+
End If
1506+
'是否使用 Java Wrapper
15021507
If Setup.Get("VersionAdvanceUseLaunchWrapperV2", Version) AndAlso Setup.Get("LaunchAdvanceUseLaunchWrapper") Then
15031508
DataList.Add("-Doolloo.jlw.tmpdir=""" & PathPure.TrimEnd("\") & """")
15041509
DataList.Add("-jar """ & ExtractJavaWrapper() & """")

Plain Craft Launcher 2/Pages/PageSetup/ModSetup.vb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ Public Class ModSetup
178178
{"VersionAdvanceAssetsV2", New SetupEntry(False, Source:=SetupSource.Version)},
179179
{"VersionAdvanceUseLaunchWrapperV2", New SetupEntry(True, Source:=SetupSource.Version)},
180180
{"VersionAdvanceJava", New SetupEntry(False, Source:=SetupSource.Version)},
181+
{"VersionAdvanceUseProxyV2", New SetupEntry(False, Source:=SetupSource.Version)},
181182
{"VersionAdvanceRun", New SetupEntry("", Source:=SetupSource.Version)},
182183
{"VersionAdvanceRunWait", New SetupEntry(True, Source:=SetupSource.Version)},
183184
{"VersionRamType", New SetupEntry(2, Source:=SetupSource.Version)},

Plain Craft Launcher 2/Pages/PageVersion/PageVersionSetup.xaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,9 @@
222222
<local:MyCheckBox Text="关闭文件校验" x:Name="CheckAdvanceAssetsV2" Tag="VersionAdvanceAssetsV2"
223223
ToolTip="完全不更改 assets;不校验 libraries、第三方登录库与版本主 jar 文件是否被修改。&#xa;如果你没有修改相关文件,请勿勾选此项。" />
224224
<local:MyCheckBox Text="使用 JLW" x:Name="CheckAdvanceUseLaunchWrapperV2" Tag="VersionAdvanceUseLaunchWrapperV2" Margin="50,0,0,0"
225-
ToolTip="在启动时额外加载 JLW 来处理中文目录。&#xa;如果服务器没有使用反作弊,请勿取消勾选此项。" />
225+
ToolTip="在启动时额外加载 JLW 来处理中文目录。&#xa;如果服务器没有使用反作弊,请勿取消勾选此项。" />
226+
<local:MyCheckBox Text="使用代理" x:Name="CheckAdvanceUseProxyV2" Tag="VersionAdvanceUseProxyV2" Margin="50,0,0,0"
227+
ToolTip="是否使用全局代理来启动游戏&#xa;错误的全局配置将会导致无法登录!" />
226228
</StackPanel>
227229
</Grid>
228230
</local:MyCard>

Plain Craft Launcher 2/Pages/PageVersion/PageVersionSetup.xaml.vb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
End If
7676
CheckAdvanceAssetsV2.Checked = Setup.Get("VersionAdvanceAssetsV2", Version:=PageVersionLeft.Version)
7777
CheckAdvanceUseLaunchWrapperV2.Checked = Setup.Get("VersionAdvanceUseLaunchWrapperV2", Version:=PageVersionLeft.Version)
78+
CheckAdvanceUseProxyV2.Checked = Setup.Get("VersionAdvanceUseProxyV2", Version:=PageVersionLeft.Version)
7879
CheckAdvanceJava.Checked = Setup.Get("VersionAdvanceJava", Version:=PageVersionLeft.Version)
7980

8081
Catch ex As Exception
@@ -106,6 +107,7 @@
106107
Setup.Reset("VersionAdvanceRun", Version:=PageVersionLeft.Version)
107108
Setup.Reset("VersionAdvanceRunWait", Version:=PageVersionLeft.Version)
108109
Setup.Reset("VersionAdvanceUseLaunchWrapperV2", Version:=PageVersionLeft.Version)
110+
Setup.Reset("VersionAdvanceUseProxyV2", Version:=PageVersionLeft.Version)
109111
Setup.Reset("VersionArgumentJavaSelect", Version:=PageVersionLeft.Version)
110112
JavaSearchLoader.Start(IsForceRestart:=True)
111113

@@ -136,7 +138,7 @@
136138
Private Shared Sub ComboChange(sender As MyComboBox, e As Object) Handles ComboArgumentIndie.SelectionChanged, ComboRamOptimize.SelectionChanged
137139
If AniControlEnabled = 0 Then Setup.Set(sender.Tag, sender.SelectedIndex, Version:=PageVersionLeft.Version)
138140
End Sub
139-
Private Shared Sub CheckBoxChange(sender As MyCheckBox, e As Object) Handles CheckAdvanceRunWait.Change, CheckAdvanceAssetsV2.Change, CheckAdvanceJava.Change, CheckAdvanceUseLaunchWrapperV2.Change
141+
Private Shared Sub CheckBoxChange(sender As MyCheckBox, e As Object) Handles CheckAdvanceRunWait.Change, CheckAdvanceAssetsV2.Change, CheckAdvanceJava.Change, CheckAdvanceUseLaunchWrapperV2.Change, CheckAdvanceUseProxyV2.Change
140142
If AniControlEnabled = 0 Then Setup.Set(sender.Tag, sender.Checked, Version:=PageVersionLeft.Version)
141143
End Sub
142144

@@ -171,7 +173,7 @@
171173
End If
172174
'设置文本
173175
LabRamGame.Text = If(RamGame = Math.Floor(RamGame), RamGame & ".0", RamGame) & " GB" &
174-
If(RamGame <> RamGameActual, " (可用 " & If(RamGameActual = Math.Floor(RamGameActual), RamGameActual & ".0", RamGameActual) & " GB)", "")
176+
If(Math.Abs(RamGame - RamGameActual) > 0.05, " (可用 " & If(RamGameActual = Math.Floor(RamGameActual), RamGameActual & ".0", RamGameActual) & " GB)", "")
175177
LabRamUsed.Text = If(RamUsed = Math.Floor(RamUsed), RamUsed & ".0", RamUsed) & " GB"
176178
LabRamTotal.Text = " / " & If(RamTotal = Math.Floor(RamTotal), RamTotal & ".0", RamTotal) & " GB"
177179
LabRamWarn.Visibility = If(RamGame = 1 AndAlso Not JavaIs64Bit(PageVersionLeft.Version) AndAlso Not Is32BitSystem AndAlso JavaList.Any, Visibility.Visible, Visibility.Collapsed)
@@ -513,4 +515,4 @@ PreFin:
513515

514516
#End Region
515517

516-
End Class
518+
End Class

0 commit comments

Comments
 (0)