Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ca627b8a2d | ||
|
|
a0c619a747 | ||
|
|
5386ae3736 | ||
|
|
32fd125b97 | ||
|
|
7a86881926 | ||
|
|
b255fd4601 | ||
|
|
562dd8d916 | ||
|
|
97d820446a | ||
|
|
826d382ad5 | ||
|
|
59d7ac3c82 | ||
|
|
566aed4ed6 | ||
|
|
1b90e94615 |
No files matched your search
+1
-1
@@ -38,7 +38,7 @@ def buildnumber = System.getenv("TRAVIS_BUILD_NUMBER")
|
||||
if (buildnumber == null)
|
||||
buildnumber = System.getenv("BUILD_NUMBER")
|
||||
if (buildnumber == null)
|
||||
buildnumber = "33"
|
||||
buildnumber = "42"
|
||||
|
||||
def versionroot = System.getenv("VERSION_ROOT")
|
||||
if (versionroot == null)
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.Authenticator;
|
||||
import java.net.PasswordAuthentication;
|
||||
import java.net.Proxy;
|
||||
import java.security.GeneralSecurityException;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.Locale;
|
||||
@@ -199,10 +200,24 @@ public final class Main {
|
||||
Settings.UPDATE_CHECKER.upgrade.register(IUpgrader.NOW_UPGRADER);
|
||||
Settings.UPDATE_CHECKER.process(false).reg(t -> Main.invokeUpdate()).execute();
|
||||
|
||||
if (StrUtils.isNotBlank(Settings.getInstance().getProxyHost()) && StrUtils.isNotBlank(Settings.getInstance().getProxyPort()) && MathUtils.canParseInt(Settings.getInstance().getProxyPort())) {
|
||||
HMCLog.log("Initializing customized proxy");
|
||||
System.setProperty("http.proxyHost", Settings.getInstance().getProxyHost());
|
||||
System.setProperty("http.proxyPort", Settings.getInstance().getProxyPort());
|
||||
if (Settings.getInstance().getProxyType() != Proxy.Type.DIRECT && StrUtils.isNotBlank(Settings.getInstance().getProxyHost())) {
|
||||
switch (Settings.getInstance().getProxyType()) {
|
||||
case DIRECT:
|
||||
break;
|
||||
case HTTP:
|
||||
System.setProperty("http.proxyHost", Settings.getInstance().getProxyHost());
|
||||
if (StrUtils.isNotBlank(Settings.getInstance().getProxyPort()))
|
||||
System.setProperty("http.proxyPort", Settings.getInstance().getProxyPort());
|
||||
HMCLog.log("Initialized HTTP proxy.");
|
||||
break;
|
||||
case SOCKS:
|
||||
System.setProperty("socksProxyHost", Settings.getInstance().getProxyHost());
|
||||
if (StrUtils.isNotBlank(Settings.getInstance().getProxyPort()))
|
||||
System.setProperty("socksProxyPort", Settings.getInstance().getProxyPort());
|
||||
HMCLog.log("Initialized Socks v4/v5 proxy.");
|
||||
break;
|
||||
}
|
||||
|
||||
if (StrUtils.isNotBlank(Settings.getInstance().getProxyUserName()) && StrUtils.isNotBlank(Settings.getInstance().getProxyPassword()))
|
||||
Authenticator.setDefault(new Authenticator() {
|
||||
@Override
|
||||
|
||||
@@ -20,6 +20,7 @@ package org.jackhuang.hmcl.setting;
|
||||
import org.jackhuang.hmcl.core.download.DownloadType;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import java.awt.Font;
|
||||
import java.net.Proxy;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -60,6 +61,8 @@ public final class Config implements Cloneable {
|
||||
private String proxyUserName;
|
||||
@SerializedName("proxyPassword")
|
||||
private String proxyPassword;
|
||||
@SerializedName("proxyType")
|
||||
private int proxyType;
|
||||
@SerializedName("enableShadow")
|
||||
private boolean enableShadow;
|
||||
@SerializedName("enableBlur")
|
||||
@@ -91,7 +94,7 @@ public final class Config implements Cloneable {
|
||||
|
||||
public Config() {
|
||||
clientToken = UUID.randomUUID().toString();
|
||||
logintype = downloadtype = 0;
|
||||
proxyType = logintype = downloadtype = 0;
|
||||
logLines = 100;
|
||||
enableAnimation = enableBlur = true;
|
||||
if (OS.os() == OS.WINDOWS)
|
||||
@@ -269,6 +272,19 @@ public final class Config implements Cloneable {
|
||||
Settings.save();
|
||||
}
|
||||
|
||||
public Proxy.Type getProxyType() {
|
||||
if (proxyType < 0 || proxyType >= 3) {
|
||||
proxyType = 0;
|
||||
Settings.save();
|
||||
}
|
||||
return Proxy.Type.values()[proxyType];
|
||||
}
|
||||
|
||||
public void setProxyType(Proxy.Type proxyType) {
|
||||
this.proxyType = proxyType.ordinal();
|
||||
Settings.save();
|
||||
}
|
||||
|
||||
public String getProxyUserName() {
|
||||
return proxyUserName == null ? "" : proxyUserName;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ import org.jackhuang.hmcl.api.event.config.ProfileLoadingEvent;
|
||||
import org.jackhuang.hmcl.laf.utils.AnimationController;
|
||||
import org.jackhuang.hmcl.util.sys.FileUtils;
|
||||
import org.jackhuang.hmcl.util.ui.MessageBox;
|
||||
import org.jackhuang.hmcl.util.UpdateChecker;
|
||||
import org.jackhuang.hmcl.util.upgrade.UpdateChecker;
|
||||
import org.jackhuang.hmcl.util.sys.IOUtils;
|
||||
|
||||
/**
|
||||
|
||||
@@ -95,35 +95,36 @@
|
||||
<Component id="btnCheckUpdate" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="btnMCBBS" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="0" pref="418" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<Component id="lblProxy" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<Component id="lblProxyHost" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="txtProxyHost" min="-2" pref="80" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="lblProxyPort" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="txtProxyPort" min="-2" pref="80" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="lblProxyUserName" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="txtProxyUsername" min="-2" pref="80" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="lblProxyPassword" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="txtProxyPassword" min="-2" pref="80" max="-2" attributes="0"/>
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="lblDownloadSource" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="lblCommonPath" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="lblLang" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="lblProxy" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace min="-2" pref="28" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="cboProxyType" pref="156" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="lblProxyHost" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="txtProxyHost" min="-2" pref="80" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="lblProxyPort" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="txtProxyPort" min="-2" pref="80" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="lblProxyUserName" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="txtProxyUsername" min="-2" pref="80" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="lblProxyPassword" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="txtProxyPassword" min="-2" pref="80" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="cboLang" alignment="1" max="32767" attributes="0"/>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="txtCommonPath" max="32767" attributes="0"/>
|
||||
@@ -168,6 +169,7 @@
|
||||
<Component id="lblProxyUserName" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="txtProxyPassword" alignment="3" min="-2" pref="26" max="-2" attributes="0"/>
|
||||
<Component id="lblProxyPassword" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="cboProxyType" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace pref="69" max="32767" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
@@ -315,6 +317,23 @@
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JComboBox" name="cboProxyType">
|
||||
<Properties>
|
||||
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
|
||||
<StringArray count="3">
|
||||
<StringItem index="0" value="Direct"/>
|
||||
<StringItem index="1" value="HTTP"/>
|
||||
<StringItem index="2" value="Socks"/>
|
||||
</StringArray>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="cboProxyTypeItemStateChanged"/>
|
||||
</Events>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Container class="javax.swing.JPanel" name="pnlUI">
|
||||
@@ -348,7 +367,7 @@
|
||||
<Component id="chkEnableAnimation" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace min="0" pref="15" max="32767" attributes="0"/>
|
||||
<EmptySpace min="0" pref="163" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
@@ -500,7 +519,7 @@
|
||||
<Component class="javax.swing.JComboBox" name="cboFontFamily">
|
||||
<Properties>
|
||||
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<SerializedValue value="-84,-19,0,5,115,114,0,32,106,97,118,97,120,46,115,119,105,110,103,46,68,101,102,97,117,108,116,67,111,109,98,111,66,111,120,77,111,100,101,108,92,-10,105,-80,-61,-104,-56,48,2,0,2,76,0,7,111,98,106,101,99,116,115,116,0,18,76,106,97,118,97,47,117,116,105,108,47,86,101,99,116,111,114,59,76,0,14,115,101,108,101,99,116,101,100,79,98,106,101,99,116,116,0,18,76,106,97,118,97,47,108,97,110,103,47,79,98,106,101,99,116,59,120,114,0,29,106,97,118,97,120,46,115,119,105,110,103,46,65,98,115,116,114,97,99,116,76,105,115,116,77,111,100,101,108,87,-79,61,-30,108,45,-87,-39,2,0,1,76,0,12,108,105,115,116,101,110,101,114,76,105,115,116,116,0,37,76,106,97,118,97,120,47,115,119,105,110,103,47,101,118,101,110,116,47,69,118,101,110,116,76,105,115,116,101,110,101,114,76,105,115,116,59,120,112,115,114,0,35,106,97,118,97,120,46,115,119,105,110,103,46,101,118,101,110,116,46,69,118,101,110,116,76,105,115,116,101,110,101,114,76,105,115,116,-79,54,-58,125,-124,-22,-42,68,3,0,0,120,112,116,0,34,106,97,118,97,120,46,115,119,105,110,103,46,101,118,101,110,116,46,76,105,115,116,68,97,116,97,76,105,115,116,101,110,101,114,115,114,0,21,106,97,118,97,120,46,115,119,105,110,103,46,74,67,111,109,98,111,66,111,120,115,-25,-16,-68,-83,109,105,-54,3,0,14,90,0,17,102,105,114,105,110,103,65,99,116,105,111,110,69,118,101,110,116,90,0,10,105,115,69,100,105,116,97,98,108,101,90,0,23,108,105,103,104,116,87,101,105,103,104,116,80,111,112,117,112,69,110,97,98,108,101,100,73,0,15,109,97,120,105,109,117,109,82,111,119,67,111,117,110,116,90,0,13,115,101,108,101,99,116,105,110,103,73,116,101,109,76,0,6,97,99,116,105,111,110,116,0,20,76,106,97,118,97,120,47,115,119,105,110,103,47,65,99,116,105,111,110,59,76,0,13,97,99,116,105,111,110,67,111,109,109,97,110,100,116,0,18,76,106,97,118,97,47,108,97,110,103,47,83,116,114,105,110,103,59,76,0,28,97,99,116,105,111,110,80,114,111,112,101,114,116,121,67,104,97,110,103,101,76,105,115,116,101,110,101,114,116,0,35,76,106,97,118,97,47,98,101,97,110,115,47,80,114,111,112,101,114,116,121,67,104,97,110,103,101,76,105,115,116,101,110,101,114,59,76,0,9,100,97,116,97,77,111,100,101,108,116,0,27,76,106,97,118,97,120,47,115,119,105,110,103,47,67,111,109,98,111,66,111,120,77,111,100,101,108,59,76,0,6,101,100,105,116,111,114,116,0,28,76,106,97,118,97,120,47,115,119,105,110,103,47,67,111,109,98,111,66,111,120,69,100,105,116,111,114,59,76,0,19,107,101,121,83,101,108,101,99,116,105,111,110,77,97,110,97,103,101,114,116,0,43,76,106,97,118,97,120,47,115,119,105,110,103,47,74,67,111,109,98,111,66,111,120,36,75,101,121,83,101,108,101,99,116,105,111,110,77,97,110,97,103,101,114,59,76,0,21,112,114,111,116,111,116,121,112,101,68,105,115,112,108,97,121,86,97,108,117,101,113,0,126,0,2,76,0,8,114,101,110,100,101,114,101,114,116,0,30,76,106,97,118,97,120,47,115,119,105,110,103,47,76,105,115,116,67,101,108,108,82,101,110,100,101,114,101,114,59,76,0,20,115,101,108,101,99,116,101,100,73,116,101,109,82,101,109,105,110,100,101,114,113,0,126,0,2,120,114,0,22,106,97,118,97,120,46,115,119,105,110,103,46,74,67,111,109,112,111,110,101,110,116,51,-17,99,38,30,108,-90,-113,3,0,16,70,0,10,97,108,105,103,110,109,101,110,116,88,70,0,10,97,108,105,103,110,109,101,110,116,89,90,0,11,97,117,116,111,115,99,114,111,108,108,115,73,0,5,102,108,97,103,115,90,0,15,105,115,65,108,105,103,110,109,101,110,116,88,83,101,116,90,0,15,105,115,65,108,105,103,110,109,101,110,116,89,83,101,116,90,0,26,118,101,114,105,102,121,73,110,112,117,116,87,104,101,110,70,111,99,117,115,84,97,114,103,101,116,76,0,9,97,99,116,105,111,110,77,97,112,116,0,23,76,106,97,118,97,120,47,115,119,105,110,103,47,65,99,116,105,111,110,77,97,112,59,76,0,16,97,110,99,101,115,116,111,114,73,110,112,117,116,77,97,112,116,0,22,76,106,97,118,97,120,47,115,119,105,110,103,47,73,110,112,117,116,77,97,112,59,76,0,6,98,111,114,100,101,114,116,0,27,76,106,97,118,97,120,47,115,119,105,110,103,47,98,111,114,100,101,114,47,66,111,114,100,101,114,59,76,0,13,102,111,99,117,115,73,110,112,117,116,77,97,112,113,0,126,0,19,76,0,13,105,110,112,117,116,86,101,114,105,102,105,101,114,116,0,27,76,106,97,118,97,120,47,115,119,105,110,103,47,73,110,112,117,116,86,101,114,105,102,105,101,114,59,76,0,12,108,105,115,116,101,110,101,114,76,105,115,116,113,0,126,0,4,76,0,9,112,111,112,117,112,77,101,110,117,116,0,24,76,106,97,118,97,120,47,115,119,105,110,103,47,74,80,111,112,117,112,77,101,110,117,59,76,0,21,118,101,116,111,97,98,108,101,67,104,97,110,103,101,83,117,112,112,111,114,116,116,0,34,76,106,97,118,97,47,98,101,97,110,115,47,86,101,116,111,97,98,108,101,67,104,97,110,103,101,83,117,112,112,111,114,116,59,76,0,14,119,105,110,100,111,119,73,110,112,117,116,77,97,112,116,0,31,76,106,97,118,97,120,47,115,119,105,110,103,47,67,111,109,112,111,110,101,110,116,73,110,112,117,116,77,97,112,59,120,114,0,18,106,97,118,97,46,97,119,116,46,67,111,110,116,97,105,110,101,114,64,7,-128,115,-3,20,12,39,3,0,8,73,0,30,99,111,110,116,97,105,110,101,114,83,101,114,105,97,108,105,122,101,100,68,97,116Line truncated
|
||||
<SerializedValue value="-84,-19,0,5,115,114,0,32,106,97,118,97,120,46,115,119,105,110,103,46,68,101,102,97,117,108,116,67,111,109,98,111,66,111,120,77,111,100,101,108,92,-10,105,-80,-61,-104,-56,48,2,0,2,76,0,7,111,98,106,101,99,116,115,116,0,18,76,106,97,118,97,47,117,116,105,108,47,86,101,99,116,111,114,59,76,0,14,115,101,108,101,99,116,101,100,79,98,106,101,99,116,116,0,18,76,106,97,118,97,47,108,97,110,103,47,79,98,106,101,99,116,59,120,114,0,29,106,97,118,97,120,46,115,119,105,110,103,46,65,98,115,116,114,97,99,116,76,105,115,116,77,111,100,101,108,87,-79,61,-30,108,45,-87,-39,2,0,1,76,0,12,108,105,115,116,101,110,101,114,76,105,115,116,116,0,37,76,106,97,118,97,120,47,115,119,105,110,103,47,101,118,101,110,116,47,69,118,101,110,116,76,105,115,116,101,110,101,114,76,105,115,116,59,120,112,115,114,0,35,106,97,118,97,120,46,115,119,105,110,103,46,101,118,101,110,116,46,69,118,101,110,116,76,105,115,116,101,110,101,114,76,105,115,116,-79,54,-58,125,-124,-22,-42,68,3,0,0,120,112,116,0,34,106,97,118,97,120,46,115,119,105,110,103,46,101,118,101,110,116,46,76,105,115,116,68,97,116,97,76,105,115,116,101,110,101,114,115,114,0,21,106,97,118,97,120,46,115,119,105,110,103,46,74,67,111,109,98,111,66,111,120,115,-25,-16,-68,-83,109,105,-54,3,0,14,90,0,17,102,105,114,105,110,103,65,99,116,105,111,110,69,118,101,110,116,90,0,10,105,115,69,100,105,116,97,98,108,101,90,0,23,108,105,103,104,116,87,101,105,103,104,116,80,111,112,117,112,69,110,97,98,108,101,100,73,0,15,109,97,120,105,109,117,109,82,111,119,67,111,117,110,116,90,0,13,115,101,108,101,99,116,105,110,103,73,116,101,109,76,0,6,97,99,116,105,111,110,116,0,20,76,106,97,118,97,120,47,115,119,105,110,103,47,65,99,116,105,111,110,59,76,0,13,97,99,116,105,111,110,67,111,109,109,97,110,100,116,0,18,76,106,97,118,97,47,108,97,110,103,47,83,116,114,105,110,103,59,76,0,28,97,99,116,105,111,110,80,114,111,112,101,114,116,121,67,104,97,110,103,101,76,105,115,116,101,110,101,114,116,0,35,76,106,97,118,97,47,98,101,97,110,115,47,80,114,111,112,101,114,116,121,67,104,97,110,103,101,76,105,115,116,101,110,101,114,59,76,0,9,100,97,116,97,77,111,100,101,108,116,0,27,76,106,97,118,97,120,47,115,119,105,110,103,47,67,111,109,98,111,66,111,120,77,111,100,101,108,59,76,0,6,101,100,105,116,111,114,116,0,28,76,106,97,118,97,120,47,115,119,105,110,103,47,67,111,109,98,111,66,111,120,69,100,105,116,111,114,59,76,0,19,107,101,121,83,101,108,101,99,116,105,111,110,77,97,110,97,103,101,114,116,0,43,76,106,97,118,97,120,47,115,119,105,110,103,47,74,67,111,109,98,111,66,111,120,36,75,101,121,83,101,108,101,99,116,105,111,110,77,97,110,97,103,101,114,59,76,0,21,112,114,111,116,111,116,121,112,101,68,105,115,112,108,97,121,86,97,108,117,101,113,0,126,0,2,76,0,8,114,101,110,100,101,114,101,114,116,0,30,76,106,97,118,97,120,47,115,119,105,110,103,47,76,105,115,116,67,101,108,108,82,101,110,100,101,114,101,114,59,76,0,20,115,101,108,101,99,116,101,100,73,116,101,109,82,101,109,105,110,100,101,114,113,0,126,0,2,120,114,0,22,106,97,118,97,120,46,115,119,105,110,103,46,74,67,111,109,112,111,110,101,110,116,51,-17,99,38,30,108,-90,-113,3,0,16,70,0,10,97,108,105,103,110,109,101,110,116,88,70,0,10,97,108,105,103,110,109,101,110,116,89,90,0,11,97,117,116,111,115,99,114,111,108,108,115,73,0,5,102,108,97,103,115,90,0,15,105,115,65,108,105,103,110,109,101,110,116,88,83,101,116,90,0,15,105,115,65,108,105,103,110,109,101,110,116,89,83,101,116,90,0,26,118,101,114,105,102,121,73,110,112,117,116,87,104,101,110,70,111,99,117,115,84,97,114,103,101,116,76,0,9,97,99,116,105,111,110,77,97,112,116,0,23,76,106,97,118,97,120,47,115,119,105,110,103,47,65,99,116,105,111,110,77,97,112,59,76,0,16,97,110,99,101,115,116,111,114,73,110,112,117,116,77,97,112,116,0,22,76,106,97,118,97,120,47,115,119,105,110,103,47,73,110,112,117,116,77,97,112,59,76,0,6,98,111,114,100,101,114,116,0,27,76,106,97,118,97,120,47,115,119,105,110,103,47,98,111,114,100,101,114,47,66,111,114,100,101,114,59,76,0,13,102,111,99,117,115,73,110,112,117,116,77,97,112,113,0,126,0,19,76,0,13,105,110,112,117,116,86,101,114,105,102,105,101,114,116,0,27,76,106,97,118,97,120,47,115,119,105,110,103,47,73,110,112,117,116,86,101,114,105,102,105,101,114,59,76,0,12,108,105,115,116,101,110,101,114,76,105,115,116,113,0,126,0,4,76,0,9,112,111,112,117,112,77,101,110,117,116,0,24,76,106,97,118,97,120,47,115,119,105,110,103,47,74,80,111,112,117,112,77,101,110,117,59,76,0,21,118,101,116,111,97,98,108,101,67,104,97,110,103,101,83,117,112,112,111,114,116,116,0,34,76,106,97,118,97,47,98,101,97,110,115,47,86,101,116,111,97,98,108,101,67,104,97,110,103,101,83,117,112,112,111,114,116,59,76,0,14,119,105,110,100,111,119,73,110,112,117,116,77,97,112,116,0,31,76,106,97,118,97,120,47,115,119,105,110,103,47,67,111,109,112,111,110,101,110,116,73,110,112,117,116,77,97,112,59,120,114,0,18,106,97,118,97,46,97,119,116,46,67,111,110,116,97,105,110,101,114,64,7,-128,115,-3,20,12,39,3,0,8,73,0,30,99,111,110,116,97,105,110,101,114,83,101,114,105,97,108,105,122,101,100,68,97,116Line truncated
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
@@ -549,7 +568,7 @@
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="lblAbout" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace pref="104" max="32767" attributes="0"/>
|
||||
<EmptySpace pref="252" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
package org.jackhuang.hmcl.ui;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.Proxy;
|
||||
import javax.swing.DefaultComboBoxModel;
|
||||
import javax.swing.filechooser.FileNameExtensionFilter;
|
||||
import org.jackhuang.hmcl.util.C;
|
||||
@@ -78,6 +79,7 @@ public class LauncherSettingsPanel extends RepaintPage {
|
||||
spinnerFontSize.setValue(Settings.getInstance().getFontSize());
|
||||
cboFontFamily.setSelectedItem(Settings.getInstance().getFontFamily());
|
||||
cboDownloadSource.setSelectedIndex(Settings.getInstance().getDownloadType());
|
||||
cboProxyType.setSelectedIndex(Settings.getInstance().getProxyType().ordinal());
|
||||
cboTheme.setSelectedItem(Settings.getInstance().getTheme());
|
||||
chkEnableShadow.setSelected(Settings.getInstance().isEnableShadow());
|
||||
chkEnableBlur.setSelected(Settings.getInstance().isEnableBlur());
|
||||
@@ -122,6 +124,7 @@ public class LauncherSettingsPanel extends RepaintPage {
|
||||
btnMCBBS = new javax.swing.JButton();
|
||||
cboLang = new javax.swing.JComboBox();
|
||||
lblLang = new javax.swing.JLabel();
|
||||
cboProxyType = new javax.swing.JComboBox<>();
|
||||
pnlUI = new Page().setAnimationEnabled(Settings.getInstance().isEnableAnimation());
|
||||
lblTheme = new javax.swing.JLabel();
|
||||
cboTheme = new javax.swing.JComboBox();
|
||||
@@ -231,6 +234,13 @@ public class LauncherSettingsPanel extends RepaintPage {
|
||||
|
||||
lblLang.setText(C.i18n("launcher.lang")); // NOI18N
|
||||
|
||||
cboProxyType.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Direct", "HTTP", "Socks" }));
|
||||
cboProxyType.addItemListener(new java.awt.event.ItemListener() {
|
||||
public void itemStateChanged(java.awt.event.ItemEvent evt) {
|
||||
cboProxyTypeItemStateChanged(evt);
|
||||
}
|
||||
});
|
||||
|
||||
javax.swing.GroupLayout pnlGeneralLayout = new javax.swing.GroupLayout(pnlGeneral);
|
||||
pnlGeneral.setLayout(pnlGeneralLayout);
|
||||
pnlGeneralLayout.setHorizontalGroup(
|
||||
@@ -242,32 +252,33 @@ public class LauncherSettingsPanel extends RepaintPage {
|
||||
.addComponent(btnCheckUpdate)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(btnMCBBS)
|
||||
.addGap(0, 418, Short.MAX_VALUE))
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlGeneralLayout.createSequentialGroup()
|
||||
.addComponent(lblProxy)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(lblProxyHost)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(txtProxyHost, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(lblProxyPort)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(txtProxyPort, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(lblProxyUserName)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(txtProxyUsername, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(lblProxyPassword)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(txtProxyPassword, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGap(0, 0, Short.MAX_VALUE))
|
||||
.addGroup(pnlGeneralLayout.createSequentialGroup()
|
||||
.addGroup(pnlGeneralLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(lblDownloadSource)
|
||||
.addComponent(lblCommonPath)
|
||||
.addComponent(lblLang))
|
||||
.addComponent(lblLang)
|
||||
.addComponent(lblProxy))
|
||||
.addGap(28, 28, 28)
|
||||
.addGroup(pnlGeneralLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(pnlGeneralLayout.createSequentialGroup()
|
||||
.addComponent(cboProxyType, 0, 156, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(lblProxyHost)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(txtProxyHost, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(lblProxyPort)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(txtProxyPort, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(lblProxyUserName)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(txtProxyUsername, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(lblProxyPassword)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(txtProxyPassword, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addComponent(cboLang, javax.swing.GroupLayout.Alignment.TRAILING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGroup(pnlGeneralLayout.createSequentialGroup()
|
||||
.addComponent(txtCommonPath)
|
||||
@@ -302,7 +313,8 @@ public class LauncherSettingsPanel extends RepaintPage {
|
||||
.addComponent(txtProxyUsername, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(lblProxyUserName)
|
||||
.addComponent(txtProxyPassword, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(lblProxyPassword))
|
||||
.addComponent(lblProxyPassword)
|
||||
.addComponent(cboProxyType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 69, Short.MAX_VALUE)
|
||||
.addGroup(pnlGeneralLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(btnCheckUpdate, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
@@ -397,7 +409,7 @@ public class LauncherSettingsPanel extends RepaintPage {
|
||||
.addComponent(chkEnableBlur)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(chkEnableAnimation)))
|
||||
.addGap(0, 15, Short.MAX_VALUE))
|
||||
.addGap(0, 163, Short.MAX_VALUE))
|
||||
.addGroup(pnlUILayout.createSequentialGroup()
|
||||
.addGroup(pnlUILayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(lblBackground)
|
||||
@@ -460,7 +472,7 @@ public class LauncherSettingsPanel extends RepaintPage {
|
||||
.addGroup(pnlAboutLayout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(lblAbout, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addContainerGap(104, Short.MAX_VALUE))
|
||||
.addContainerGap(252, Short.MAX_VALUE))
|
||||
);
|
||||
pnlAboutLayout.setVerticalGroup(
|
||||
pnlAboutLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
@@ -612,6 +624,10 @@ public class LauncherSettingsPanel extends RepaintPage {
|
||||
lblExample.setFont(Settings.getInstance().getConsoleFont());
|
||||
}//GEN-LAST:event_spinnerFontSizeStateChanged
|
||||
|
||||
private void cboProxyTypeItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cboProxyTypeItemStateChanged
|
||||
Settings.getInstance().setProxyType(Proxy.Type.values()[cboProxyType.getSelectedIndex()]);
|
||||
}//GEN-LAST:event_cboProxyTypeItemStateChanged
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton btnCheckUpdate;
|
||||
private javax.swing.JButton btnMCBBS;
|
||||
@@ -620,6 +636,7 @@ public class LauncherSettingsPanel extends RepaintPage {
|
||||
private javax.swing.JComboBox cboDownloadSource;
|
||||
private javax.swing.JComboBox cboFontFamily;
|
||||
private javax.swing.JComboBox cboLang;
|
||||
private javax.swing.JComboBox<String> cboProxyType;
|
||||
private javax.swing.JComboBox cboTheme;
|
||||
private javax.swing.JCheckBox chkDecorated;
|
||||
private javax.swing.JCheckBox chkEnableAnimation;
|
||||
|
||||
@@ -52,8 +52,9 @@ import org.xml.sax.XMLReader;
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public class LaunchingUIDaemon {
|
||||
|
||||
|
||||
XMLReader reader;
|
||||
Log4jHandler logHandler;
|
||||
|
||||
public LaunchingUIDaemon() {
|
||||
HMCLApi.EVENT_BUS.channel(LaunchingStateChangedEvent.class).register(LAUNCHING_STATE_CHANGED);
|
||||
@@ -76,12 +77,12 @@ public class LaunchingUIDaemon {
|
||||
PipedOutputStream os = new PipedOutputStream();
|
||||
monitor.setTag(obj);
|
||||
try {
|
||||
Log4jHandler handler = new Log4jHandler(monitor, os);
|
||||
handler.addForbiddenToken(obj.getLoginResult().getAccessToken(), "<access token>");
|
||||
handler.addForbiddenToken(obj.getLoginResult().getSession(), "<session>");
|
||||
handler.addForbiddenToken(obj.getLoginResult().getUserId(), "<uuid>");
|
||||
handler.addForbiddenToken("Setting user: " + obj.getLoginResult().getUserName(), "<player>");
|
||||
handler.start();
|
||||
logHandler = new Log4jHandler(monitor, os, false);
|
||||
logHandler.addForbiddenToken(obj.getLoginResult().getAccessToken(), "<access token>");
|
||||
logHandler.addForbiddenToken(obj.getLoginResult().getSession(), "<session>");
|
||||
logHandler.addForbiddenToken(obj.getLoginResult().getUserId(), "<uuid>");
|
||||
logHandler.addForbiddenToken("Setting user: " + obj.getLoginResult().getUserName(), "<player>");
|
||||
logHandler.start();
|
||||
} catch(Exception e) {
|
||||
HMCLog.err("", e);
|
||||
}
|
||||
@@ -128,7 +129,7 @@ public class LaunchingUIDaemon {
|
||||
noExitThisTime = true;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
static LauncherVisibility unpackProcessMonitor(Object obj) {
|
||||
GameLauncher launcher = ((GameLauncher) ((ProcessMonitor) obj).getTag());
|
||||
HMCLGameLauncher.GameLauncherTag tag = (HMCLGameLauncher.GameLauncherTag) launcher.getTag();
|
||||
@@ -161,9 +162,9 @@ public class LaunchingUIDaemon {
|
||||
((HMCLGameLauncher.GameLauncherTag) value.getTag()).state = 2;
|
||||
}, MainFrame.INSTANCE::failed, Settings.getInstance().getAuthenticator().getPassword());
|
||||
}
|
||||
|
||||
|
||||
class PrintlnProcessor implements Consumer<PrintlnEvent> {
|
||||
|
||||
|
||||
GameLauncher launcher;
|
||||
PipedOutputStream os;
|
||||
|
||||
@@ -174,25 +175,24 @@ public class LaunchingUIDaemon {
|
||||
|
||||
@Override
|
||||
public void accept(PrintlnEvent t) {
|
||||
if (!t.isError())
|
||||
try {
|
||||
os.write((t.getLine() + C.LINE_SEPARATOR).replace("log4j:Event", "log4j_Event").replace("log4j:Message", "log4j_Message").getBytes());
|
||||
os.flush();
|
||||
} catch(IOException e) {
|
||||
HMCLog.err("", e);
|
||||
}
|
||||
String log = t.getLine();
|
||||
if (!t.isError() && logHandler != null) {
|
||||
logHandler.newLogLine(log + C.LINE_SEPARATOR);
|
||||
}
|
||||
else System.err.println(t.getLine());
|
||||
HMCLGameLauncher.GameLauncherTag tag = (HMCLGameLauncher.GameLauncherTag) launcher.getTag();
|
||||
LauncherVisibility l = tag.launcherVisibility;
|
||||
if (t.getLine().contains("LWJGL Version: ") && l != LauncherVisibility.KEEP)
|
||||
if (l != LauncherVisibility.HIDE_AND_REOPEN)
|
||||
MainFrame.INSTANCE.dispose();
|
||||
else { // If current state is 'hide and reopen', closes the main window and reset the state to normal.
|
||||
MainFrame.INSTANCE.setVisible(false);
|
||||
HMCLApi.EVENT_BUS.fireChannel(new LaunchingStateChangedEvent(launcher, LaunchingState.Done));
|
||||
}
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
if (l != LauncherVisibility.HIDE_AND_REOPEN)
|
||||
MainFrame.INSTANCE.dispose();
|
||||
else { // If current state is 'hide and reopen', closes the main window and reset the state to normal.
|
||||
MainFrame.INSTANCE.setVisible(false);
|
||||
HMCLApi.EVENT_BUS.fireChannel(new LaunchingStateChangedEvent(launcher, LaunchingState.Done));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private static final Consumer<LaunchingStateChangedEvent> LAUNCHING_STATE_CHANGED = t -> {
|
||||
@@ -231,13 +231,10 @@ public class LaunchingUIDaemon {
|
||||
|
||||
private void checkExit(LauncherVisibility v) {
|
||||
if (v == LauncherVisibility.HIDE_AND_REOPEN) {
|
||||
HMCLog.log("Launcher will not exit now.");
|
||||
MainFrame.INSTANCE.setVisible(true);
|
||||
} else if (v != LauncherVisibility.KEEP && !LogWindow.INSTANCE.isVisible() && !noExitThisTime) {
|
||||
HMCLog.log("Launcher will exit now.");
|
||||
System.exit(0);
|
||||
} else {
|
||||
HMCLog.log("Launcher will not exit now.");
|
||||
noExitThisTime = false;
|
||||
}
|
||||
}
|
||||
@@ -253,5 +250,5 @@ public class LaunchingUIDaemon {
|
||||
}
|
||||
MainFrame.INSTANCE.closeMessage();
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
@@ -252,7 +252,7 @@ public class LogWindow extends javax.swing.JFrame {
|
||||
}//GEN-LAST:event_btnClearActionPerformed
|
||||
|
||||
private void btnCopyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCopyActionPerformed
|
||||
Utils.setClipborad(this.txtLog.getText());
|
||||
Utils.setClipboard(this.txtLog.getText());
|
||||
}//GEN-LAST:event_btnCopyActionPerformed
|
||||
|
||||
private void btnContactActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnContactActionPerformed
|
||||
|
||||
@@ -39,7 +39,7 @@ public class HMCLGameProvider extends MinecraftVersionManager<HMCLMinecraftServi
|
||||
public File getLibraryFile(MinecraftVersion version, IMinecraftLibrary lib) {
|
||||
VersionSetting vs = service.getProfile().getVersionSetting(version.id);
|
||||
File self = super.getLibraryFile(version, lib);
|
||||
if (self.exists() || (vs != null && service.getProfile().isNoCommon()))
|
||||
if (self == null || self.exists() || (vs != null && service.getProfile().isNoCommon()))
|
||||
return self;
|
||||
else
|
||||
return lib.getFilePath(new File(Settings.getInstance().getCommonpath()));
|
||||
|
||||
@@ -18,14 +18,18 @@
|
||||
package org.jackhuang.hmcl.util;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InterruptedIOException;
|
||||
import java.io.PipedInputStream;
|
||||
import java.io.PipedOutputStream;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import org.jackhuang.hmcl.api.HMCLApi;
|
||||
import org.jackhuang.hmcl.api.HMCLog;
|
||||
import org.jackhuang.hmcl.api.event.process.JavaProcessStoppedEvent;
|
||||
import org.jackhuang.hmcl.api.func.Consumer;
|
||||
import org.jackhuang.hmcl.ui.LogWindow;
|
||||
@@ -49,12 +53,16 @@ public class Log4jHandler extends Thread implements Consumer<JavaProcessStoppedE
|
||||
PipedInputStream inputStream;
|
||||
PipedOutputStream outputStream;
|
||||
List<Pair<String, String>> forbiddenTokens = new LinkedList<>();
|
||||
AtomicBoolean interrupted = new AtomicBoolean(false);
|
||||
ExecutorService executorService = Executors.newSingleThreadExecutor();
|
||||
boolean enabled = true;
|
||||
|
||||
public Log4jHandler(ProcessMonitor monitor, PipedOutputStream outputStream) throws ParserConfigurationException, IOException, SAXException {
|
||||
public Log4jHandler(ProcessMonitor monitor, PipedOutputStream outputStream, boolean enabled) throws ParserConfigurationException, IOException, SAXException {
|
||||
reader = XMLReaderFactory.createXMLReader();
|
||||
inputStream = new PipedInputStream(outputStream);
|
||||
this.outputStream = outputStream;
|
||||
this.monitor = monitor;
|
||||
this.enabled = enabled;
|
||||
|
||||
HMCLApi.EVENT_BUS.channel(JavaProcessStoppedEvent.class).register((Consumer<JavaProcessStoppedEvent>) this);
|
||||
}
|
||||
@@ -66,27 +74,83 @@ public class Log4jHandler extends Thread implements Consumer<JavaProcessStoppedE
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
outputStream.write("<output>".getBytes());
|
||||
outputStream.flush();
|
||||
setName("log4j-handler");
|
||||
if (enabled)
|
||||
newLogLine("<output>");
|
||||
reader.setContentHandler(new Log4jHandlerImpl());
|
||||
reader.parse(new InputSource(inputStream));
|
||||
} catch (InterruptedIOException e) {
|
||||
interrupted.set(true);
|
||||
} catch (SAXException | IOException e) {
|
||||
|
||||
throw new Error(e);
|
||||
} finally {
|
||||
executorService.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(JavaProcessStoppedEvent t) {
|
||||
if (!interrupted.get())
|
||||
return;
|
||||
if (t.getSource() == monitor) {
|
||||
try {
|
||||
outputStream.write("</output>".getBytes());
|
||||
outputStream.close();
|
||||
} catch (IOException ignore) { // won't happen
|
||||
throw new Error(ignore);
|
||||
executorService.submit(() -> {
|
||||
if (!interrupted.get()) {
|
||||
if (enabled) {
|
||||
Future f = newLogLine("</output>");
|
||||
if (f != null)
|
||||
f.get();
|
||||
}
|
||||
outputStream.close();
|
||||
join();
|
||||
}
|
||||
return null;
|
||||
}).get();
|
||||
} catch (Exception e) {
|
||||
HMCLog.err("Please contact author", e);
|
||||
} finally {
|
||||
executorService.shutdown();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Always use this instance method to write to the log,
|
||||
* to make sure only this Thread writes to the PipedOutputStream.
|
||||
*
|
||||
* It will also flush the buffer, directly after write.
|
||||
*
|
||||
* This prevents java.io.IOException: Read end dead
|
||||
* See also https://techtavern.wordpress.com/2008/07/16/whats-this-ioexception-write-end-dead/
|
||||
*
|
||||
* @param content The content to be written to the log
|
||||
*/
|
||||
public Future newLogLine(String content) {
|
||||
try {
|
||||
return executorService.submit(() -> {
|
||||
if (enabled)
|
||||
try {
|
||||
String log = content;
|
||||
if (!log.trim().startsWith("<")) { // without logging configuration.
|
||||
log = "<![CDATA[" + log.replace("]]>", "") + "]]>";
|
||||
}
|
||||
outputStream.write(log
|
||||
.replace("log4j:Event", "log4j_Event")
|
||||
.replace("log4j:Message", "log4j_Message")
|
||||
.replace("log4j:Throwable", "log4j_Throwable")
|
||||
.getBytes());
|
||||
outputStream.flush();
|
||||
} catch (IOException ignore) { // won't happen
|
||||
throw new Error(ignore);
|
||||
}
|
||||
else
|
||||
printlnImpl(content, Level.guessLevel(content));
|
||||
});
|
||||
} catch (RejectedExecutionException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
class Log4jHandlerImpl extends DefaultHandler {
|
||||
private final SimpleDateFormat df = new SimpleDateFormat("HH:mm:ss");
|
||||
|
||||
@@ -141,10 +205,14 @@ public class Log4jHandler extends Thread implements Consumer<JavaProcessStoppedE
|
||||
}
|
||||
|
||||
public void println(String message, Level l) {
|
||||
for (Pair<String, String> entry : forbiddenTokens)
|
||||
message = message.replace(entry.key, entry.value);
|
||||
if (LogWindow.outputStream != null)
|
||||
LogWindow.outputStream.log(message, l);
|
||||
printlnImpl(message, l);
|
||||
}
|
||||
}
|
||||
|
||||
private void printlnImpl(String message, Level l) {
|
||||
for (Pair<String, String> entry : forbiddenTokens)
|
||||
message = message.replace(entry.key, entry.value);
|
||||
if (LogWindow.outputStream != null)
|
||||
LogWindow.outputStream.log(message, l);
|
||||
}
|
||||
}
|
||||
@@ -47,7 +47,6 @@ import org.jackhuang.hmcl.util.task.TaskWindow;
|
||||
import org.jackhuang.hmcl.util.net.FileDownloadTask;
|
||||
import org.jackhuang.hmcl.util.ArrayUtils;
|
||||
import org.jackhuang.hmcl.util.ui.MessageBox;
|
||||
import org.jackhuang.hmcl.util.UpdateChecker;
|
||||
import org.jackhuang.hmcl.util.Utils;
|
||||
import org.jackhuang.hmcl.api.VersionNumber;
|
||||
import org.jackhuang.hmcl.util.StrUtils;
|
||||
@@ -137,17 +136,17 @@ public class AppDataUpgrader extends IUpgrader {
|
||||
else {
|
||||
String url = C.URL_PUBLISH;
|
||||
if (map != null)
|
||||
if (map.containsKey(OS.os().checked_name))
|
||||
url = map.get(OS.os().checked_name);
|
||||
else if (map.containsKey(OS.UNKOWN.checked_name))
|
||||
url = map.get(OS.UNKOWN.checked_name);
|
||||
if (map.containsKey(OS.os().checkedName))
|
||||
url = map.get(OS.os().checkedName);
|
||||
else if (map.containsKey(OS.UNKNOWN.checkedName))
|
||||
url = map.get(OS.UNKNOWN.checkedName);
|
||||
if (url == null)
|
||||
url = C.URL_PUBLISH;
|
||||
try {
|
||||
java.awt.Desktop.getDesktop().browse(new URI(url));
|
||||
} catch (URISyntaxException | IOException e) {
|
||||
HMCLog.err("Failed to browse uri: " + url, e);
|
||||
Utils.setClipborad(url);
|
||||
Utils.setClipboard(url);
|
||||
MessageBox.show(C.i18n("update.no_browser"));
|
||||
}
|
||||
}
|
||||
|
||||
+4
-1
@@ -15,7 +15,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see {http://www.gnu.org/licenses/}.
|
||||
*/
|
||||
package org.jackhuang.hmcl.util;
|
||||
package org.jackhuang.hmcl.util.upgrade;
|
||||
|
||||
import org.jackhuang.hmcl.util.ui.MessageBox;
|
||||
import org.jackhuang.hmcl.api.VersionNumber;
|
||||
@@ -28,6 +28,9 @@ import java.util.Map;
|
||||
import org.jackhuang.hmcl.api.HMCLApi;
|
||||
import org.jackhuang.hmcl.api.event.SimpleEvent;
|
||||
import org.jackhuang.hmcl.api.event.OutOfDateEvent;
|
||||
import org.jackhuang.hmcl.util.AbstractSwingWorker;
|
||||
import org.jackhuang.hmcl.util.C;
|
||||
import org.jackhuang.hmcl.util.IUpdateChecker;
|
||||
|
||||
/**
|
||||
*
|
||||
+1
-1
@@ -57,7 +57,7 @@ public class MinecraftDownloadService extends IMinecraftDownloadService {
|
||||
for (IMinecraftLibrary l : v.getLibraries())
|
||||
if (l != null && l.allow()) {
|
||||
File ff = service.version().getLibraryFile(mv, l);
|
||||
if (!ff.exists() && l.getDownloadURL(service.getDownloadType().name()) != null) {
|
||||
if (ff != null && !ff.exists() && l.getDownloadURL(service.getDownloadType().name()) != null) {
|
||||
String libURL = l.getDownloadURL(service.getDownloadType().name());
|
||||
if (libURL != null)
|
||||
downloadLibraries.add(new DownloadLibraryJob(l, libURL, ff));
|
||||
|
||||
@@ -115,12 +115,14 @@ public class MinecraftLoader extends AbstractMinecraftLoader {
|
||||
|
||||
list.add("-Dminecraft.client.jar=" + version.getJar(service.baseDirectory()).getAbsolutePath());
|
||||
|
||||
/*
|
||||
if (version.logging != null && version.logging.containsKey("client")) {
|
||||
LoggingInfo logging = version.logging.get("client");
|
||||
File file = service.asset().getLoggingObject(version.getAssetsIndex().getId(), logging);
|
||||
if (file.exists())
|
||||
list.add(logging.argument.replace("${path}", file.getAbsolutePath()));
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
private final IAssetProvider DEFAULT_ASSET_PROVIDER = (t, allow) -> {
|
||||
|
||||
+5
-1
@@ -41,7 +41,11 @@ public abstract class AbstractMinecraftLibrary implements IMinecraftLibrary {
|
||||
|
||||
@Override
|
||||
public String getDownloadURL(String downloadSource) {
|
||||
return getDownloadInfo().getUrl(DownloadType.valueOf(downloadSource));
|
||||
LibraryDownloadInfo info = getDownloadInfo();
|
||||
if (info == null)
|
||||
return null;
|
||||
else
|
||||
return info.getUrl(DownloadType.valueOf(downloadSource));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -123,6 +123,8 @@ public class MinecraftLibrary extends AbstractMinecraftLibrary {
|
||||
if (natives != null) {
|
||||
if (downloads.classifiers == null)
|
||||
downloads.classifiers = new HashMap<>();
|
||||
if (StrUtils.isBlank(getNative()))
|
||||
return null;
|
||||
if (!downloads.classifiers.containsKey(getNative()))
|
||||
downloads.classifiers.put(getNative(), info = new LibraryDownloadInfo());
|
||||
else info = downloads.classifiers.get(getNative());
|
||||
|
||||
@@ -247,11 +247,13 @@ public class MinecraftVersionManager<T extends IMinecraftService> extends IMinec
|
||||
throw new GameException("Wrong format: minecraft.json");
|
||||
ArrayList<File> unzippings = new ArrayList<>();
|
||||
ArrayList<Extract> extractRules = new ArrayList<>();
|
||||
for (IMinecraftLibrary l : v.libraries)
|
||||
if (l.isNative() && v.isAllowedToUnpackNatives()) {
|
||||
unzippings.add(getLibraryFile(v, l));
|
||||
for (IMinecraftLibrary l : v.libraries) {
|
||||
final File f = getLibraryFile(v, l);
|
||||
if (l.isNative() && v.isAllowedToUnpackNatives() && l.allow() && f != null) {
|
||||
unzippings.add(f);
|
||||
extractRules.add(l.getDecompressExtractRules());
|
||||
}
|
||||
}
|
||||
return new DecompressLibraryJob(unzippings.toArray(new File[unzippings.size()]), extractRules.toArray(new Extract[extractRules.size()]), getDecompressNativesToLocation(v));
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ public final class Utils {
|
||||
return ((URLClassLoader) Utils.class.getClassLoader()).getURLs();
|
||||
}
|
||||
|
||||
public static void setClipborad(String text) {
|
||||
public static void setClipboard(String text) {
|
||||
try {
|
||||
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(text), null);
|
||||
} catch(HeadlessException ignored) {
|
||||
|
||||
@@ -20,6 +20,7 @@ package org.jackhuang.hmcl.util.log;
|
||||
import java.awt.Color;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import org.jackhuang.hmcl.util.ui.GraphicsUtils;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -27,12 +28,12 @@ import java.util.regex.Pattern;
|
||||
*/
|
||||
public enum Level {
|
||||
|
||||
FATAL(1, Color.red),
|
||||
ERROR(2, Color.red),
|
||||
WARN(3, Color.orange),
|
||||
FATAL(1, GraphicsUtils.getWebColor("#C0392B")),
|
||||
ERROR(2, GraphicsUtils.getWebColor("#D35400")),
|
||||
WARN(3, GraphicsUtils.getWebColor("#F39C12")),
|
||||
INFO(4, Color.black),
|
||||
DEBUG(5, Color.blue),
|
||||
TRACE(6, Color.blue),
|
||||
DEBUG(5, GraphicsUtils.getWebColor("#2980B9")),
|
||||
TRACE(6, GraphicsUtils.getWebColor("#16A085")),
|
||||
ALL(2147483647, Color.black);
|
||||
|
||||
public final int level;
|
||||
|
||||
@@ -31,14 +31,14 @@ public enum OS {
|
||||
LINUX('/', "linux"),
|
||||
WINDOWS('\\', "windows"),
|
||||
OSX('/', "osx"),
|
||||
UNKOWN('/', "universal");
|
||||
UNKNOWN('/', "universal");
|
||||
|
||||
public final char fileSeparator;
|
||||
public final String checked_name;
|
||||
public final String checkedName;
|
||||
|
||||
private OS(char fileSeparator, String n) {
|
||||
this.fileSeparator = fileSeparator;
|
||||
checked_name = n;
|
||||
checkedName = n;
|
||||
}
|
||||
|
||||
public static OS os() {
|
||||
@@ -55,7 +55,7 @@ public enum OS {
|
||||
return OS.LINUX;
|
||||
if (str.contains("unix"))
|
||||
return OS.LINUX;
|
||||
return OS.UNKOWN;
|
||||
return OS.UNKNOWN;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -89,7 +89,7 @@ public class ProcessMonitor {
|
||||
try {
|
||||
exitCode = p.getExitCode();
|
||||
} catch(IllegalThreadStateException e) {
|
||||
HMCLog.err("Failed to ");
|
||||
HMCLog.err("Failed to get exit code ", e);
|
||||
}
|
||||
if (p.getExitCode() != 0 || StrUtils.containsOne(t.getLines(),
|
||||
Arrays.asList("Unable to launch"), // LaunchWrapper will terminate the application returning exit code 0, but this is an error state.
|
||||
|
||||
@@ -71,11 +71,20 @@ public class ProcessThread extends Thread {
|
||||
br = new BufferedReader(new InputStreamReader(in, Charsets.toCharset()));
|
||||
|
||||
String line;
|
||||
while (p.isRunning())
|
||||
while ((line = br.readLine()) != null)
|
||||
while (p.isRunning()) {
|
||||
if (isInterrupted())
|
||||
return;
|
||||
while ((line = br.readLine()) != null) {
|
||||
if (isInterrupted())
|
||||
return;
|
||||
println(line);
|
||||
while ((line = br.readLine()) != null)
|
||||
}
|
||||
}
|
||||
while ((line = br.readLine()) != null) {
|
||||
if (isInterrupted())
|
||||
return;
|
||||
println(line);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
HMCLog.err("An error occured when reading process stdout/stderr.", e);
|
||||
} finally {
|
||||
|
||||
@@ -79,10 +79,9 @@ public class ZipEngine implements Closeable {
|
||||
File[] files;
|
||||
if (source.isDirectory())
|
||||
files = source.listFiles();
|
||||
else {
|
||||
files = new File[1];
|
||||
files[0] = source;
|
||||
}
|
||||
else
|
||||
files = new File[] { source };
|
||||
|
||||
if (files == null)
|
||||
return;
|
||||
String pathName;//存相对路径(相对于待压缩的根目录)
|
||||
|
||||
+1
-1
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https://services.gradle.org/distributions/gradle-3.3-bin.zip
|
||||
distributionUrl=https://services.gradle.org/distributions/gradle-4.2.1-bin.zip
|
||||
Reference in new issue
Block a user