Skip to content

Commit 3088f5d

Browse files
WhatDamon3gf8jv4dv
authored andcommitted
在 macOS 上添加启动脚本的后缀 .command (#4927)
1 parent e8b9d98 commit 3088f5d

5 files changed

Lines changed: 10 additions & 2 deletions

File tree

HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/Versions.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,11 @@ public static void generateLaunchScript(Profile profile, String id) {
200200
if (repository.getRunDirectory(id).isDirectory())
201201
chooser.setInitialDirectory(repository.getRunDirectory(id));
202202
chooser.setTitle(i18n("version.launch_script.save"));
203+
if (OperatingSystem.CURRENT_OS == OperatingSystem.MACOS) {
204+
chooser.getExtensionFilters().add(
205+
new FileChooser.ExtensionFilter(i18n("extension.command"), "*.command")
206+
);
207+
}
203208
chooser.getExtensionFilters().add(OperatingSystem.CURRENT_OS == OperatingSystem.WINDOWS
204209
? new FileChooser.ExtensionFilter(i18n("extension.bat"), "*.bat")
205210
: new FileChooser.ExtensionFilter(i18n("extension.sh"), "*.sh"));

HMCL/src/main/resources/assets/lang/I18N.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@ extension.mod=Mod File
370370
extension.png=Image File
371371
extension.ps1=Windows PowerShell Script
372372
extension.sh=Shell Script
373+
extension.command=macOS Shell Script
373374

374375
fatal.create_hmcl_current_directory_failure=Hello Minecraft! Launcher cannot create the HMCL directory (%s). Please move HMCL to another location and reopen it.
375376
fatal.javafx.incompatible=Missing JavaFX environment.\n\

HMCL/src/main/resources/assets/lang/I18N_zh.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,7 @@ extension.mod=模組檔案
368368
extension.png=圖片檔案
369369
extension.ps1=PowerShell 指令碼
370370
extension.sh=Bash 指令碼
371+
extension.command=macOS Shell 指令碼
371372

372373
fatal.create_hmcl_current_directory_failure=Hello Minecraft! Launcher 無法建立 HMCL 資料夾 (%s),請將 HMCL 移動至其他位置再開啟。
373374
fatal.javafx.incompatible=缺少 JavaFX 執行環境。\nHMCL 無法在低於 Java 11 的 Java 環境上自行補全 JavaFX 執行環境。請更新到 Java 11 或更高版本。

HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,7 @@ extension.mod=模组文件
377377
extension.png=图片文件
378378
extension.ps1=PowerShell 脚本
379379
extension.sh=Bash 脚本
380+
extension.command=macOS Shell 脚本
380381

381382
fatal.create_hmcl_current_directory_failure=Hello Minecraft! Launcher 无法创建 HMCL 文件夹 (%s),请将 HMCL 移动至其他位置再启动。\n如遇到问题,你可以访问 https://docs.hmcl.net/help.html 页面寻求帮助。
382383
fatal.javafx.incompatible=缺少 JavaFX 运行环境。\nHello Minecraft! Launcher 无法在低于 Java 11 的 Java 环境上自行补全 JavaFX 运行环境。请更新到 Java 11 或更高版本。\n你可以访问 https://docs.hmcl.net/help.html 页面寻求帮助。

HMCLCore/src/main/java/org/jackhuang/hmcl/launch/DefaultLauncher.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -597,8 +597,8 @@ public void makeLaunchScript(File scriptFile) throws IOException {
597597
if (!usePowerShell) {
598598
if (isWindows && !scriptExtension.equals("bat"))
599599
throw new IllegalArgumentException("The extension of " + scriptFile + " is not 'bat' or 'ps1' in Windows");
600-
else if (!isWindows && !scriptExtension.equals("sh"))
601-
throw new IllegalArgumentException("The extension of " + scriptFile + " is not 'sh' or 'ps1' in macOS/Linux");
600+
else if (!isWindows && !(scriptExtension.equals("sh") || scriptExtension.equals("command")))
601+
throw new IllegalArgumentException("The extension of " + scriptFile + " is not 'sh', 'ps1' or 'command' in macOS/Linux");
602602
}
603603

604604
final Command commandLine = generateCommandLine(nativeFolder);

0 commit comments

Comments
 (0)