Compare commits

...
56 Commits
Author SHA1 Message Date
huanghongxun 678be4b92f feat(multiplayer): upgrade cato to 1.2.0 2021-12-18 17:15:18 +08:00
Glavo 74d759a45b Update I18N text 2021-12-18 17:08:16 +08:00
huanghongxun 295499c17b fix: missing translations. 2021-12-18 16:55:33 +08:00
Glavo 043d1c88c8 Fix #1096: Feedback item cannot be clicked 2021-12-18 16:49:42 +08:00
bling-yshs 55e9b93b1c fix curse category 2021-12-18 16:49:23 +08:00
Glavo aa5e3e9697 Fix #1148: Specify console encoding explicitly 2021-12-18 15:59:24 +08:00
Glavo fbf7ff6ebd Lifting GB2312 to GB18030 2021-12-18 15:59:24 +08:00
Glavo 3a5e8a827c update README 2021-12-18 15:59:24 +08:00
Glavo 6176dfaaf7 Lifting encoding to be compatible with more Unicode characters 2021-12-18 15:59:24 +08:00
Glavo 76c361e9bc Fix #1201: Download version jar if the jar is empty 2021-12-18 15:58:33 +08:00
Glavo ccb8981634 Remove invalid Appender 2021-12-18 15:47:41 +08:00
Glavo 99b55d03c1 Allows user to enable message lookup 2021-12-18 15:47:41 +08:00
Glavo 651fa6e2d1 fix #663: Incorrect judgment of WebView loading status 2021-12-18 15:46:24 +08:00
Glavo 4b258da0a0 Fix code format 2021-12-18 15:45:35 +08:00
Glavo 9a66605616 Disable JndiLookup using log4j-patch 2021-12-18 15:45:35 +08:00
Glavo da13895b72 fix: InputStream not closed 2021-12-18 15:45:35 +08:00
Glavo c657a1d2cc Introducing log4j-patch 2021-12-18 15:45:35 +08:00
Glavo eac8896f3e fix NPE in MultiplayerManager 2021-12-18 15:39:57 +08:00
Gamom 113f4f948b Update I18N_zh_CN.properties
翻译问题
解决 https://github.com/huanghongxun/HMCL/issues/1203#issuecomment-997155654
2021-12-18 15:39:26 +08:00
huanghongxun 1b8dc1f75e fix(mcbbs): NPE when fileApi is not empty. Closes #1197. 2021-12-18 01:40:25 +08:00
huanghongxun 001236e8e6 feat(download): refresh button 2021-12-18 01:40:25 +08:00
Glavo 8025b8e24b Support offline installation of OptiFine 1.17.1 H1 and later 2021-12-18 01:26:03 +08:00
Glavo e48bf012a6 Safely save config 2021-12-18 01:21:45 +08:00
Glavo 94e32694b2 fix: Game should use global settings by default 2021-12-12 16:51:01 +08:00
Glavo cbcf033b15 Delete unnecessary properties 2021-12-11 23:52:03 +08:00
Glavo 7da2671ec5 Use custom log4j2.xml 2021-12-11 23:52:03 +08:00
Glavo b6ea4c7003 Fix the problem that you cannot continue after canceling the prompt 2021-12-11 23:52:03 +08:00
Glavo 49378061bf Always issue security warning 2021-12-11 23:52:03 +08:00
Glavo 38013a9298 Issue security warning for CVE-2021-44228 2021-12-11 23:52:03 +08:00
Glavo 5ffbd16800 Prohibit JNDI remote invoke 2021-12-11 23:52:03 +08:00
Glavo bcb29ef792 Update GitHub workflow configuration 2021-12-11 23:50:37 +08:00
Glavo d20adb20d3 fix: Logs should be encoded in UTF-8 2021-12-11 23:49:29 +08:00
Kylepoops 4f28cdd58f Fix CVE-2021-44228 again
https://github.com/apache/logging-log4j2/pull/614
2021-12-11 23:49:09 +08:00
huanghongxun 4b6b5c2f0e fix(game): fix remote code execution from log4j. 2021-12-10 14:22:16 +08:00
Glavo c31269a358 Disable message pattern lookup by default 2021-12-10 14:19:32 +08:00
Glavo 55092326a4 Use StringWriter instead of ByteArrayOutputStream 2021-12-10 14:18:08 +08:00
Glavo 10dbcf63b7 Adjust the default capability to reduce memory allocation 2021-12-10 14:18:08 +08:00
Glavo 32fad77104 Optimize logging performance 2021-12-10 14:18:08 +08:00
SettingDust 05d2fbbbb9 fix(core): zipper lose the file attributes 2021-12-10 14:17:03 +08:00
ttsdzb 916733a1e8 根据最近的变化对README下载部分稍作修改 2021-12-10 14:16:50 +08:00
huanghongxun 83b4b58cb2 feat(crash): 1.18 requires Java 17. Closes #1186. 2021-11-22 01:54:05 +08:00
huanghongxun 11f53c0e03 feat(crash): show link for jdk downloading. Closes #1186. 2021-11-22 01:15:15 +08:00
huanghongxun 2fa8aee055 fix(multiplayer): incorrect cato checksum. 2021-11-20 18:42:25 +08:00
huanghongxun d2848e12f3 fix: not reloading VersionPage when renaming the game version. Closes #1176. 2021-11-20 18:24:00 +08:00
huanghongxun 36ba840fe8 fix: should close version settings page when deleting related version. Closes #1175. 2021-11-20 18:19:39 +08:00
asdqp233 819d41a75c Update I18N.properties 2021-11-20 01:57:39 +08:00
huanghongxun 3a6c3dc51d fix(multiplayer): update cato. 2021-11-11 22:00:46 +08:00
huanghongxun db721107ae fix(microsoft): remove redundant login steps. 2021-11-09 00:35:52 +08:00
huanghongxun 5b9be471e3 fix(microsoft): should not pass client secret when refreshing token. Closes #1164. 2021-11-06 22:32:08 +08:00
huanghongxun e8f8617412 fix: crash when all profiles removed. Close #1165. 2021-11-06 22:32:07 +08:00
Glavo eb472037db fix: checkstyle 2021-11-03 17:30:27 +08:00
Glavo 81b7afd08d Update issue template 2021-11-02 22:46:41 +08:00
Glavo 7a71ecf177 Fix #1153: On Windows, the 'classpath' environment variable in the context overrides the 'CLASSPATH' 2021-11-02 22:46:13 +08:00
huanghongxun a12e485a27 chore(multiplayer): adjust some translations. 2021-10-31 18:42:27 +08:00
huanghongxun af521b2893 chore: localize SSLHandshakeException. 2021-10-31 18:42:27 +08:00
Glavo aab6f68492 Fix #1147: shadowJar minimize exclude JFoenix 2021-10-31 17:04:11 +08:00
63 changed files with 819 additions and 285 deletions

No files matched your search

-29
View File
@@ -1,29 +0,0 @@
# 公告
提交前请确保你的启动器版本是**最新的开发版**,可以在启动器设置中更换更新通道至开发版获取更新。
**如果你在阅读完本公告后仍然希望在此处发布 issue,请将公告内容删去,并按照下面的模板填入相关信息。**
我们发现,对于不经常检查邮箱的人来说,GitHub Issues 的反馈效率太低,时隔几个小时甚至一天的情况很多。
为了改善反馈效率,并将积极为 HMCL 提供问题反馈和建议的人聚集起来,我们希望在这里反馈的人可以在 [Discord频道](https://discord.gg/jVvC7HfM6U) [开黑啦频道](https://kaihei.co/Kx7n3t) 中反馈信息,**而不在 GitHub Issues 中反馈问题**。
如果你希望在 QQ 群中反馈问题,请[赞助 HMCL](https://afdian.net/@huanghongxun) 后申请加入群聊,也请将下面的信息表填好直接发在群中,加快我们的沟通速度。
# 问题提交
*完整地填下面的问题提交表对我们很重要,这可以加快我们分析问题原因的速度。*
* 启动器版本:
* 操作系统:
* Java 版本:
* 错误截图(最好请将整个电脑屏幕的截图发上来):
* 游戏版本(如果是启动通过启动器自带的自动安装功能安装的游戏):
* 对游戏做的修改(是否自行通过安装器安装 Rift 等 API,以及 mod):
* 游戏崩溃报告(如果有):
* 启动器崩溃报告(如果有):
* 启动器日志文件(出现问题后点击启动器设置中的【导出启动器日志】按钮):
* 问题描述(如何触发问题):
+68
View File
@@ -0,0 +1,68 @@
name: Bug 反馈
description: 反馈一个 Bug。为了提高反馈效率,请优先在开黑啦或者或 Discord 频道中反馈。
body:
- type: markdown
attributes:
value: |
提交前请确保你的启动器版本是**最新的开发版**,可以在启动器设置中更换更新通道至开发版获取更新。
我们发现,对于不经常检查邮箱的人来说,GitHub Issues 的反馈效率太低,时隔几个小时甚至一天的情况很多。
为了改善反馈效率,并将积极为 HMCL 提供问题反馈和建议的人聚集起来,我们希望在这里反馈的人可以在 [开黑啦频道](https://kaihei.co/Kx7n3t)
或 [Discord 频道](https://discord.gg/jVvC7HfM6U)中反馈信息,**而不在 GitHub Issues 中反馈问题**。
如果你希望在 QQ 群中反馈问题,请[赞助 HMCL](https://afdian.net/@huanghongxun) 后申请加入群聊,也请将下面的信息表填好直接发在群中,加快我们的沟通速度。
- type: input
id: hmcl-version
attributes:
label: 启动器版本
description: 请输入您所使用的的 HMCL 启动器版本。
placeholder: 例如:3.3.188
validations:
required: true
- type: input
id: platform
attributes:
label: 平台
description: 请输入您遇到 BUG 的平台。
placeholder: 例如:Windows 11
validations:
required: true
- type: input
id: java-version
attributes:
label: Java
description: 请输入您所使用的 Java 的名称与版本。
placeholder: 例如:LibericaJDK Full JDK 17.0.1
- type: input
id: game-version
attributes:
label: 游戏版本
description: 如果您是在启动通过 HMCL 启动器自动下载的游戏时遇到了问题,请输入您所启动的游戏版本。
placeholder: 例如:1.17.1
- type: input
id: game-modify
attributes:
label: 对游戏所做的修改
description: 如果您为游戏安装了 OptiFine、Forge,或者是其他的 mod,请将您所做的修改填入下方。
placeholder: 例如:OptiFine HD_U_G9, Rift
- type: textarea
id: game-crash-report
attributes:
label: 游戏崩溃报告
description: 如果有游戏崩溃报告的话,请填入(或将文件拖入)下方。
- type: textarea
id: hmcl-crash-report
attributes:
label: 启动器崩溃报告
description: 如果有启动器崩溃报告的话,请填入(或将文件拖入)下方。
- type: textarea
id: hmcl-logs
attributes:
label: 启动器日志文件
description: 遇到问题后,请在启动器的【设置】>【通用】>【调试】一栏中点击“导出启动器日志”,并将导出的日志拖到下方的输入栏中。
- type: textarea
id: bug-report
attributes:
label: 问题描述
description: 请尽可能地详细描述问题,特别是您是怎么遇到这个 BUG 的。
+14
View File
@@ -0,0 +1,14 @@
blank_issues_enabled: true
contact_links:
- name: 开黑啦频道
url: https://kaihei.co/Kx7n3t
about: Hello Minecraft! Launcher 的官方开黑啦频道。
- name: Discord 频道
url: https://discord.gg/jVvC7HfM6U
about: Hello Minecraft! Launcher 的官方 Discord 频道。
- name: 赞助通道
url: https://afdian.net/@huanghongxun
about: 前往爱发电赞助 HMCL。赞助后可以申请加入官方 QQ 群反馈问题。
- name: 其他反馈
url: https://github.com/huanghongxun/HMCL/issues/new
about: 通过 Issue 反馈其他问题。
+9 -8
View File
@@ -1,16 +1,14 @@
name: Check Update
on:
push:
branches:
- javafx
workflow_dispatch:
schedule:
- cron: '30 * * * *'
jobs:
check-update:
if: ${{ github.repository_owner == 'huanghongxun' }}
runs-on: ubuntu-latest
env:
HMCL_BASE_VERSION: '3.4'
steps:
- uses: actions/checkout@v2
- name: Fetch tags
@@ -20,7 +18,11 @@ jobs:
- name: Fetch last version
run: |
wget -O ci.json https://ci.huangyuhui.net/job/HMCL/lastSuccessfulBuild/api/json
export HMCL_EXE_FILE_NAME=`cat ci.json | jq -M -r '.artifacts[] | select(.fileName | endswith(".exe")) | .fileName'`
if [ -z `echo $HMCL_EXE_FILE_NAME | grep "^HMCL-[0-9]\.[0-9]\.[0-9]\{3\}\.exe\$"` ]; then exit 1; fi
export HMCL_BASE_VERSION=${HMCL_EXE_FILE_NAME:5:3}
export HMCL_BUILD_NUMBER=`cat ci.json | jq -M -r '.id'`
export HMCL_VERSION="$HMCL_BASE_VERSION.$HMCL_BUILD_NUMBER"
export HMCL_COMMIT_SHA=`cat ci.json | jq -M -r '.actions[] | select(._class == "hudson.plugins.git.util.BuildData") | .lastBuiltRevision.SHA1'`
@@ -28,6 +30,7 @@ jobs:
if [ "${#HMCL_BUILD_NUMBER}" != 3 ]; then exit 1; fi
if [ "${#HMCL_COMMIT_SHA}" != 40 ]; then exit 1; fi
echo "HMCL_BASE_VERSION=$HMCL_BASE_VERSION" >> $GITHUB_ENV
echo "HMCL_BUILD_NUMBER=$HMCL_BUILD_NUMBER" >> $GITHUB_ENV
echo "HMCL_VERSION=$HMCL_VERSION" >> $GITHUB_ENV
echo "HMCL_COMMIT_SHA=$HMCL_COMMIT_SHA" >> $GITHUB_ENV
@@ -63,5 +66,3 @@ jobs:
target_commitish: ${{ env.HMCL_COMMIT_SHA }}
name: ${{ env.HMCL_TAG_NAME }}
tag_name: ${{ env.HMCL_TAG_NAME }}
-44
View File
@@ -1,44 +0,0 @@
name: Create Release
on:
push:
tags:
- "v*.*.*"
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Check and set HMCL version
run: |
export HMCL_VERSION=`echo ${{ github.ref }} | awk '{print substr($0,12)}'`
echo "HMCL_VERSION=$HMCL_VERSION" >> $GITHUB_ENV
if [ -z `echo $HMCL_VERSION | grep "^[0-9]\.[0-9]\.[0-9]\{3\}\$"` ]; then
exit 1
fi
echo "HMCL_BUILD_NUMBER=`echo $HMCL_VERSION | awk '{print substr($0,5)}'`" >> $GITHUB_ENV
- name: Download artifacts
run: |
wget "$DOWNLOAD_BASE_URL/HMCL-$HMCL_VERSION.exe"
wget "$DOWNLOAD_BASE_URL/HMCL-$HMCL_VERSION.exe.sha1"
wget "$DOWNLOAD_BASE_URL/HMCL-$HMCL_VERSION.jar"
wget "$DOWNLOAD_BASE_URL/HMCL-$HMCL_VERSION.jar.sha1"
env:
DOWNLOAD_BASE_URL: https://ci.huangyuhui.net/job/HMCL/${{ env.HMCL_BUILD_NUMBER }}/artifact/HMCL/build/libs
- name: Generate release note
run: |
echo "HMCL v$HMCL_VERSION" >> RELEASE_NOTE
echo "" >> RELEASE_NOTE
echo "The full changelogs can be found on the website: https://hmcl.huangyuhui.net/changelog/dev.html" >> RELEASE_NOTE
echo "Notice: changelogs are written in Chinese." >> RELEASE_NOTE
- name: Create release
uses: softprops/action-gh-release@v1
with:
body_path: RELEASE_NOTE
files: |
HMCL-${{ env.HMCL_VERSION }}.exe
HMCL-${{ env.HMCL_VERSION }}.exe.sha1
HMCL-${{ env.HMCL_VERSION }}.jar
HMCL-${{ env.HMCL_VERSION }}.jar.sha1
+6 -3
View File
@@ -17,20 +17,23 @@ NVIDIA
/build/
/HMCL/build/
/HMCLCore/build/
/HMCLTransformerDiscoveryService/build/
/minecraft/libraries/HMCLTransformerDiscoveryService/build/
/minecraft/libraries/log4j-patch/build/
# idea
.idea
/out/
/HMCL/out/
/HMCLCore/out/
/HMCLTransformerDiscoveryService/out/
/minecraft/libraries/HMCLTransformerDiscoveryService/out/
/minecraft/libraries/log4j-patch/out/
# eclipse
/bin/
/HMCL/bin/
/HMCLCore/bin/
/HMCLTransformerDiscoveryService/bin/
/minecraft/libraries/HMCLTransformerDiscoveryService/bin/
/minecraft/libraries/log4j-patch/bin/
.classpath
.project
.settings
+2 -2
View File
@@ -45,7 +45,7 @@ mainClassName = 'org.jackhuang.hmcl.Main'
dependencies {
implementation project(":HMCLCore")
implementation rootProject.files("lib/JFoenix.jar")
implementation 'libs:JFoenix'
implementation group: 'de.javawi.jstun', name: 'jstun', version: '0.7.4'
}
@@ -128,7 +128,7 @@ shadowJar {
minimize {
exclude(dependency('com.google.code.gson:.*:.*'))
exclude(dependency('com.github.steveice10:.*:.*'))
exclude(project(":HMCLTransformerDiscoveryService"))
exclude(dependency('libs:JFoenix:.*'))
}
manifest {
@@ -1,7 +1,6 @@
package org.jackhuang.hmcl.countly;
import org.jackhuang.hmcl.Metadata;
import org.jackhuang.hmcl.util.CrashReporter;
import org.jackhuang.hmcl.util.Logging;
import org.jackhuang.hmcl.util.StringUtils;
import org.jackhuang.hmcl.util.platform.Architecture;
@@ -425,6 +425,11 @@ public final class LauncherHelper {
FXUtils.openLink("https://adoptium.net/?variant=openjdk17");
}, breakAction);
return null;
case VANILLA_JAVA_17:
Controllers.confirm(i18n("launch.advice.require_newer_java_version", gameVersion.toString(), 17), i18n("message.warning"), () -> {
FXUtils.openLink("https://adoptium.net/?variant=openjdk17");
}, breakAction);
return null;
case VANILLA_JAVA_8:
Controllers.dialog(i18n("launch.advice.java8_1_13"), i18n("message.error"), MessageType.ERROR, breakAction);
return null;
@@ -489,7 +494,7 @@ public final class LauncherHelper {
// Cannot allocate too much memory exceeding free space.
if (!suggested && OperatingSystem.TOTAL_MEMORY > 0 && OperatingSystem.TOTAL_MEMORY < setting.getMaxMemory()) {
Controllers.confirm(i18n("launch.advice.not_enough_space", OperatingSystem.TOTAL_MEMORY), i18n("message.error"), continueAction, null);
Controllers.confirm(i18n("launch.advice.not_enough_space", OperatingSystem.TOTAL_MEMORY), i18n("message.error"), continueAction, breakAction);
suggested = true;
}
@@ -501,7 +506,7 @@ public final class LauncherHelper {
VersionNumber.VERSION_COMPARATOR.compare(it.getVersion(), "1.12.2-14.23.5.2773") < 0);
boolean hasLiteLoader = version.getLibraries().stream().anyMatch(it -> it.is("com.mumfrey", "liteloader"));
if (hasForge2760 && hasLiteLoader && gameVersion.compareTo(VersionNumber.asVersion("1.12.2")) == 0) {
Controllers.confirm(i18n("launch.advice.forge2760_liteloader"), i18n("message.error"), continueAction, null);
Controllers.confirm(i18n("launch.advice.forge2760_liteloader"), i18n("message.error"), continueAction, breakAction);
suggested = true;
}
}
@@ -513,12 +518,12 @@ public final class LauncherHelper {
VersionNumber.VERSION_COMPARATOR.compare("1.14.4-28.2.2", it.getVersion()) <= 0);
boolean hasOptiFine = version.getLibraries().stream().anyMatch(it -> it.is("optifine", "OptiFine"));
if (hasForge28_2_2 && hasOptiFine && gameVersion.compareTo(VersionNumber.asVersion("1.14.4")) == 0) {
Controllers.confirm(i18n("launch.advice.forge28_2_2_optifine"), i18n("message.error"), continueAction, null);
Controllers.confirm(i18n("launch.advice.forge28_2_2_optifine"), i18n("message.error"), continueAction, breakAction);
suggested = true;
}
}
if (!suggested) {
if (!future.isDone()) {
future.complete(javaVersion);
}
@@ -169,6 +169,10 @@ public final class OAuthServer extends NanoHTTPD implements OAuth.Session {
JarUtils.thisJar().flatMap(JarUtils::getManifest).map(manifest -> manifest.getMainAttributes().getValue("Microsoft-Auth-Secret")).orElse(""));
}
@Override
public boolean isPublicClient() {
return true; // We have turned on the device auth flow.
}
}
public static class GrantDeviceCodeEvent extends Event {
@@ -30,7 +30,6 @@ import java.nio.file.*;
import java.util.Map;
import java.util.logging.Level;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.jackhuang.hmcl.util.Logging.LOG;
public final class ConfigHolder {
@@ -175,7 +174,7 @@ public final class ConfigHolder {
private static void writeToConfig(String content) throws IOException {
LOG.info("Saving config");
synchronized (configLocation) {
Files.write(configLocation, content.getBytes(UTF_8));
FileUtils.saveSafely(configLocation, content);
}
}
@@ -219,7 +218,7 @@ public final class ConfigHolder {
private static void writeToGlobalConfig(String content) throws IOException {
LOG.info("Saving global config");
synchronized (GLOBAL_CONFIG_PATH) {
Files.write(GLOBAL_CONFIG_PATH, content.getBytes(UTF_8));
FileUtils.saveSafely(GLOBAL_CONFIG_PATH, content);
}
}
@@ -26,6 +26,7 @@ import org.jackhuang.hmcl.util.StringUtils;
import org.jackhuang.hmcl.util.i18n.I18n;
import org.jackhuang.hmcl.util.io.ResponseCodeException;
import javax.net.ssl.SSLHandshakeException;
import java.io.FileNotFoundException;
import java.net.SocketTimeoutException;
import java.net.URL;
@@ -156,6 +157,8 @@ public final class DownloadProviders {
return i18n("install.failed.downloading.detail", url) + "\n" + i18n("exception.access_denied", ((AccessDeniedException) exception.getCause()).getFile());
} else if (exception.getCause() instanceof ArtifactMalformedException) {
return i18n("install.failed.downloading.detail", url) + "\n" + i18n("exception.artifact_malformed");
} else if (exception.getCause() instanceof SSLHandshakeException) {
return i18n("install.failed.downloading.detail", url) + "\n" + i18n("exception.ssl_handshake");
} else {
return i18n("install.failed.downloading.detail", url) + "\n" + StringUtils.getStackTrace(exception.getCause());
}
@@ -60,7 +60,7 @@ public final class VersionSetting implements Cloneable {
this.global = global;
}
private final BooleanProperty usesGlobalProperty = new SimpleBooleanProperty(this, "usesGlobal", false);
private final BooleanProperty usesGlobalProperty = new SimpleBooleanProperty(this, "usesGlobal", true);
public BooleanProperty usesGlobalProperty() {
return usesGlobalProperty;
@@ -24,12 +24,15 @@ import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.Label;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;
import javafx.scene.layout.VBox;
import javafx.scene.text.Text;
import javafx.scene.text.TextFlow;
import javafx.stage.Stage;
import org.jackhuang.hmcl.download.LibraryAnalyzer;
import org.jackhuang.hmcl.game.*;
@@ -71,7 +74,7 @@ public class GameCrashWindow extends Stage {
private final LibraryAnalyzer analyzer;
private final StringProperty os = new SimpleStringProperty(OperatingSystem.SYSTEM_NAME);
private final StringProperty arch = new SimpleStringProperty(Architecture.SYSTEM_ARCH.getDisplayName());
private final StringProperty reason = new SimpleStringProperty(i18n("game.crash.reason.unknown"));
private final TextFlow reasonTextFlow = new TextFlow(new Text(i18n("game.crash.reason.unknown")));
private final BooleanProperty loading = new SimpleBooleanProperty();
private final Label feedbackLabel = new Label(i18n("game.crash.feedback"));
@@ -133,52 +136,53 @@ public class GameCrashWindow extends Stage {
if (exception != null) {
LOG.log(Level.WARNING, "Failed to analyze crash report", exception);
reason.set(i18n("game.crash.reason.unknown"));
reasonTextFlow.getChildren().setAll(new Text(i18n("game.crash.reason.unknown")));
} else {
List<CrashReportAnalyzer.Result> results = pair.getKey();
Set<String> keywords = pair.getValue();
StringBuilder reasonText = new StringBuilder();
List<Node> segments = new ArrayList<>();
for (CrashReportAnalyzer.Result result : results) {
switch (result.getRule()) {
case TOO_OLD_JAVA:
reasonText.append(i18n("game.crash.reason.too_old_java",
CrashReportAnalyzer.getJavaVersionFromMajorVersion(Integer.parseInt(result.getMatcher().group("expected")))))
.append("\n");
segments.addAll(FXUtils.parseSegment(i18n("game.crash.reason.too_old_java",
CrashReportAnalyzer.getJavaVersionFromMajorVersion(Integer.parseInt(result.getMatcher().group("expected")))), Controllers::onHyperlinkAction));
break;
case MOD_RESOLUTION_CONFLICT:
case MOD_RESOLUTION_MISSING:
case MOD_RESOLUTION_COLLECTION:
reasonText.append(i18n("game.crash.reason." + result.getRule().name().toLowerCase(Locale.ROOT),
segments.addAll(FXUtils.parseSegment(i18n("game.crash.reason." + result.getRule().name().toLowerCase(Locale.ROOT),
translateFabricModId(result.getMatcher().group("sourcemod")),
parseFabricModId(result.getMatcher().group("destmod")),
parseFabricModId(result.getMatcher().group("destmod"))));
parseFabricModId(result.getMatcher().group("destmod"))), Controllers::onHyperlinkAction));
break;
case MOD_RESOLUTION_MISSING_MINECRAFT:
reasonText.append(i18n("game.crash.reason." + result.getRule().name().toLowerCase(Locale.ROOT),
segments.addAll(FXUtils.parseSegment(i18n("game.crash.reason." + result.getRule().name().toLowerCase(Locale.ROOT),
translateFabricModId(result.getMatcher().group("mod")),
result.getMatcher().group("version")));
result.getMatcher().group("version")), Controllers::onHyperlinkAction));
break;
case TWILIGHT_FOREST_OPTIFINE:
reasonText.append(i18n("game.crash.reason.mod", "OptiFine"));
segments.addAll(FXUtils.parseSegment(i18n("game.crash.reason.mod", "OptiFine"), Controllers::onHyperlinkAction));
break;
default:
reasonText.append(i18n("game.crash.reason." + result.getRule().name().toLowerCase(Locale.ROOT),
segments.addAll(FXUtils.parseSegment(i18n("game.crash.reason." + result.getRule().name().toLowerCase(Locale.ROOT),
Arrays.stream(result.getRule().getGroupNames()).map(groupName -> result.getMatcher().group(groupName))
.toArray()))
.append("\n");
.toArray()), Controllers::onHyperlinkAction));
break;
}
segments.add(new Text("\n"));
}
if (results.isEmpty()) {
if (!keywords.isEmpty()) {
reason.set(i18n("game.crash.reason.stacktrace", String.join(", ", keywords)));
reasonTextFlow.getChildren().setAll(new Text(i18n("game.crash.reason.stacktrace", String.join(", ", keywords))));
} else {
reason.set(i18n("game.crash.reason.unknown"));
reasonTextFlow.getChildren().setAll(new Text(i18n("game.crash.reason.unknown")));
}
feedbackLabel.setVisible(true);
} else {
reason.set(reasonText.toString());
feedbackLabel.setVisible(false);
reasonTextFlow.getChildren().setAll(segments);
}
}
}, Schedulers.javafx()).exceptionally(Lang::handleUncaughtException);
@@ -333,14 +337,12 @@ public class GameCrashWindow extends Stage {
javaDir.setTitle(i18n("settings.game.java_directory"));
javaDir.setSubtitle(launchOptions.getJava().getBinary().toAbsolutePath().toString());
TwoLineListItem reason = new TwoLineListItem();
reason.getStyleClass().setAll("two-line-item-second-large", "wrap-text");
reason.setTitle(i18n("game.crash.reason"));
reason.subtitleProperty().bind(GameCrashWindow.this.reason);
Label reasonTitle = new Label(i18n("game.crash.reason"));
reasonTitle.getStyleClass().add("two-line-item-second-large-title");
gameDirPane.setPadding(new Insets(8));
VBox.setVgrow(gameDirPane, Priority.ALWAYS);
gameDirPane.getChildren().setAll(gameDir, javaDir, reason);
gameDirPane.getChildren().setAll(gameDir, javaDir, new VBox(reasonTitle, reasonTextFlow));
}
HBox toolBar = new HBox();
@@ -19,6 +19,7 @@ package org.jackhuang.hmcl.ui;
import com.jfoenix.controls.JFXButton;
import com.jfoenix.controls.JFXDialogLayout;
import javafx.concurrent.Worker;
import javafx.scene.control.Label;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
@@ -41,23 +42,23 @@ public class UpgradeDialog extends JFXDialogLayout {
{
String url = CHANGELOG_URL + remoteVersion.getChannel().channelName + ".html";
WebView webView = new WebView();
webView.getEngine().setUserDataDirectory(Metadata.HMCL_DIRECTORY.toFile());
try {
WebView webView = new WebView();
webView.getEngine().setUserDataDirectory(Metadata.HMCL_DIRECTORY.toFile());
WebEngine engine = webView.getEngine();
engine.load(CHANGELOG_URL + remoteVersion.getChannel().channelName);
engine.load(url);
engine.getLoadWorker().stateProperty().addListener((observable, oldValue, newValue) -> {
String viewURL = engine.getLoadWorker().getMessage().trim();
if (!viewURL.startsWith(CHANGELOG_URL)) {
engine.getLoadWorker().cancel();
FXUtils.openLink(viewURL);
if (newValue == Worker.State.FAILED) {
LOG.warning("Failed to load update log, trying to open it in browser");
FXUtils.openLink(url);
setBody();
}
});
setBody(webView);
} catch (NoClassDefFoundError | UnsatisfiedLinkError e) {
LOG.log(Level.WARNING, "WebView is missing or initialization failed", e);
FXUtils.openLink(url);
}
setBody(webView);
}
{
@@ -17,6 +17,7 @@
*/
package org.jackhuang.hmcl.ui.download;
import com.jfoenix.controls.JFXButton;
import com.jfoenix.controls.JFXCheckBox;
import com.jfoenix.controls.JFXListView;
import com.jfoenix.controls.JFXSpinner;
@@ -39,7 +40,9 @@ import org.jackhuang.hmcl.download.forge.ForgeRemoteVersion;
import org.jackhuang.hmcl.download.game.GameRemoteVersion;
import org.jackhuang.hmcl.download.liteloader.LiteLoaderRemoteVersion;
import org.jackhuang.hmcl.download.optifine.OptiFineRemoteVersion;
import org.jackhuang.hmcl.setting.Theme;
import org.jackhuang.hmcl.ui.FXUtils;
import org.jackhuang.hmcl.ui.SVG;
import org.jackhuang.hmcl.ui.animation.ContainerAnimations;
import org.jackhuang.hmcl.ui.animation.TransitionPane;
import org.jackhuang.hmcl.ui.construct.ComponentList;
@@ -58,6 +61,7 @@ import java.util.concurrent.CompletableFuture;
import java.util.logging.Level;
import java.util.stream.Collectors;
import static org.jackhuang.hmcl.ui.ToolbarListPageSkin.wrap;
import static org.jackhuang.hmcl.util.Logging.LOG;
import static org.jackhuang.hmcl.util.i18n.I18n.i18n;
@@ -84,6 +88,8 @@ public final class VersionsPage extends BorderPane implements WizardPage, Refres
@FXML
private JFXCheckBox chkOld;
@FXML
private JFXButton btnRefresh;
@FXML
private HBox checkPane;
@FXML
private ComponentList centrePane;
@@ -114,6 +120,8 @@ public final class VersionsPage extends BorderPane implements WizardPage, Refres
chkSnapshot.selectedProperty().addListener(listener);
chkOld.selectedProperty().addListener(listener);
btnRefresh.setGraphic(wrap(SVG.refresh(Theme.blackFillBinding(), -1, -1)));
list.setCellFactory(listView -> new ListCell<RemoteVersion>() {
IconedTwoLineListItem content = new IconedTwoLineListItem();
RipplerContainer ripplerContainer = new RipplerContainer(content);
@@ -128,7 +128,7 @@ public class FeedbackPage extends VBox implements PageAware {
container.setPickOnBounds(false);
container.setAlignment(Pos.CENTER_LEFT);
HBox.setHgrow(content, Priority.ALWAYS);
content.setMouseTransparent(true);
content.setMouseTransparent(false);
setSelectable();
likeButton.getStyleClass().add("toggle-icon4");
@@ -152,7 +152,7 @@ public class FeedbackPage extends VBox implements PageAware {
"#" + feedback.getId(),
i18n("feedback.state." + feedback.getState().name().toLowerCase(Locale.US)),
i18n("feedback.type." + feedback.getType().name().toLowerCase(Locale.US)));
container.setOnMouseClicked(e -> {
content.setOnMouseClicked(e -> {
getFeedback(feedback.getId())
.thenAcceptAsync(Schedulers.javafx(), f -> {
Controllers.dialog(new ViewFeedbackDialog(f));
@@ -234,7 +234,7 @@ public final class MainPage extends StackPane implements DecoratorPage {
doAnimation(show);
if (show && getLatestVersion() != null && !Objects.equals(config().getPromptedVersion(), getLatestVersion().getVersion())) {
Controllers.dialog("", i18n("update.bubble.title", getLatestVersion().getVersion()), MessageDialogPane.MessageType.INFO, () -> {
Controllers.dialog("", i18n("update.bubble.title", getLatestVersion().getVersion()), MessageDialogPane.MessageType.INFO, () -> {
config().setPromptedVersion(getLatestVersion().getVersion());
onUpgrade();
});
@@ -59,40 +59,38 @@ import static org.jackhuang.hmcl.util.Pair.pair;
* Cato Management.
*/
public final class MultiplayerManager {
static final String CATO_VERSION = "1.1.1";
// private static final String CATO_DOWNLOAD_URL = "https://files.huangyuhui.net/maven/cato/cato/" + MultiplayerManager.CATO_VERSION;
private static final String CATO_DOWNLOAD_URL = "https://codechina.csdn.net/to/ioi_bin/-/raw/acb0524bcad82a31fa5a09bf4c79248ebd674de1/client/";
static final String CATO_VERSION = "1.2.0-202112171527";
private static final String CATO_DOWNLOAD_URL = "https://gitcode.net/huanghongxun1/ioi_bin/-/raw/c7b7d8c61b66c297a6460f744dc14487c3ec2289/client/";
private static final String CATO_PATH = getCatoPath();
public static final int CATO_AGREEMENT_VERSION = 2;
private static final String REMOTE_ADDRESS = "127.0.0.1";
private static final String LOCAL_ADDRESS = "0.0.0.0";
private static final Map<String, String> HASH = mapOf(
pair("cato-client-darwin-amd64", "6b7630f843d4b8f8e11feff4c1cb3dc1916d1fdb"),
pair("cato-client-darwin-arm64", "5f00153f0117eebb4209a4484152ec4077d34b34"),
pair("cato-client-freebsd-amd64", "ac401f51e69058696e342ddaa62968d21c8252e8"),
pair("cato-client-freebsd-arm7", "168dfdabc773ce87f0f1d901bee76f7ea3beacb3"),
pair("cato-client-freebsd-arm64", "08daef0f3acc279411ff39e8a22510a9876d06cb"),
pair("cato-client-freebsd-i386", "febdf99be30c671708dd80f8d3b48335a0d5920a"),
pair("cato-client-js.wasm", "0439d2a1cd8ee854ef6057a8ae6898db47aba2bd"),
pair("cato-client-linux-amd64", "816aecb116e2bc0727de9362e893bd9cefdf0485"),
pair("cato-client-linux-arm7", "710a047fdf528917d8a45ed0161ca155e2e05ff1"),
pair("cato-client-linux-arm64", "7a9a22d39f0ba200e1e4b2f6fca8cbe218a3eedf"),
pair("cato-client-linux-i386", "3eb0b37bdff8b9c8dc1e425b91ddb4d0a72a0da0"),
pair("cato-client-linux-mips", "8d2b383fcd4edb7903a14a93947ed5cb54838e60"),
pair("cato-client-linux-mips64", "248f1a3fe69ec97f6c095b63fa597ee099b4cb8c"),
pair("cato-client-linux-mips64le", "8d2f8d93ca582ab5f43dc4570a0d5b18dbe06df3"),
pair("cato-client-linux-mipsle", "f38bd14e6cdd6bfcd045ccd5a0a183bc8083c028"),
pair("cato-client-linux-ppc64", "db420847ed8e60a58a69b2e1cb55cf21b7b56e4b"),
pair("cato-client-linux-ppc64le", "717149f52a0808ee09cd5a7e89f8b9a6ed604cb0"),
pair("cato-client-openbsd-amd64", "248aaf3ca3bcaa18d4d1391325d171ef17e65244"),
pair("cato-client-openbsd-arm7", "1ab97264dba5d2b61388ee68e49f890c29c4e09f"),
pair("cato-client-openbsd-arm64", "5f28541ace9d298b816eb43963be8e4cd87bd0fd"),
pair("cato-client-openbsd-i386", "613b5c3fc0382815843a6e9b2a5281b05967bc1c"),
pair("cato-client-windows-amd64.exe", "64f19648d281882eefc5afaa3af347907af5cb23"),
pair("cato-client-windows-arm64.exe", "48a4bc5e18c35c93c9a3ecc500420d3abb5ae6f0"),
pair("cato-client-windows-i386.exe", "fcb4f245da2e293badb73fac04cf4e83fbd79b18")
pair("cato-client-darwin-amd64", "03c22a68f37654fea60761a1fcb5deb122ea69b8"),
pair("cato-client-darwin-arm64", "f79b80437a4b13dde72718dacc80c0469491ad48"),
pair("cato-client-freebsd-amd64", "6b244259e3887f5878a87b0a3fcdd5eec9a90a46"),
pair("cato-client-freebsd-arm64", "5529f6eacc5a47f9b6e41841531b5bbd911f74e5"),
pair("cato-client-freebsd-arm7", "f4b32ecadf82538965f969306e783fa7a7ce86a9"),
pair("cato-client-freebsd-i386", "24e27e63e9efe657de23f36f5217232d3c704de3"),
pair("cato-client-js.wasm", "3f5d13513b97e750d6cabce9b0c418e7187ad5c7"),
pair("cato-client-linux-amd64", "a3f6611ca9e602821faf909d9c6ec243236fed47"),
pair("cato-client-linux-arm64", "d04602c1b041f727a2429530e102392f596cc458"),
pair("cato-client-linux-arm7", "0924b8d71e62cc80ff7c09a6e1c6aa5b5ea9d77f"),
pair("cato-client-linux-i386", "fa426104d4cb0f028bbde5b8e6dddfa9169befd3"),
pair("cato-client-linux-mips", "1d8f2710df9e708ef9cc422336cf3fe9e48674e9"),
pair("cato-client-linux-mips64", "73ceb1c4e5374766a358d09fcb82a799fb65e846"),
pair("cato-client-linux-mips64le", "9d3af8504d049cb502b85fb0d87b9919881e029f"),
pair("cato-client-linux-mipsle", "0e771bde5a16fb03c952c6de06e4a65efe23ce83"),
pair("cato-client-linux-ppc64", "1199b67ec24afdb4dee2fe4e5f4eeeef8ac3e1e3"),
pair("cato-client-linux-ppc64le", "107f6d23685eb98ea961c7e7556d1956c364da32"),
pair("cato-client-openbsd-amd64", "606493c36521996b1ce41cd980a775db791b783f"),
pair("cato-client-openbsd-arm64", "4c1b2d89e88669452d174607bc65ed3897420868"),
pair("cato-client-openbsd-arm7", "a51860b41c4d3634d84fcec578f6ed15f8a49401"),
pair("cato-client-openbsd-i386", "9ac8f86b7ceb15564424fbd578867fae93b5cb47"),
pair("cato-client-windows-amd64.exe", "57c5166b4c02046ea73d0321481f379db8b103d3"),
pair("cato-client-windows-arm64.exe", "d6b9025f1a2a1202256546cfb38ed7d863f5bb57"),
pair("cato-client-windows-i386.exe", "45959f36c061ae7cd4294575053920fc43a85516")
);
private MultiplayerManager() {
@@ -401,7 +399,8 @@ public final class MultiplayerManager {
onExit.fireEvent(new CatoExitEvent(this, CatoExitEvent.EXIT_CODE_INTERRUPTED));
} finally {
try {
writer.close();
if (writer != null)
writer.close();
} catch (IOException e) {
LOG.log(Level.WARNING, "Failed to close cato stdin writer", e);
}
@@ -40,6 +40,7 @@ import org.jackhuang.hmcl.ui.decorator.DecoratorPage;
import org.jackhuang.hmcl.util.HMCLService;
import org.jackhuang.hmcl.util.Result;
import org.jackhuang.hmcl.util.StringUtils;
import org.jackhuang.hmcl.util.io.ChecksumMismatchException;
import org.jetbrains.annotations.Nullable;
import java.util.concurrent.CancellationException;
@@ -377,6 +378,8 @@ public class MultiplayerPage extends DecoratorAnimatedPage implements DecoratorP
} else {
return i18n("multiplayer.exit.after_ready");
}
} else if (e instanceof ChecksumMismatchException) {
return i18n("exception.artifact_malformed");
} else {
return fallback.apply(e);
}
@@ -55,9 +55,11 @@ public class GameAdvancedListItem extends AdvancedListItem {
private void loadVersion(String version) {
if (Profiles.getSelectedProfile() != profile) {
profile = Profiles.getSelectedProfile();
onVersionIconChangedListener = profile.getRepository().onVersionIconChanged.registerWeak(event -> {
this.loadVersion(Profiles.getSelectedVersion());
});
if (profile != null) {
onVersionIconChangedListener = profile.getRepository().onVersionIconChanged.registerWeak(event -> {
this.loadVersion(Profiles.getSelectedVersion());
});
}
}
if (version != null && Profiles.getSelectedProfile() != null &&
Profiles.getSelectedProfile().getRepository().hasVersion(version)) {
@@ -28,10 +28,15 @@ import javafx.scene.layout.BorderPane;
import javafx.scene.layout.Priority;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import org.jackhuang.hmcl.event.EventBus;
import org.jackhuang.hmcl.event.EventPriority;
import org.jackhuang.hmcl.event.RefreshedVersionsEvent;
import org.jackhuang.hmcl.game.GameRepository;
import org.jackhuang.hmcl.setting.Profile;
import org.jackhuang.hmcl.setting.Theme;
import org.jackhuang.hmcl.ui.FXUtils;
import org.jackhuang.hmcl.ui.SVG;
import org.jackhuang.hmcl.ui.WeakListenerHolder;
import org.jackhuang.hmcl.ui.animation.ContainerAnimations;
import org.jackhuang.hmcl.ui.animation.TransitionPane;
import org.jackhuang.hmcl.ui.construct.*;
@@ -43,6 +48,7 @@ import java.io.File;
import java.util.Optional;
import java.util.function.Supplier;
import static org.jackhuang.hmcl.ui.FXUtils.runInFX;
import static org.jackhuang.hmcl.util.i18n.I18n.i18n;
public class VersionPage extends DecoratorAnimatedPage implements DecoratorPage {
@@ -55,6 +61,7 @@ public class VersionPage extends DecoratorAnimatedPage implements DecoratorPage
private final TransitionPane transitionPane = new TransitionPane();
private final BooleanProperty currentVersionUpgradable = new SimpleBooleanProperty();
private final ObjectProperty<Profile.ProfileVersion> version = new SimpleObjectProperty<>();
private final WeakListenerHolder listenerHolder = new WeakListenerHolder();
private String preferredVersionName = null;
@@ -72,6 +79,22 @@ public class VersionPage extends DecoratorAnimatedPage implements DecoratorPage
FXUtils.onChangeAndOperate(tab.getSelectionModel().selectedItemProperty(), newValue -> {
transitionPane.setContent(newValue.getNode(), ContainerAnimations.FADE.getAnimationProducer());
});
listenerHolder.add(EventBus.EVENT_BUS.channel(RefreshedVersionsEvent.class).registerWeak(event -> checkSelectedVersion(), EventPriority.HIGHEST));
}
private void checkSelectedVersion() {
runInFX(() -> {
if (this.version.get() == null) return;
GameRepository repository = this.version.get().getProfile().getRepository();
if (!repository.hasVersion(this.version.get().getVersion())) {
if (preferredVersionName != null) {
loadVersion(preferredVersionName, this.version.get().getProfile());
} else {
fireEvent(new PageCloseEvent());
}
}
});
}
private <T extends Node> Supplier<T> loadVersionFor(Supplier<T> nodeSupplier) {
@@ -112,7 +112,7 @@ public final class VersionSettingsPage extends StackPane implements DecoratorPag
private final StringProperty selectedVersion = new SimpleStringProperty();
private final BooleanProperty navigateToSpecificSettings = new SimpleBooleanProperty(false);
private final BooleanProperty enableSpecificSettings = new SimpleBooleanProperty(true);
private final BooleanProperty enableSpecificSettings = new SimpleBooleanProperty(false);
private final IntegerProperty maxMemory = new SimpleIntegerProperty();
private final ObjectProperty<OperatingSystem.PhysicalMemoryStatus> memoryStatus = new SimpleObjectProperty<>(OperatingSystem.PhysicalMemoryStatus.INVALID);
private final BooleanProperty modpack = new SimpleBooleanProperty();
@@ -122,8 +122,8 @@ public final class Versions {
return;
}
if (profile.getRepository().renameVersion(version, newName)) {
profile.getRepository().refreshVersionsAsync().start();
resolve.run();
profile.getRepository().refreshVersionsAsync().start();
} else {
reject.accept(i18n("version.manage.rename.fail"));
}
@@ -26,18 +26,11 @@ import org.jackhuang.hmcl.ui.CrashWindow;
import org.jackhuang.hmcl.upgrade.IntegrityChecker;
import org.jackhuang.hmcl.upgrade.UpdateChecker;
import org.jackhuang.hmcl.util.io.NetworkUtils;
import org.jackhuang.hmcl.util.platform.Architecture;
import org.jackhuang.hmcl.util.platform.OperatingSystem;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
import static java.util.Collections.newSetFromMap;
import static org.jackhuang.hmcl.util.Logging.LOG;
import static org.jackhuang.hmcl.util.Pair.pair;
import static org.jackhuang.hmcl.util.i18n.I18n.i18n;
+1 -1
View File
@@ -285,7 +285,7 @@
}
.two-line-item-second-large > .first-line > .title {
.two-line-item-second-large > .first-line > .title, .two-line-item-second-large-title {
-fx-text-fill: rgba(0, 0, 0, 0.5);
-fx-font-weight: normal;
-fx-font-size: 12px;
@@ -23,10 +23,26 @@
<JFXSpinner fx:id="spinner" styleClass="first-spinner" />
<StackPane fx:id="center" style="-fx-padding: 10;">
<ComponentList fx:id="centrePane" styleClass="no-padding">
<HBox fx:id="checkPane" spacing="10" style="-fx-padding: 10;">
<JFXCheckBox fx:id="chkRelease" text="%version.game.releases" selected="true" />
<JFXCheckBox fx:id="chkSnapshot" text="%version.game.snapshots" />
<JFXCheckBox fx:id="chkOld" text="%version.game.old" />
<HBox fx:id="checkPane" spacing="10">
<JFXCheckBox fx:id="chkRelease" text="%version.game.releases" selected="true">
<HBox.margin>
<Insets top="10" bottom="10" />
</HBox.margin>
</JFXCheckBox>
<JFXCheckBox fx:id="chkSnapshot" text="%version.game.snapshots">
<HBox.margin>
<Insets top="10" bottom="10" />
</HBox.margin>
</JFXCheckBox>
<JFXCheckBox fx:id="chkOld" text="%version.game.old">
<HBox.margin>
<Insets top="10" bottom="10" />
</HBox.margin>
</JFXCheckBox>
<HBox HBox.hgrow="ALWAYS" />
<JFXButton fx:id="btnRefresh" styleClass="jfx-tool-bar-button" onMouseClicked="#onRefresh" text="%button.refresh" />
</HBox>
<JFXListView fx:id="list" styleClass="jfx-list-view-float" VBox.vgrow="ALWAYS">
</JFXListView>
@@ -182,6 +182,11 @@ curse.category.4472=Tech
curse.category.4473=Magic
# https://addons-ecs.forgesvc.net/api/v2/category/section/6
curse.category.5129=Vanilla+
curse.category.5189=Utility & QOL
curse.category.5190=QoL
curse.category.5191=Utility & QoL
curse.category.5192=FancyMenu
curse.category.423=Map and Information
curse.category.426=Addons
curse.category.434=Armor, Tools, and Weapons
@@ -223,7 +228,8 @@ curse.category.4558=Redstone
curse.category.4843=Automation
curse.category.4906=MCreator
# https://addons-ecs.forgesvc.net/api/v2/category/section/6
# https://addons-ecs.forgesvc.net/api/v2/category/section/12
curse.category.5193=Data Packs
curse.category.399=Steampunk
curse.category.396=128x
curse.category.398=512x and Higher
@@ -293,6 +299,7 @@ exception.access_denied=It's denied by operating system to access file %s. Maybe
Please check if current operating system user has permission to access that file.\n\
For Windows users, you can also try the Resource Monitor, find if some programs is holding the file, try to close related program, or restart your computer.
exception.artifact_malformed=The file cannot pass verification.
exception.ssl_handshake=Cannot establish SSL connection because of missing SSL certifcate in current Java installation. Try to start HMCL on another Java VM.
extension.bat=Windows Bat file
extension.mod=Mod file
@@ -386,7 +393,7 @@ game.crash.reason.openj9=Game cannot run on OpenJ9 virtual machine, please switc
game.crash.reason.out_of_memory=Game cannot run because out of memory.\nThis may be due to too little memory allocation, or too many mods.\nYou can increase the game memory allocation in the game settings to allow the game running on larger memory.\nIf you still have these problems, you may need to change a better computer.
game.crash.reason.resolution_too_high=Game cannot run because you are using a resource pack whose resolution is too high\nYou should use a resource pack with lower resolution, or buy a graphics card with larger memory.
game.crash.reason.stacktrace=Unknown. You can look into details by clicking "Logs" button.\nThere are some keywords that may represent Mod ID. You can search them online to figure out the reason.\n%s
game.crash.reason.too_old_java=Game cannot run because the Java virtual machine version is too low.\nYou need to switch to a newer version (%1$s) of Java virtual machine in the game settings and restart the game. If not, you can download it online.
game.crash.reason.too_old_java=Game cannot run because the Java virtual machine version is too low.\nYou need to switch to a newer version (%1$s) of Java virtual machine in the game settings and restart the game. If not, you can download it from <a href="https://docs.microsoft.com/en-US/java/openjdk/download">here</a>.
game.crash.reason.unknown=Unknown. You can look into details by clicking "Logs" button.
game.crash.reason.unsatisfied_link_error=Game cannot run because the required native libraries are missing.\nThe missing native library: %1$s。\nIf you have modified the native library path option in game settings, you'd better switch back to standard mode.\nIf it's already standard mode, please check if the missing native library belongs to a mod or the game. If you are sure that it's caused by HMCL, you can give feedback to us.\nIf you do really need to customize native library path, you should place all the native libraries the the game requires in the directory.
game.crash.title=Game crashed
@@ -698,7 +705,6 @@ multiplayer.session.create.token.prompt=Default randomized. You can apply for yo
multiplayer.session.error.already_started=Cato service has already started locally. Please check whether there are other multiplayer services served or not. Or you can kill cato process in task manager.
multiplayer.session.error.file_not_found=Cannot find cato executable. This file should be downloaded when entering this page. Please check if your anti-virus software has isolated the file. If true, please rollback.
multiplayer.session.expired=Multiplayer session has expired. You should re-create or re-join a room to continue.
multiplayer.session.hint=You must click "Open LAN Server" in game in order to enable multiplayer functionality.
multiplayer.session.join=Join Session
multiplayer.session.join.error=Failed to join multiplayer session
multiplayer.session.join.error.connection=Failed to join multiplayer session. Cannot establish connection.
@@ -943,7 +949,7 @@ update.found=Update Available!
update.newest_version=Latest version: %s
update.bubble.title=Update Available: %s
update.bubble.subtitle=Click here to update
update.note=Warning: Beta versions may have more functionality and bug fixes but also more possible errors.
update.note=Warning: Beta versions and nightly versions may have more functionality and bug fixes but also more possible errors.
update.latest=This is the latest version.
update.no_browser=Cannot open a browser. The link has been copied to the clipboard. Paste it into the address bar of browser to update.
update.tooltip=Update
@@ -971,7 +977,7 @@ version.manage.clean.tooltip=Clear logs, crash-reports
version.manage.duplicate=Copy game instance
version.manage.duplicate.duplicate_save=Copy saves
version.manage.duplicate.prompt=Type new version name
version.manage.duplicate.confirm=
version.manage.duplicate.confirm=New version generated by replication will be locked: forced independent mode, game setting independence.
version.manage.manage=Manage Version
version.manage.manage.title=Manage Version - %1s
version.manage.redownload_assets_index=Update Game Asset Files
@@ -182,6 +182,11 @@ curse.category.4472=科技
curse.category.4473=魔法
# https://addons-ecs.forgesvc.net/api/v2/category/section/6
curse.category.5129=原版增強
curse.category.5189=實用與QOL
curse.category.5190=QoL
curse.category.5191=實用與QoL
curse.category.5192=夢幻菜單
curse.category.423=訊息展示
curse.category.426=模組擴展
curse.category.434=裝備武器
@@ -224,6 +229,7 @@ curse.category.4843=自動化
curse.category.4906=MCreator
# https://addons-ecs.forgesvc.net/api/v2/category/section/6
curse.category.5193=封包
curse.category.399=蒸汽朋克
curse.category.396=128x
curse.category.398=512x 及更高
@@ -293,6 +299,7 @@ exception.access_denied=因為無法訪問文件 %s,HMCL 沒有對該文件的
請你檢查當前操作系統帳戶是否能訪問該文件,比如非管理員用戶可能不能訪問其他帳戶的個人文件夾內的文件。\n\
對於 Windows 用戶,你還可以嘗試通過資源監視器查看是否有程序占用了該文件,如果是,你可以關閉占用此文件相關程序,或者重啟電腦再試。
exception.artifact_malformed=下載的文件正確,無法通過校驗。
exception.ssl_handshake=無法建立 SSL 連接,因為當前 Java 虛擬機缺少相關的 SSL 證書。你可以嘗試使用其他的 Java 虛擬機啟動 HMCL 再試。
extension.bat=Windows 指令碼
extension.mod=模組檔案
@@ -386,7 +393,7 @@ game.crash.reason.openj9=當前遊戲無法運行在 OpenJ9 虛擬機上,請
game.crash.reason.out_of_memory=當前遊戲因為記憶體不足,無法繼續運行。\n這可能是記憶體分配太小,或者 Mod 數量過多導致的。\n你可以在遊戲設置中調大遊戲記憶體分配值以允許遊戲在更大的記憶體下運行。\n如果仍然出現該錯誤,你可能需要換一台更好的電腦。
game.crash.reason.resolution_too_high=當前遊戲因為材質包解析度過高,無法繼續運行\n你可以更換一個解析度更低的材質,或者更換一個視訊記憶體更大的顯示卡。
game.crash.reason.stacktrace=原因未知,請點擊日誌按鈕查看詳細訊息。\n下面是一些關鍵字,其中可能包含 Mod 名稱,你可以透過搜索的方式查找有關訊息。\n%s
game.crash.reason.too_old_java=當前遊戲因為 Java 虛擬機版本過低,無法繼續運行。\n你需要在遊戲設置中更換 %1$s 或更新版本的 Java 虛擬機,並重新啟動遊戲。如果沒有下載安裝,你可以在網路上自行下載。
game.crash.reason.too_old_java=當前遊戲因為 Java 虛擬機版本過低,無法繼續運行。\n你需要在遊戲設置中更換 %1$s 或更新版本的 Java 虛擬機,並重新啟動遊戲。如果沒有下載安裝,你可以點擊 <a href="https://docs.microsoft.com/zh-TW/java/openjdk/download">此處</a> 下載微軟 JDK。
game.crash.reason.unknown=原因未知,請點擊日誌按鈕查看詳細訊息。\n不要將本界面截圖給他人!如果你要求助他人,請你點擊左下角導出遊戲崩潰訊息後將導出的文件發送給他人以供分析!\n你可以向我們提供遊戲崩潰日誌以提升 HMCL 的日誌分析能力。
game.crash.reason.unsatisfied_link_error=當前遊戲因為缺少本地庫,無法繼續運行。\n這些本地庫缺失:%1$s。\n如果你在遊戲設置中修改了本地庫路徑選項,請你修改回預設模式。\n如果已經在預設模式下,請檢查本地庫缺失是否是 Mod 引起的,或由 HMCL 引起的。如果你確定是 HMCL 引起的,建議你向我們回饋。\n如果你確實需要自訂本地庫路徑,你需要保證其中包含缺失的本地庫。
game.crash.title=遊戲意外退出
@@ -650,7 +657,7 @@ multiplayer.download.success=多人聯機初始化完成
multiplayer.download.unsupported=多人聯機依賴不支持當前系統或平台
multiplayer.exit.after_ready=多人聯機會話意外退出,退出碼 %d
multiplayer.exit.before_ready=多人聯機房間創建失敗,cato 退出碼 %d
multiplayer.exit.timeout.static_token=無法連接多人聯機服務,請你切換動態 Token 重試。
multiplayer.exit.timeout.static_token=無法連接多人聯機服務,你的憑證可能無法正常工作,你可以使用空憑證再試。
multiplayer.exit.timeout.dynamic_token=無法連接多人聯機服務,你可以在多人聯機頁面的回饋中回饋問題。
multiplayer.hint=多人聯機功能處於實驗階段,如果有問題請回饋。
multiplayer.nat=網路檢測
@@ -671,8 +678,8 @@ multiplayer.nat.type.symmetric_udp_firewall=差(對稱型+防火牆)
multiplayer.nat.type.unknown=未知
multiplayer.powered_by=多人聯機服務由 這裡 (<a href="https://noin.cn">noin.cn</a>) 提供。<a href="https://noin.cn/agreement">用戶協議與免責聲明</a>
multiplayer.report=違法違規檢舉
multiplayer.relay=中繼模式
multiplayer.relay.hint=NAT 網路類型為差-對稱型的用戶,若無法聯機,申請靜態 Token 後可以啟用本選項
multiplayer.relay=橋接服務
multiplayer.relay.hint=Cato 面向較差網路情況提供的網路質量增強最佳化解決方案。若無法聯機請到 這裡 的個人中心兌換憑證後啟用。
multiplayer.session=房間
multiplayer.session.name.format=%1$s 的房間
multiplayer.session.name.motd=HMCL 多人聯機房間 - %s
@@ -681,7 +688,7 @@ multiplayer.session.close.warning=關閉房間後,已經加入聯機房間的
multiplayer.session.copy_room_code=複製邀請碼
multiplayer.session.create=創建房間
multiplayer.session.create.error.dynamic_token=創建聯機房間失敗,請稍後再試。
multiplayer.session.create.error.static_token=創建聯機房間失敗,你可以使用動態 Token 再試。
multiplayer.session.create.error.static_token=創建聯機房間失敗,你的憑證可能無法正常工作,你可以使用空憑證再試。
multiplayer.session.create.hint=創建聯機房間前,你需要先在正在運行的遊戲內的遊戲菜單中選擇 對區域網路開放 選項,然後在下方的輸入框中輸入遊戲內提示的埠號(通常是 5 位的數字)
multiplayer.session.create.join=連接申請
multiplayer.session.create.join.allow=自動接受所有連接申請(不啟用此選項時,你需要手動同意申請,以避免不相關人士誤連你的伺服器)
@@ -692,9 +699,9 @@ multiplayer.session.create.members.kick.prompt=是否踢出該玩家?踢出後
multiplayer.session.create.name=房間名稱
multiplayer.session.create.port=埠號
multiplayer.session.create.port.error=無法檢測遊戲埠號,你必須先啟動遊戲並在遊戲內打開對區域網路開放選項後才能啟動聯機。
multiplayer.session.create.token=Token
multiplayer.session.create.token.apply=申請靜態 Token
multiplayer.session.create.token.prompt=預設為臨時 Token。你可以在 noin.cn 上申請靜態 Token 並填寫至此處
multiplayer.session.create.token=憑證
multiplayer.session.create.token.apply=申請憑證
multiplayer.session.create.token.prompt=預設為無憑證。你可以在 這裡 的個人中心兌換憑證
multiplayer.session.error.already_started=本地已經開啟 cato 服務,請檢查是否有其他 HMCL 正在運行聯機服務。或者你可以在任務管理器裡殺掉 cato 進程以繼續。
multiplayer.session.error.file_not_found=找不到 cato 程序。該程序應該在進入多人聯機頁面時完成下載。請檢查你電腦的防毒軟體是否將 cato 標記為病毒,如果是,請恢復 cato。
multiplayer.session.expired=聯機會話連續使用時間超過了 3 小時,你需要重新創建/加入房間以繼續聯機。
@@ -942,7 +949,7 @@ update.found=發現到更新
update.newest_version=最新版本為: %s
update.bubble.title=發現更新: %s
update.bubble.subtitle=點選此處進行升級
update.note=開發版包含更多的功能以及錯誤修復,但也可能會包含其他的問題。
update.note=測試版與開發版包含更多的功能以及錯誤修復,但也可能會包含其他的問題。
update.latest=目前版本為最新版本
update.no_browser=無法開啟瀏覽器,網址已經複製到剪貼簿了,您可以手動複製網址開啟頁面
update.tooltip=更新
@@ -182,6 +182,11 @@ curse.category.4472=科技
curse.category.4473=魔法
# https://addons-ecs.forgesvc.net/api/v2/category/section/6
curse.category.5129=原版增强
curse.category.5189=实用与QOL
curse.category.5190=QoL
curse.category.5191=实用与QoL
curse.category.5192=梦幻菜单
curse.category.423=信息展示
curse.category.426=模组扩展
curse.category.434=装备武器
@@ -223,7 +228,8 @@ curse.category.4558=红石
curse.category.4843=自动化
curse.category.4906=MCreator
# https://addons-ecs.forgesvc.net/api/v2/category/section/6
# https://addons-ecs.forgesvc.net/api/v2/category/section/12
curse.category.5193=数据包
curse.category.399=蒸汽朋克
curse.category.396=128x
curse.category.398=512x 及更高
@@ -293,6 +299,7 @@ exception.access_denied=因为无法访问文件 %s,HMCL 没有对该文件的
请你检查当前操作系统帐户是否能访问该文件,比如非管理员用户可能不能访问其他帐户的个人文件夹内的文件。\n\
对于 Windows 用户,你还可以尝试通过资源监视器查看是否有程序占用了该文件,如果是,你可以关闭占用此文件相关程序,或者重启电脑再试。
exception.artifact_malformed=下载的文件正确,无法通过校验。
exception.ssl_handshake=无法建立 SSL 连接,因为当前 Java 虚拟机缺少相关的 SSL 证书。你可以尝试使用其他的 Java 虚拟机启动 HMCL 再试。
extension.bat=Windows 脚本
extension.mod=模组文件
@@ -386,7 +393,7 @@ game.crash.reason.openj9=当前游戏无法运行在 OpenJ9 虚拟机上,请
game.crash.reason.out_of_memory=当前游戏因为内存不足,无法继续运行。\n这可能是内存分配太小,或者 Mod 数量过多导致的。\n你可以在游戏设置中调大游戏内存分配值以允许游戏在更大的内存下运行。\n如果仍然出现该错误,你可能需要换一台更好的电脑。
game.crash.reason.resolution_too_high=当前游戏因为材质包分辨率过高,无法继续运行\n你可以更换一个分辨率更低的材质,或者更换一个显存更大的显卡。
game.crash.reason.stacktrace=原因未知,请点击日志按钮查看详细信息。\n下面是一些关键词,其中可能包含 Mod 名称,你可以通过搜索的方式查找有关信息。\n%s
game.crash.reason.too_old_java=当前游戏因为 Java 虚拟机版本过低,无法继续运行。\n你需要在游戏设置中更换 Java %1$s 或更新版本的 Java 虚拟机,并重新启动游戏。如果没有下载安装,你可以在 https://adoptopenjdk.net 上自行下载。
game.crash.reason.too_old_java=当前游戏因为 Java 虚拟机版本过低,无法继续运行。\n你需要在游戏设置中更换 Java %1$s 或更新版本的 Java 虚拟机,并重新启动游戏。如果没有下载安装,你可以点击 <a href="https://docs.microsoft.com/zh-cn/java/openjdk/download">此处</a> 下载微软 JDK。
game.crash.reason.unknown=原因未知,请点击日志按钮查看详细信息。\n不要将本界面截图给他人!如果你要求助他人,请你点击左下角导出游戏崩溃信息后将导出的文件发送给他人以供分析!\n你可以向我们提供游戏崩溃日志以提升 HMCL 的日志分析能力。
game.crash.reason.unsatisfied_link_error=当前游戏因为缺少本地库,无法继续运行。\n这些本地库缺失:%1$s。\n如果你在游戏设置中修改了本地库路径选项,请你修改回预设模式。\n如果已经在预设模式下,请检查本地库缺失是否是 Mod 引起的,或由 HMCL 引起的。如果你确定是 HMCL 引起的,建议你向我们反馈。\n如果你确实需要自定义本地库路径,你需要保证其中包含缺失的本地库。
game.crash.title=游戏意外退出
@@ -650,7 +657,7 @@ multiplayer.download.success=多人联机初始化完成
multiplayer.download.unsupported=多人联机依赖不支持当前系统或平台
multiplayer.exit.after_ready=多人联机会话意外退出,退出码 %d
multiplayer.exit.before_ready=多人联机房间创建失败,cato 退出码 %d
multiplayer.exit.timeout.static_token=无法连接多人联机服务,请你切换动态 Token 重试。
multiplayer.exit.timeout.static_token=无法连接多人联机服务,你的凭证可能无法正常工作,你可以使用空凭证再试。
multiplayer.exit.timeout.dynamic_token=无法连接多人联机服务,你可以在多人联机页面的反馈中反馈问题。
multiplayer.hint=多人联机功能处于实验阶段,如果有问题请反馈。
multiplayer.nat=网络检测
@@ -670,8 +677,8 @@ multiplayer.nat.type.symmetric=差(对称型)
multiplayer.nat.type.symmetric_udp_firewall=差(对称型+防火墙)
multiplayer.nat.type.unknown=未知
multiplayer.powered_by=多人联机服务由 这里 (<a href="https://noin.cn">noin.cn</a>) 提供。<a href="https://noin.cn/agreement">用户协议与免责声明</a>
multiplayer.relay=中继模式
multiplayer.relay.hint=NAT 网络类型为差-对称型的用户,若无法联机,申请静态 Token 后可以启用本选项
multiplayer.relay=桥接服务
multiplayer.relay.hint=Cato 面向较差网络情况提供的网络质量增强优化解决方案。若无法联机请到 这里 的个人中心兑换凭证后启用。
multiplayer.report=违法违规举报
multiplayer.session=房间
multiplayer.session.name.format=%1$s 的房间
@@ -681,7 +688,7 @@ multiplayer.session.close.warning=关闭房间后,已经加入联机房间的
multiplayer.session.copy_room_code=复制邀请码
multiplayer.session.create=创建房间
multiplayer.session.create.error.dynamic_token=创建联机房间失败,请稍后再试。
multiplayer.session.create.error.static_token=创建联机房间失败,你可以使用动态 Token 再试。
multiplayer.session.create.error.static_token=创建联机房间失败,你的凭证可能无法正常工作,你可以使用空凭证再试。
multiplayer.session.create.hint=创建联机房间前,你需要先在正在运行的游戏内的游戏菜单中选择 对局域网开放 选项,然后在下方的输入框中确认游戏内提示的端口号(通常是 5 位的数字)
multiplayer.session.create.join=连接申请
multiplayer.session.create.join.allow=自动接受所有连接申请(不启用此选项时,你需要手动同意申请,以避免不相关人士误连你的服务器)
@@ -692,9 +699,9 @@ multiplayer.session.create.members.kick.prompt=是否踢出该玩家?踢出后
multiplayer.session.create.name=房间名称
multiplayer.session.create.port=端口号
multiplayer.session.create.port.error=无法检测游戏端口号,你必须先启动游戏并在游戏内打开对局域网开放选项后才能启动联机。
multiplayer.session.create.token=Token
multiplayer.session.create.token.apply=申请静态 Token
multiplayer.session.create.token.prompt=默认为临时 Token。你可以在 noin.cn 上申请静态 Token 并填写至此处
multiplayer.session.create.token=凭证
multiplayer.session.create.token.apply=申请凭证
multiplayer.session.create.token.prompt=默认为无凭证。你可以在 这里 的个人中心兑换凭证
multiplayer.session.error.already_started=本地已经开启 cato 服务,请检查是否有其他 HMCL 正在运行联机服务。或者你可以在任务管理器里杀掉 cato 进程以继续。
multiplayer.session.error.file_not_found=找不到 cato 程序。该程序应该在进入多人联机页面时完成下载。请检查你电脑的杀毒软件是否将 cato 标记为病毒,如果是,请恢复 cato。
multiplayer.session.expired=联机会话连续使用时间超过了 3 小时,你需要重新创建/加入房间以继续联机。
@@ -942,7 +949,7 @@ update.found=发现更新
update.newest_version=最新版本为:%s
update.bubble.title=发现更新:%s
update.bubble.subtitle=点击此处进行升级
update.note=开发版包含更多的功能以及错误修复,但也可能会包含其他的问题。
update.note=测试版与开发版包含更多的功能以及错误修复,但也可能会包含其他的问题。
update.latest=当前版本为最新版本
update.no_browser=无法打开浏览器,网址已经复制到剪贴板了,您可以手动粘贴网址打开页面
update.tooltip=更新
@@ -46,7 +46,7 @@ public class GameCrashWindowTest {
ManagedProcess process = new ManagedProcess(null, Arrays.asList("commands", "2"));
String logs = FileUtils.readText(new File("C:\\Users\\huang\\Downloads\\minecraft-exported-logs-2021-10-18T21-15-43.log"));
String logs = FileUtils.readText(new File("../HMCLCore/src/test/resources/logs/too_old_java.txt"));
CountDownLatch latch = new CountDownLatch(1);
FXUtils.runInFX(() -> {
+8
View File
@@ -17,3 +17,11 @@ dependencies {
api group: 'org.apache.commons', name: 'commons-lang3', version: '3.12.0'
compileOnlyApi group: 'org.jetbrains', name: 'annotations', version: '16.0.3'
}
tasks.processResources {
dependsOn ':log4j-patch:jar'
into('assets/game') {
from project(':log4j-patch').file("build/libs")
}
}
@@ -24,6 +24,7 @@ import org.jackhuang.hmcl.util.io.HttpRequest;
import org.jackhuang.hmcl.util.io.NetworkUtils;
import java.io.IOException;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
@@ -144,11 +145,17 @@ public class OAuth {
public Result refresh(String refreshToken, Options options) throws AuthenticationException {
try {
RefreshResponse response = HttpRequest.POST(accessTokenURL)
.form(pair("client_id", options.callback.getClientId()),
pair("client_secret", options.callback.getClientSecret()),
pair("refresh_token", refreshToken),
pair("grant_type", "refresh_token"))
Map<String, String> query = mapOf(pair("client_id", options.callback.getClientId()),
pair("refresh_token", refreshToken),
pair("grant_type", "refresh_token")
);
if (!options.callback.isPublicClient()) {
query.put("client_secret", options.callback.getClientSecret());
}
RefreshResponse response = HttpRequest.POST(tokenURL)
.form(query)
.accept("application/json")
.ignoreHttpCode()
.getJson(RefreshResponse.class);
@@ -233,6 +240,8 @@ public class OAuth {
String getClientId();
String getClientSecret();
boolean isPublicClient();
}
public enum GrantFlow {
@@ -136,20 +136,6 @@ public class MicrosoftService {
getUhs(minecraftXstsResponse, uhs);
// Authenticate XBox with XSTS
XBoxLiveAuthenticationResponse xboxXstsResponse = HttpRequest
.POST("https://xsts.auth.xboxlive.com/xsts/authorize")
.json(mapOf(
pair("Properties",
mapOf(pair("SandboxId", "RETAIL"),
pair("UserTokens", Collections.singletonList(xboxResponse.token)))),
pair("RelyingParty", "http://xboxlive.com"), pair("TokenType", "JWT")))
.getJson(XBoxLiveAuthenticationResponse.class);
getUhs(xboxXstsResponse, uhs);
getXBoxProfile(uhs, xboxXstsResponse.token);
// Authenticate with Minecraft
MinecraftLoginWithXBoxResponse minecraftResponse = HttpRequest
.POST("https://api.minecraftservices.com/authentication/login_with_xbox")
@@ -27,6 +27,7 @@ import org.jackhuang.hmcl.game.Library;
import org.jackhuang.hmcl.game.Version;
import org.jackhuang.hmcl.task.Task;
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.util.ArrayList;
@@ -78,7 +79,8 @@ public class DefaultDependencyManager extends AbstractDependencyManager {
Version version = original.resolve(repository);
return Task.allOf(
Task.composeAsync(() -> {
if (!repository.getVersionJar(version).exists())
File versionJar = repository.getVersionJar(version);
if (!versionJar.exists() || versionJar.length() == 0)
return new GameDownloadTask(this, null, version);
else
return null;
@@ -27,6 +27,7 @@ import org.jackhuang.hmcl.util.versioning.VersionNumber;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
@@ -62,18 +63,57 @@ public class MaintainTask extends Task<Version> {
String mainClass = version.resolve(null).getMainClass();
if (mainClass != null && mainClass.equals(LibraryAnalyzer.LAUNCH_WRAPPER_MAIN)) {
return maintainOptiFineLibrary(repository, maintainGameWithLaunchWrapper(unique(version), true), false);
version = maintainOptiFineLibrary(repository, maintainGameWithLaunchWrapper(unique(version), true), false);
} else if (mainClass != null && mainClass.equals(LibraryAnalyzer.MOD_LAUNCHER_MAIN)) {
// Forge 1.13 and OptiFine
return maintainOptiFineLibrary(repository, maintainGameWithCpwModLauncher(repository, unique(version)), true);
version = maintainOptiFineLibrary(repository, maintainGameWithCpwModLauncher(repository, unique(version)), true);
} else if (mainClass != null && mainClass.equals(LibraryAnalyzer.BOOTSTRAP_LAUNCHER_MAIN)) {
// Forge 1.17
return maintainGameWithCpwBoostrapLauncher(repository, unique(version));
version = maintainGameWithCpwBoostrapLauncher(repository, unique(version));
} else {
// Vanilla Minecraft does not need maintain
// Fabric does not need maintain, nothing compatible with fabric now.
return maintainOptiFineLibrary(repository, unique(version), false);
version = maintainOptiFineLibrary(repository, unique(version), false);
}
Library log4jPatch = null;
List<Library> libraries = version.getLibraries();
for (Library library : libraries) {
if (library.is("org.apache.logging.log4j", "log4j-core")) {
if (library.getVersion().startsWith("2.0-beta")) {
if ("2.0-beta9".equals(library.getVersion())) {
log4jPatch = new Library(new Artifact("org.glavo", "log4j-patch-beta9", "1.0"));
} else {
Logging.LOG.warning("Log4j " + library.getVersion() + " cannot be patched");
}
} else if (VersionNumber.VERSION_COMPARATOR.compare(library.getVersion(), "2.16") < 0) {
log4jPatch = new Library(new Artifact("org.glavo", "log4j-patch", "1.0"));
}
break;
}
}
if (log4jPatch != null) {
ArrayList<Library> patchedLibraries = new ArrayList<>(libraries.size() + 1);
patchedLibraries.add(log4jPatch);
patchedLibraries.addAll(libraries);
version = version.setLibraries(patchedLibraries);
Path log4jPatchPath = repository.getLibraryFile(version, log4jPatch).toPath();
String patchName = log4jPatch.getArtifactId() + "-" + log4jPatch.getVersion();
if (Files.notExists(log4jPatchPath)) {
try (InputStream input = MaintainTask.class.getResourceAsStream("/assets/game/" + patchName + ".jar")) {
Files.createDirectories(log4jPatchPath.getParent());
Files.copy(input, log4jPatchPath, StandardCopyOption.REPLACE_EXISTING);
} catch (IOException e) {
Logging.LOG.log(Level.WARNING, "Unable to unpack " + patchName, e);
}
}
Logging.LOG.info("Apply patch " + patchName + " to log4j");
}
return version;
}
public static Version maintainPreservingPatches(GameRepository repository, Version version) {
@@ -136,10 +176,9 @@ public class MaintainTask extends Task<Version> {
builder.addJvmArgument("-Dhmcl.transformer.candidates=${library_directory}/" + library.getPath());
if (!libraryExisting) builder.addLibrary(hmclTransformerDiscoveryService);
Path libraryPath = repository.getLibraryFile(version, hmclTransformerDiscoveryService).toPath();
try {
try (InputStream input = MaintainTask.class.getResourceAsStream("/assets/game/HMCLTransformerDiscoveryService-1.0.jar")) {
Files.createDirectories(libraryPath.getParent());
Files.copy(MaintainTask.class.getResourceAsStream("/assets/game/HMCLTransformerDiscoveryService-1.0.jar"),
libraryPath, StandardCopyOption.REPLACE_EXISTING);
Files.copy(input, libraryPath, StandardCopyOption.REPLACE_EXISTING);
} catch (IOException e) {
Logging.LOG.log(Level.WARNING, "Unable to unpack HMCLTransformerDiscoveryService", e);
}
@@ -229,6 +229,7 @@ public final class OptiFineInstallTask extends Task<Version> {
try (FileSystem fs = CompressingUtils.createReadOnlyZipFileSystem(installer)) {
Path configClass = fs.getPath("Config.class");
if (!Files.exists(configClass)) configClass = fs.getPath("net/optifine/Config.class");
if (!Files.exists(configClass)) configClass = fs.getPath("notch/net/optifine/Config.class");
if (!Files.exists(configClass)) throw new IOException("Unrecognized installer");
ConstantPool pool = ConstantPoolScanner.parse(Files.readAllBytes(configClass), ConstantType.UTF8);
List<String> constants = new ArrayList<>();
@@ -35,6 +35,7 @@ public enum JavaVersionConstraint {
// Minecraft>=1.17 requires Java 16
VANILLA_JAVA_16(JavaVersionConstraint.RULE_MANDATORY, versionRange("1.17", JavaVersionConstraint.MAX), versionRange("16", JavaVersionConstraint.MAX)),
VANILLA_JAVA_17(JavaVersionConstraint.RULE_MANDATORY, versionRange("1.18", JavaVersionConstraint.MAX), versionRange("17", JavaVersionConstraint.MAX)),
// Minecraft>=1.13 requires Java 8
VANILLA_JAVA_8(JavaVersionConstraint.RULE_MANDATORY, versionRange("1.13", JavaVersionConstraint.MAX), versionRange("1.8", JavaVersionConstraint.MAX)),
// Minecraft>=1.7.10+Forge accepts Java 8
@@ -31,12 +31,14 @@ import org.jackhuang.hmcl.util.Log4jLevel;
import org.jackhuang.hmcl.util.StringUtils;
import org.jackhuang.hmcl.util.gson.UUIDTypeAdapter;
import org.jackhuang.hmcl.util.io.FileUtils;
import org.jackhuang.hmcl.util.io.IOUtils;
import org.jackhuang.hmcl.util.io.Unzipper;
import org.jackhuang.hmcl.util.platform.CommandBuilder;
import org.jackhuang.hmcl.util.platform.JavaVersion;
import org.jackhuang.hmcl.util.platform.ManagedProcess;
import org.jackhuang.hmcl.util.platform.OperatingSystem;
import org.jackhuang.hmcl.util.platform.Bits;
import org.jackhuang.hmcl.util.versioning.VersionNumber;
import java.io.*;
import java.net.InetSocketAddress;
@@ -48,8 +50,10 @@ import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.*;
import java.util.function.Supplier;
import java.util.logging.Level;
import static org.jackhuang.hmcl.util.Lang.mapOf;
import static org.jackhuang.hmcl.util.Logging.LOG;
import static org.jackhuang.hmcl.util.Pair.pair;
/**
@@ -114,6 +118,19 @@ public class DefaultLauncher extends Launcher {
res.addAllWithoutParsing(options.getJavaArguments());
Charset encoding = OperatingSystem.NATIVE_CHARSET;
// After Java 17, file.encoding does not affect console encoding
if (options.getJava().getParsedVersion() <= JavaVersion.JAVA_17) {
try {
String fileEncoding = res.addDefault("-Dfile.encoding=", encoding.name());
if (fileEncoding != null)
encoding = Charset.forName(fileEncoding.substring("-Dfile.encoding=".length()));
} catch (Throwable ex) {
LOG.log(Level.WARNING, "Bad file encoding", ex);
}
}
// JVM Args
if (!options.isNoGeneratedJVMArgs()) {
appendJvmArgs(res);
@@ -180,6 +197,16 @@ public class DefaultLauncher extends Launcher {
res.addDefault("-Dfml.ignorePatchDiscrepancies=", "true");
}
// Fix RCE vulnerability of log4j2
res.addDefault("-Djava.rmi.server.useCodebaseOnly=", "true");
res.addDefault("-Dcom.sun.jndi.rmi.object.trustURLCodebase=", "false");
res.addDefault("-Dcom.sun.jndi.cosnaming.object.trustURLCodebase=", "false");
String formatMsgNoLookups = res.addDefault("-Dlog4j2.formatMsgNoLookups=", "true");
if (!"-Dlog4j2.formatMsgNoLookups=false".equals(formatMsgNoLookups) && isUsingLog4j()) {
res.addDefault("-Dlog4j.configurationFile=", getLog4jConfigurationFile().getAbsolutePath());
}
Proxy proxy = options.getProxy();
if (proxy != null && StringUtils.isBlank(options.getProxyUser()) && StringUtils.isBlank(options.getProxyPass())) {
InetSocketAddress address = (InetSocketAddress) options.getProxy().address();
@@ -269,7 +296,7 @@ public class DefaultLauncher extends Launcher {
res.addAllWithoutParsing(Arguments.parseStringArguments(options.getGameArguments(), configuration));
res.removeIf(it -> getForbiddens().containsKey(it) && getForbiddens().get(it).get());
return new Command(res, tempNativeFolder);
return new Command(res, tempNativeFolder, encoding);
}
public Map<String, Boolean> getFeatures() {
@@ -333,6 +360,29 @@ public class DefaultLauncher extends Launcher {
}
}
private boolean isUsingLog4j() {
return VersionNumber.VERSION_COMPARATOR.compare(repository.getGameVersion(version).orElse("Unknown"), "1.7") >= 0;
}
public File getLog4jConfigurationFile() {
return new File(repository.getVersionRoot(version.getId()), "log4j2.xml");
}
public void extractLog4jConfigurationFile() throws IOException {
File targetFile = getLog4jConfigurationFile();
InputStream source;
if (VersionNumber.VERSION_COMPARATOR.compare(repository.getGameVersion(version).orElse("Unknown"), "1.12") < 0) {
source = DefaultLauncher.class.getResourceAsStream("/assets/game/log4j2-1.7.xml");
} else {
source = DefaultLauncher.class.getResourceAsStream("/assets/game/log4j2-1.12.xml");
}
try (InputStream input = source;
OutputStream output = new FileOutputStream(targetFile)) {
IOUtils.copyTo(input, output);
}
}
protected Map<String, String> getConfigurations() {
return mapOf(
// defined by Minecraft official launcher
@@ -400,6 +450,10 @@ public class DefaultLauncher extends Launcher {
decompressNatives(nativeFolder);
}
if (isUsingLog4j()) {
extractLog4jConfigurationFile();
}
File runDirectory = repository.getRunDirectory(version.getId());
if (StringUtils.isNotBlank(options.getPreLaunchCommand())) {
@@ -416,7 +470,12 @@ public class DefaultLauncher extends Launcher {
}
String appdata = options.getGameDir().getAbsoluteFile().getParent();
if (appdata != null) builder.environment().put("APPDATA", appdata);
if (classpath != null) builder.environment().put("CLASSPATH", classpath);
if (classpath != null) {
builder.environment().put("CLASSPATH", classpath);
// Fix #1153: On Windows, the 'classpath' environment variable in the context overrides the 'CLASSPATH'
// Environment variables on Windows are not case-sensitive; The lowercase 'classpath' overwrites any other case.
builder.environment().put("classpath", classpath);
}
builder.environment().putAll(getEnvVars());
process = builder.start();
} catch (IOException e) {
@@ -425,7 +484,7 @@ public class DefaultLauncher extends Launcher {
ManagedProcess p = new ManagedProcess(process, rawCommandLine, classpath);
if (listener != null)
startMonitors(p, listener, daemon);
startMonitors(p, listener, command.encoding, daemon);
return p;
}
@@ -469,6 +528,10 @@ public class DefaultLauncher extends Launcher {
decompressNatives(nativeFolder);
}
if (isUsingLog4j()) {
extractLog4jConfigurationFile();
}
String scriptExtension = FileUtils.getExtension(scriptFile);
boolean usePowerShell = "ps1".equals(scriptExtension);
@@ -586,17 +649,17 @@ public class DefaultLauncher extends Launcher {
throw new ExecutionPolicyLimitException();
}
private void startMonitors(ManagedProcess managedProcess, ProcessListener processListener, boolean isDaemon) {
private void startMonitors(ManagedProcess managedProcess, ProcessListener processListener, Charset encoding, boolean isDaemon) {
processListener.setProcess(managedProcess);
Thread stdout = Lang.thread(new StreamPump(managedProcess.getProcess().getInputStream(), it -> {
processListener.onLog(it, Optional.ofNullable(Log4jLevel.guessLevel(it)).orElse(Log4jLevel.INFO));
managedProcess.addLine(it);
}, OperatingSystem.NATIVE_CHARSET), "stdout-pump", isDaemon);
}, encoding), "stdout-pump", isDaemon);
managedProcess.addRelatedThread(stdout);
Thread stderr = Lang.thread(new StreamPump(managedProcess.getProcess().getErrorStream(), it -> {
processListener.onLog(it, Log4jLevel.ERROR);
managedProcess.addLine(it);
}, OperatingSystem.NATIVE_CHARSET), "stderr-pump", isDaemon);
}, encoding), "stderr-pump", isDaemon);
managedProcess.addRelatedThread(stderr);
managedProcess.addRelatedThread(Lang.thread(new ExitWaiter(managedProcess, Arrays.asList(stdout, stderr), processListener::onExit), "exit-waiter", isDaemon));
}
@@ -604,10 +667,12 @@ public class DefaultLauncher extends Launcher {
private static final class Command {
final CommandBuilder commandLine;
final Path tempNativeFolder;
final Charset encoding;
Command(CommandBuilder commandBuilder, Path tempNativeFolder) {
Command(CommandBuilder commandBuilder, Path tempNativeFolder, Charset encoding) {
this.commandLine = commandBuilder;
this.tempNativeFolder = tempNativeFolder;
this.encoding = encoding;
}
}
}
@@ -62,7 +62,6 @@ public class McbbsModpackCompletionTask extends CompletableFutureTask<Void> {
private final String version;
private final File configurationFile;
private ModpackConfiguration<McbbsModpackManifest> configuration;
private GetTask dependent;
private McbbsModpackManifest manifest;
private final List<Task<?>> dependencies = new LinkedList<>();
@@ -108,11 +107,11 @@ public class McbbsModpackCompletionTask extends CompletableFutureTask<Void> {
}
})).thenComposeAsync(wrap(unused1 -> {
return executor.one(new GetTask(new URL(manifest.getFileApi() + "/manifest.json")));
})).thenComposeAsync(wrap(unused1 -> {
})).thenComposeAsync(wrap(remoteManifestJson -> {
McbbsModpackManifest remoteManifest;
// We needs to update modpack from online server.
try {
remoteManifest = JsonUtils.fromNonNullJson(dependent.getResult(), McbbsModpackManifest.class);
remoteManifest = JsonUtils.fromNonNullJson(remoteManifestJson, McbbsModpackManifest.class);
} catch (JsonParseException e) {
throw new IOException("Unable to parse server manifest.json from " + manifest.getFileApi(), e);
}
@@ -17,13 +17,14 @@
*/
package org.jackhuang.hmcl.util;
import org.jackhuang.hmcl.util.io.IOUtils;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.text.SimpleDateFormat;
import java.text.MessageFormat;
import java.util.Date;
import java.util.logging.*;
@@ -35,7 +36,7 @@ public final class Logging {
}
public static final Logger LOG = Logger.getLogger("HMCL");
private static ByteArrayOutputStream storedLogs = new ByteArrayOutputStream();
private static final ByteArrayOutputStream storedLogs = new ByteArrayOutputStream(IOUtils.DEFAULT_BUFFER_SIZE);
public static void start(Path logFolder) {
LOG.setLevel(Level.ALL);
@@ -46,6 +47,7 @@ public final class Logging {
FileHandler fileHandler = new FileHandler(logFolder.resolve("hmcl.log").toAbsolutePath().toString());
fileHandler.setLevel(Level.FINEST);
fileHandler.setFormatter(DefaultFormatter.INSTANCE);
fileHandler.setEncoding("UTF-8");
LOG.addHandler(fileHandler);
} catch (IOException e) {
System.err.println("Unable to create hmcl.log, " + e.getMessage());
@@ -87,27 +89,29 @@ public final class Logging {
}
public static String getLogs() {
return storedLogs.toString();
try {
return storedLogs.toString("UTF-8");
} catch (UnsupportedEncodingException e) {
throw new InternalError(e);
}
}
private static final class DefaultFormatter extends Formatter {
static final DefaultFormatter INSTANCE = new DefaultFormatter();
private final SimpleDateFormat format = new SimpleDateFormat("HH:mm:ss");
private static final MessageFormat format = new MessageFormat("[{0,date,HH:mm:ss}] [{1}.{2}/{3}] {4}\n");
@Override
public String format(LogRecord record) {
String date = format.format(new Date(record.getMillis()));
String log = String.format("[%s] [%s.%s/%s] %s%n",
date, record.getSourceClassName(), record.getSourceMethodName(),
record.getLevel().getName(), record.getMessage()
);
ByteArrayOutputStream builder = new ByteArrayOutputStream();
String log = format.format(new Object[]{
new Date(record.getMillis()),
record.getSourceClassName(), record.getSourceMethodName(), record.getLevel().getName(),
record.getMessage()
}, new StringBuffer(128), null).toString();
if (record.getThrown() != null)
try (PrintWriter writer = new PrintWriter(builder)) {
record.getThrown().printStackTrace(writer);
}
return log + builder.toString();
log += StringUtils.getStackTrace(record.getThrown());
return log;
}
}
@@ -64,4 +64,4 @@ public abstract class Result<T> {
}
}
}
}
@@ -19,9 +19,7 @@ package org.jackhuang.hmcl.util;
import org.jackhuang.hmcl.util.platform.OperatingSystem;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
import java.io.*;
import java.nio.charset.CharsetEncoder;
import java.nio.charset.StandardCharsets;
import java.util.*;
@@ -37,13 +35,11 @@ public final class StringUtils {
}
public static String getStackTrace(Throwable throwable) {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
try {
throwable.printStackTrace(new PrintStream(stream, false, "UTF-8"));
return stream.toString("UTF-8");
} catch (UnsupportedEncodingException e) {
throw new InternalError(e);
StringWriter stringWriter = new StringWriter(512);
try (PrintWriter printWriter = new PrintWriter(stringWriter)) {
throwable.printStackTrace(printWriter);
}
return stringWriter.toString();
}
public static String getStackTrace(StackTraceElement[] elements) {
@@ -20,6 +20,7 @@ package org.jackhuang.hmcl.util.io;
import org.jackhuang.hmcl.util.Lang;
import org.jackhuang.hmcl.util.StringUtils;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
@@ -36,7 +37,6 @@ import java.util.function.Predicate;
import static java.nio.charset.StandardCharsets.UTF_8;
/**
*
* @author huang
*/
public final class FileUtils {
@@ -425,4 +425,24 @@ public final class FileUtils {
return Optional.empty();
}
}
public static Path tmpSaveFile(Path file) {
return file.toAbsolutePath().resolveSibling("." + file.getFileName().toString() + ".tmp");
}
public static void saveSafely(Path file, String content) throws IOException {
Path tmpFile = tmpSaveFile(file);
try (BufferedWriter writer = Files.newBufferedWriter(tmpFile, StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.CREATE)) {
writer.write(content);
}
try {
if (Files.exists(file) && Files.getAttribute(file, "dos:hidden") == Boolean.TRUE) {
Files.setAttribute(tmpFile, "dos:hidden", true);
}
} catch (Throwable ignored) {
}
Files.move(tmpFile, file, StandardCopyOption.REPLACE_EXISTING);
}
}
@@ -80,7 +80,7 @@ public final class Zipper implements Closeable {
if (filter != null && !filter.test(relativePath.replace('\\', '/'))) {
return FileVisitResult.SKIP_SUBTREE;
}
Files.copy(file, root.resolve(relativePath));
Files.copy(file, root.resolve(relativePath), StandardCopyOption.COPY_ATTRIBUTES);
return FileVisitResult.CONTINUE;
}
@@ -104,11 +104,11 @@ public final class Zipper implements Closeable {
}
public void putFile(Path file, String path) throws IOException {
Files.copy(file, fs.getPath(path));
Files.copy(file, fs.getPath(path), StandardCopyOption.COPY_ATTRIBUTES);
}
public void putStream(InputStream in, String path) throws IOException {
Files.copy(in, fs.getPath(path));
Files.copy(in, fs.getPath(path), StandardCopyOption.COPY_ATTRIBUTES);
}
public void putTextFile(String text, String path) throws IOException {
@@ -83,33 +83,33 @@ public final class CommandBuilder {
return this;
}
public CommandBuilder addDefault(String opt) {
public String addDefault(String opt) {
for (Item item : raw) {
if (item.arg.equals(opt)) {
return this;
return item.arg;
}
}
raw.add(new Item(opt, true));
return this;
return null;
}
public CommandBuilder addDefault(String opt, String value) {
public String addDefault(String opt, String value) {
for (Item item : raw) {
if (item.arg.startsWith(opt)) {
LOG.info("Default option '" + opt + value + "' is suppressed by '" + item.arg + "'");
return this;
return item.arg;
}
}
raw.add(new Item(opt + value, true));
return this;
return null;
}
public CommandBuilder addUnstableDefault(String opt, boolean value) {
public String addUnstableDefault(String opt, boolean value) {
for (Item item : raw) {
final Matcher matcher = UNSTABLE_BOOLEAN_OPTION_PATTERN.matcher(item.arg);
if (matcher.matches()) {
if (matcher.group("key").equals(opt)) {
return this;
return item.arg;
}
}
}
@@ -119,21 +119,21 @@ public final class CommandBuilder {
} else {
raw.add(new Item("-XX:-" + opt, true));
}
return this;
return null;
}
public CommandBuilder addUnstableDefault(String opt, String value) {
public String addUnstableDefault(String opt, String value) {
for (Item item : raw) {
final Matcher matcher = UNSTABLE_OPTION_PATTERN.matcher(item.arg);
if (matcher.matches()) {
if (matcher.group("key").equals(opt)) {
return this;
return item.arg;
}
}
}
raw.add(new Item("-XX:" + opt + "=" + value, true));
return this;
return null;
}
public boolean removeIf(Predicate<String> pred) {
@@ -112,6 +112,7 @@ public final class JavaVersion {
public static final int JAVA_8 = 8;
public static final int JAVA_9 = 9;
public static final int JAVA_16 = 16;
public static final int JAVA_17 = 17;
private static int parseVersion(String version) {
Matcher matcher = VERSION.matcher(version);
@@ -22,6 +22,7 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.charset.UnsupportedCharsetException;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -112,15 +113,26 @@ public enum OperatingSystem {
private static final Pattern MEMINFO_PATTERN = Pattern.compile("^(?<key>.*?):\\s+(?<value>\\d+) kB?$");
static {
String nativeEncoding = System.getProperty("native.encoding", System.getProperty("sun.jnu.encoding"));
String nativeEncoding = System.getProperty("native.encoding");
String hmclNativeEncoding = System.getProperty("hmcl.native.encoding");
Charset nativeCharset = Charset.defaultCharset();
if (nativeEncoding != null) {
try {
nativeCharset = Charset.forName(nativeEncoding);
} catch (UnsupportedCharsetException e) {
e.printStackTrace();
try {
if (hmclNativeEncoding != null) {
nativeCharset = Charset.forName(hmclNativeEncoding);
} else {
if (nativeEncoding != null && !nativeEncoding.equalsIgnoreCase(nativeCharset.name())) {
nativeCharset = Charset.forName(nativeEncoding);
}
if (nativeCharset == StandardCharsets.UTF_8 || nativeCharset == StandardCharsets.US_ASCII) {
nativeCharset = StandardCharsets.UTF_8;
} else if ("GBK".equalsIgnoreCase(nativeCharset.name()) || "GB2312".equalsIgnoreCase(nativeCharset.name())) {
nativeCharset = Charset.forName("GB18030");
}
}
} catch (UnsupportedCharsetException e) {
e.printStackTrace();
}
NATIVE_CHARSET = nativeCharset;
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
<Appenders>
<Console name="SysOut" target="SYSTEM_OUT">
<PatternLayout pattern="[%d{HH:mm:ss}] [%t/%level]: %msg{nolookups}%n" />
</Console>
<Queue name="ServerGuiConsole">
<PatternLayout pattern="[%d{HH:mm:ss} %level]: %msg{nolookups}%n" />
</Queue>
<RollingRandomAccessFile name="File" fileName="logs/latest.log" filePattern="logs/%d{yyyy-MM-dd}-%i.log.gz">
<PatternLayout pattern="[%d{HH:mm:ss}] [%t/%level]: %msg{nolookups}%n" />
<Policies>
<TimeBasedTriggeringPolicy />
<OnStartupTriggeringPolicy />
</Policies>
</RollingRandomAccessFile>
</Appenders>
<Loggers>
<Root level="info">
<filters>
<MarkerFilter marker="NETWORK_PACKETS" onMatch="DENY" onMismatch="NEUTRAL" />
</filters>
<AppenderRef ref="SysOut"/>
<AppenderRef ref="File"/>
</Root>
</Loggers>
</Configuration>
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
<Appenders>
<Console name="SysOut" target="SYSTEM_OUT">
<PatternLayout pattern="[%d{HH:mm:ss}] [%t/%level]: %msg%n" />
</Console>
<Queue name="ServerGuiConsole">
<PatternLayout pattern="[%d{HH:mm:ss} %level]: %msg%n" />
</Queue>
<RollingRandomAccessFile name="File" fileName="logs/latest.log" filePattern="logs/%d{yyyy-MM-dd}-%i.log.gz">
<PatternLayout pattern="[%d{HH:mm:ss}] [%t/%level]: %msg%n" />
<Policies>
<TimeBasedTriggeringPolicy />
<OnStartupTriggeringPolicy />
</Policies>
</RollingRandomAccessFile>
</Appenders>
<Loggers>
<Root level="info">
<filters>
<MarkerFilter marker="NETWORK_PACKETS" onMatch="DENY" onMismatch="NEUTRAL" />
<RegexFilter regex=".*\$\{[^}]*\}.*" onMatch="DENY" onMismatch="NEUTRAL"/>
</filters>
<AppenderRef ref="SysOut"/>
<AppenderRef ref="File"/>
</Root>
</Loggers>
</Configuration>
@@ -1 +0,0 @@
org.jackhuang.hmcl.HMCLTransformerDiscoveryService
+4 -1
View File
@@ -11,7 +11,9 @@ No plugin API is provided.
## Download
Download the latest version [from the official website](https://hmcl.huangyuhui.net/download)
Note: Github releases are outdated.
Note: The recent versions in Github release is the beta version, which contains extra testing functions compared to the release versions on the official website. However, they may be unstable and you're more likely to encounter bugs or unexpected problems.
If not necessary, it is recommended to download the ones from the official website.
## License
The software is distributed under [GPL v3](https://www.gnu.org/licenses/gpl-3.0.html) with additional terms.
@@ -56,5 +58,6 @@ Make sure you have Java installed with JavaFX 8 at least. Liberica full JDK 8 or
|`-Dhmcl.update_source.override=<url>`|Override the update source.|
|`-Dhmcl.authlibinjector.location=<path>`|Use specified authlib-injector (instead of downloading one).|
|`-Dhmcl.openjfx.repo=<maven repository url>`|Add custom maven repository for download OpenJFX.|
|`-Dhmcl.native.encoding=<encoding>`|Override the native encoding.|
|`-Dhmcl.microsoft.auth.id=<App ID>`|Override Microsoft OAuth App ID.|
|`-Dhmcl.microsoft.auth.secret=<App Secret>`|Override Microsoft OAuth App secret.|
+2
View File
@@ -22,6 +22,8 @@ subprojects {
apply plugin: 'checkstyle'
repositories {
flatDir name: 'libs', dirs: rootProject.file('lib')
mavenCentral()
maven { url 'https://jitpack.io' }
@@ -4,6 +4,11 @@ dependencies {
compileOnly project.files("lib/modlauncher-4.1.0.jar")
}
compileJava {
sourceCompatibility = 8
targetCompatibility = 8
}
jar {
manifest {
attributes 'Created-By': 'Copyright(c) 2013-2020 huangyuhui.',
+13
View File
@@ -0,0 +1,13 @@
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.
@@ -0,0 +1,6 @@
# Log4j Patch
Copy from [Glavo/log4j-patch](https://github.com/Glavo/log4j-patch/).
`org.apache.logging.log4j.core.lookup.JndiLookup` is licensed under the WTFPL 2.0 license,
and `org.apache.logging.log4j.core.lookup.Interpolator` is licensed under the Apache 2.0 license.
@@ -0,0 +1,46 @@
version '1.0'
dependencies {
compileOnly group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.0-beta9'
}
tasks.compileJava {
sourceCompatibility = 8
targetCompatibility = 8
doLast {
FileTree tree = fileTree('build/classes/java/main')
tree.include '**/*.class'
tree.each {
RandomAccessFile rf = new RandomAccessFile(it, "rw")
rf.seek(7) // major version
rf.write(50) // java 6
rf.close()
}
}
}
task patchJar(type: Jar) {
dependsOn(tasks.compileJava)
baseName = 'log4j-patch'
from(sourceSets.main.output) {
include('**/JndiLookup.class')
}
}
task patchBeta9Jar(type: Jar) {
dependsOn(tasks.compileJava)
baseName = 'log4j-patch-beta9'
from(sourceSets.main.output) {
include '**/Interpolator.class'
}
}
tasks.jar {
enabled = false
dependsOn patchJar, patchBeta9Jar
}
@@ -0,0 +1,155 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache license, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the license for the specific language governing permissions and
* limitations under the license.
*/
package org.apache.logging.log4j.core.lookup;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.core.config.plugins.PluginManager;
import org.apache.logging.log4j.core.config.plugins.PluginType;
import org.apache.logging.log4j.status.StatusLogger;
import java.util.HashMap;
import java.util.Map;
/**
* The Interpolator is a StrLookup that acts as a proxy for all the other StrLookups.
*/
public class Interpolator implements StrLookup {
private static final Logger LOGGER = StatusLogger.getLogger();
/** Constant for the prefix separator. */
private static final char PREFIX_SEPARATOR = ':';
private final Map<String, StrLookup> lookups = new HashMap<String, StrLookup>();
private final StrLookup defaultLookup;
@SuppressWarnings("deprecation")
public Interpolator(final StrLookup defaultLookup) {
this.defaultLookup = defaultLookup == null ? new MapLookup(new HashMap<String, String>()) : defaultLookup;
final PluginManager manager = new PluginManager("Lookup");
manager.collectPlugins();
final Map<String, PluginType<?>> plugins = manager.getPlugins();
for (final Map.Entry<String, PluginType<?>> entry : plugins.entrySet()) {
@SuppressWarnings("unchecked")
final Class<? extends StrLookup> clazz = (Class<? extends StrLookup>) entry.getValue().getPluginClass();
try {
lookups.put(entry.getKey(), clazz.newInstance());
} catch (final Exception ex) {
LOGGER.error("Unable to create Lookup for " + entry.getKey(), ex);
}
}
}
/**
* Create the default Interpolator using only Lookups that work without an event.
*/
public Interpolator() {
this.defaultLookup = new MapLookup(new HashMap<String, String>());
lookups.put("sys", new SystemPropertiesLookup());
lookups.put("env", new EnvironmentLookup());
// lookups.put("jndi", new JndiLookup());
LOGGER.warn("log4j-patch works, JNDI lookup is disabled");
try {
if (Class.forName("javax.servlet.ServletContext") != null) {
lookups.put("web", new WebLookup());
}
} catch (ClassNotFoundException ex) {
LOGGER.debug("ServletContext not present - WebLookup not added");
} catch (Exception ex) {
LOGGER.error("Unable to locate ServletContext", ex);
}
}
/**
* Resolves the specified variable. This implementation will try to extract
* a variable prefix from the given variable name (the first colon (':') is
* used as prefix separator). It then passes the name of the variable with
* the prefix stripped to the lookup object registered for this prefix. If
* no prefix can be found or if the associated lookup object cannot resolve
* this variable, the default lookup object will be used.
*
* @param var the name of the variable whose value is to be looked up
* @return the value of this variable or <b>null</b> if it cannot be
* resolved
*/
@Override
public String lookup(final String var) {
return lookup(null, var);
}
/**
* Resolves the specified variable. This implementation will try to extract
* a variable prefix from the given variable name (the first colon (':') is
* used as prefix separator). It then passes the name of the variable with
* the prefix stripped to the lookup object registered for this prefix. If
* no prefix can be found or if the associated lookup object cannot resolve
* this variable, the default lookup object will be used.
*
* @param event The current LogEvent or null.
* @param var the name of the variable whose value is to be looked up
* @return the value of this variable or <b>null</b> if it cannot be
* resolved
*/
@Override
public String lookup(final LogEvent event, String var) {
if (var == null) {
return null;
}
final int prefixPos = var.indexOf(PREFIX_SEPARATOR);
if (prefixPos >= 0) {
final String prefix = var.substring(0, prefixPos);
final String name = var.substring(prefixPos + 1);
final StrLookup lookup = lookups.get(prefix);
String value = null;
if (lookup != null) {
value = event == null ? lookup.lookup(name) : lookup.lookup(event, name);
}
if (value != null) {
return value;
}
var = var.substring(prefixPos + 1);
}
if (defaultLookup != null) {
return event == null ? defaultLookup.lookup(var) : defaultLookup.lookup(event, var);
}
return null;
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder();
for (final String name : lookups.keySet()) {
if (sb.length() == 0) {
sb.append("{");
} else {
sb.append(", ");
}
sb.append(name);
}
if (sb.length() > 0) {
sb.append("}");
}
return sb.toString();
}
}
@@ -0,0 +1,13 @@
/*
* Copyright © 2021 Glavo <zjx001202@gmail.com>
* This work is free. You can redistribute it and/or modify it under the
* terms of the Do What The Fuck You Want To Public License, Version 2,
* as published by Sam Hocevar. See http://www.wtfpl.net/ for more details.
*/
package org.apache.logging.log4j.core.lookup;
public class JndiLookup {
public JndiLookup() {
throw new NoClassDefFoundError("JNDI lookup is disabled");
}
}
+4
View File
@@ -2,3 +2,7 @@ rootProject.name = 'HMCL3'
include ':HMCL'
include ':HMCLCore'
include ':HMCLTransformerDiscoveryService'
include ':log4j-patch'
project(':HMCLTransformerDiscoveryService').projectDir = file('minecraft/libraries/HMCLTransformerDiscoveryService')
project(':log4j-patch').projectDir = file('minecraft/libraries/log4j-patch')