From aaab95ba5528c67f1056f2cc7e42656348ca3ec6 Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Mon, 12 Jun 2023 12:08:18 +0100 Subject: [PATCH 01/30] Basic Quick Play support Signed-off-by: TheKodeToad --- launcher/minecraft/MinecraftInstance.cpp | 11 ++++++++-- .../launcher/impl/StandardLauncher.java | 21 +++++++++++++++---- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/launcher/minecraft/MinecraftInstance.cpp b/launcher/minecraft/MinecraftInstance.cpp index 2c624a365..caba8f9a7 100644 --- a/launcher/minecraft/MinecraftInstance.cpp +++ b/launcher/minecraft/MinecraftInstance.cpp @@ -564,8 +564,15 @@ QStringList MinecraftInstance::processMinecraftArgs( if (serverToJoin && !serverToJoin->address.isEmpty()) { - args_pattern += " --server " + serverToJoin->address; - args_pattern += " --port " + QString::number(serverToJoin->port); + if (profile->hasTrait("quickPlay")) + { + args_pattern += " --quickPlayMultiplayer " + serverToJoin->address + ':' + QString::number(serverToJoin->port); + } + else + { + args_pattern += " --server " + serverToJoin->address; + args_pattern += " --port " + QString::number(serverToJoin->port); + } } QMap token_mapping; diff --git a/libraries/launcher/org/prismlauncher/launcher/impl/StandardLauncher.java b/libraries/launcher/org/prismlauncher/launcher/impl/StandardLauncher.java index 9436ff15e..c9ec34909 100644 --- a/libraries/launcher/org/prismlauncher/launcher/impl/StandardLauncher.java +++ b/libraries/launcher/org/prismlauncher/launcher/impl/StandardLauncher.java @@ -55,14 +55,21 @@ package org.prismlauncher.launcher.impl; import java.lang.invoke.MethodHandle; +import java.util.Collections; +import java.util.List; import org.prismlauncher.utils.Parameters; import org.prismlauncher.utils.ReflectionUtils; public final class StandardLauncher extends AbstractLauncher { + private final boolean quickPlaySupported; + public StandardLauncher(Parameters params) { super(params); + + List traits = params.getList("traits", Collections.emptyList()); + quickPlaySupported = traits.contains("quickPlay"); } @Override @@ -77,10 +84,16 @@ public final class StandardLauncher extends AbstractLauncher { } if (serverAddress != null) { - gameArgs.add("--server"); - gameArgs.add(serverAddress); - gameArgs.add("--port"); - gameArgs.add(serverPort); + if (quickPlaySupported) { + // as of 23w14a + gameArgs.add("--quickPlayMultiplayer"); + gameArgs.add(serverAddress + ':' + serverPort); + } else { + gameArgs.add("--server"); + gameArgs.add(serverAddress); + gameArgs.add("--port"); + gameArgs.add(serverPort); + } } // find and invoke the main method From db4a7ce23951019005ecc8111d1c007087a02053 Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Fri, 20 Oct 2023 13:11:17 +0100 Subject: [PATCH 02/30] Fix code style Signed-off-by: TheKodeToad --- .../org/prismlauncher/launcher/impl/StandardLauncher.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/launcher/org/prismlauncher/launcher/impl/StandardLauncher.java b/libraries/launcher/org/prismlauncher/launcher/impl/StandardLauncher.java index b687b20ec..70ee015bd 100644 --- a/libraries/launcher/org/prismlauncher/launcher/impl/StandardLauncher.java +++ b/libraries/launcher/org/prismlauncher/launcher/impl/StandardLauncher.java @@ -63,7 +63,7 @@ import java.util.List; public final class StandardLauncher extends AbstractLauncher { private final boolean quickPlaySupported; - + public StandardLauncher(Parameters params) { super(params); From 1a379280b88e0bfa604ed5ff38ef97ac2b7b11ff Mon Sep 17 00:00:00 2001 From: Trial97 Date: Sun, 17 Mar 2024 20:53:26 +0200 Subject: [PATCH 03/30] Fixed curesforge export Signed-off-by: Trial97 (cherry picked from commit 05487152fe4eae0ad3d12b18c398ea2a99b44e32) --- launcher/modplatform/flame/FlamePackExportTask.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/launcher/modplatform/flame/FlamePackExportTask.cpp b/launcher/modplatform/flame/FlamePackExportTask.cpp index e28c82b4c..3a2028fd1 100644 --- a/launcher/modplatform/flame/FlamePackExportTask.cpp +++ b/launcher/modplatform/flame/FlamePackExportTask.cpp @@ -393,16 +393,16 @@ QByteArray FlamePackExportTask::generateIndex() version["version"] = minecraft->m_version; QString id; if (quilt != nullptr) - id = "quilt-" + quilt->getVersion(); + id = "quilt-" + quilt->m_version; else if (fabric != nullptr) - id = "fabric-" + fabric->getVersion(); + id = "fabric-" + fabric->m_version; else if (forge != nullptr) - id = "forge-" + forge->getVersion(); + id = "forge-" + forge->m_version; else if (neoforge != nullptr) { id = "neoforge-"; if (minecraft->m_version == "1.20.1") id += "1.20.1-"; - id += neoforge->getVersion(); + id += neoforge->m_version; } version["modLoaders"] = QJsonArray(); if (!id.isEmpty()) { From ca3516d26de0e697b944c9c57b2787e1ad4d4877 Mon Sep 17 00:00:00 2001 From: chouzz Date: Sat, 9 Mar 2024 19:34:16 +0800 Subject: [PATCH 04/30] Add totalTimePlayed for FTBApp import Signed-off-by: chouzz (cherry picked from commit 92113e233aefbd2b255775d4e858e45845a94a2c) --- launcher/modplatform/import_ftb/PackHelpers.cpp | 1 + launcher/modplatform/import_ftb/PackHelpers.h | 1 + launcher/modplatform/import_ftb/PackInstallTask.cpp | 1 + 3 files changed, 3 insertions(+) diff --git a/launcher/modplatform/import_ftb/PackHelpers.cpp b/launcher/modplatform/import_ftb/PackHelpers.cpp index ecf973452..e523b9d20 100644 --- a/launcher/modplatform/import_ftb/PackHelpers.cpp +++ b/launcher/modplatform/import_ftb/PackHelpers.cpp @@ -43,6 +43,7 @@ Modpack parseDirectory(QString path) modpack.version = Json::requireString(root, "version", "version"); modpack.mcVersion = Json::requireString(root, "mcVersion", "mcVersion"); modpack.jvmArgs = Json::ensureVariant(root, "jvmArgs", {}, "jvmArgs"); + modpack.totalPlayTime = Json::requireInteger(root, "totalPlayTime", "totalPlayTime"); } catch (const Exception& e) { qDebug() << "Couldn't load ftb instance json: " << e.cause(); return {}; diff --git a/launcher/modplatform/import_ftb/PackHelpers.h b/launcher/modplatform/import_ftb/PackHelpers.h index 221eb5bf6..449ed2546 100644 --- a/launcher/modplatform/import_ftb/PackHelpers.h +++ b/launcher/modplatform/import_ftb/PackHelpers.h @@ -36,6 +36,7 @@ struct Modpack { QString name; QString version; QString mcVersion; + int totalPlayTime; // not needed for instance creation QVariant jvmArgs; diff --git a/launcher/modplatform/import_ftb/PackInstallTask.cpp b/launcher/modplatform/import_ftb/PackInstallTask.cpp index 9a3b2595b..d529dd7e1 100644 --- a/launcher/modplatform/import_ftb/PackInstallTask.cpp +++ b/launcher/modplatform/import_ftb/PackInstallTask.cpp @@ -55,6 +55,7 @@ void PackInstallTask::copySettings() instanceSettings->suspendSave(); MinecraftInstance instance(m_globalSettings, instanceSettings, m_stagingPath); instance.settings()->set("InstanceType", "OneSix"); + instance.settings()->set("totalTimePlayed", m_pack.totalPlayTime / 1000); if (m_pack.jvmArgs.isValid() && !m_pack.jvmArgs.toString().isEmpty()) { instance.settings()->set("OverrideJavaArgs", true); From b255c8b17f6e72a006c9123410709ab161a7852e Mon Sep 17 00:00:00 2001 From: Trial97 Date: Wed, 27 Mar 2024 00:56:12 +0200 Subject: [PATCH 05/30] Changed the trait name Signed-off-by: Trial97 --- launcher/minecraft/MinecraftInstance.cpp | 2 +- .../org/prismlauncher/launcher/impl/StandardLauncher.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/launcher/minecraft/MinecraftInstance.cpp b/launcher/minecraft/MinecraftInstance.cpp index e85b16214..9e5463b30 100644 --- a/launcher/minecraft/MinecraftInstance.cpp +++ b/launcher/minecraft/MinecraftInstance.cpp @@ -548,7 +548,7 @@ QStringList MinecraftInstance::processMinecraftArgs(AuthSessionPtr session, Mine } if (serverToJoin && !serverToJoin->address.isEmpty()) { - if (profile->hasTrait("quickPlay")) { + if (profile->hasTrait("feature:is_quick_play_multiplayer")) { args_pattern += " --quickPlayMultiplayer " + serverToJoin->address + ':' + QString::number(serverToJoin->port); } else { args_pattern += " --server " + serverToJoin->address; diff --git a/libraries/launcher/org/prismlauncher/launcher/impl/StandardLauncher.java b/libraries/launcher/org/prismlauncher/launcher/impl/StandardLauncher.java index 70ee015bd..49e5d518f 100644 --- a/libraries/launcher/org/prismlauncher/launcher/impl/StandardLauncher.java +++ b/libraries/launcher/org/prismlauncher/launcher/impl/StandardLauncher.java @@ -68,7 +68,7 @@ public final class StandardLauncher extends AbstractLauncher { super(params); List traits = params.getList("traits", Collections.emptyList()); - quickPlaySupported = traits.contains("quickPlay"); + quickPlaySupported = traits.contains("feature:is_quick_play_multiplayer"); } @Override From 4642c13ca4f71b3a9fa8033f87ed38638ad5145b Mon Sep 17 00:00:00 2001 From: DioEgizio <83089242+DioEgizio@users.noreply.github.com> Date: Wed, 20 Mar 2024 13:16:28 +0100 Subject: [PATCH 06/30] fix: include libbz2.so.1.0 fixes portable installs not working on fedora anymore i did this only on portable builds and not system installs so that it doesn't create problems to people packaging them, as to fix system installs i would have to put it in bin/ Signed-off-by: DioEgizio <83089242+DioEgizio@users.noreply.github.com> --- .github/workflows/build.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 432f39fb0..88ded3cfb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -448,7 +448,6 @@ jobs: run: | cmake --install ${{ env.BUILD_DIR }} --prefix ${{ env.INSTALL_DIR }} for l in $(find ${{ env.INSTALL_DIR }} -type f); do l=${l#$(pwd)/}; l=${l#${{ env.INSTALL_DIR }}/}; l=${l#./}; echo $l; done > ${{ env.INSTALL_DIR }}/manifest.txt - cd ${{ env.INSTALL_DIR }} tar --owner root --group root -czf ../PrismLauncher.tar.gz * @@ -457,9 +456,12 @@ jobs: run: | cmake --install ${{ env.BUILD_DIR }} --prefix ${{ env.INSTALL_PORTABLE_DIR }} cmake --install ${{ env.BUILD_DIR }} --prefix ${{ env.INSTALL_PORTABLE_DIR }} --component portable + + # workaround to make portable installs to work on fedora + mkdir ${{ env.INSTALL_PORTABLE_DIR }}/lib + cp /lib/x86_64-linux-gnu/libbz2.so.1.0 ${{ env.INSTALL_PORTABLE_DIR }}/lib + for l in $(find ${{ env.INSTALL_PORTABLE_DIR }} -type f); do l=${l#$(pwd)/}; l=${l#${{ env.INSTALL_PORTABLE_DIR }}/}; l=${l#./}; echo $l; done > ${{ env.INSTALL_PORTABLE_DIR }}/manifest.txt - - cd ${{ env.INSTALL_PORTABLE_DIR }} tar -czf ../PrismLauncher-portable.tar.gz * From 2c864a4aad756addd8659f3900ea4f8517ec40ae Mon Sep 17 00:00:00 2001 From: Trial97 Date: Mon, 30 Oct 2023 22:55:23 +0200 Subject: [PATCH 07/30] added more microsoft error codes Signed-off-by: Trial97 --- .../auth/steps/XboxAuthorizationStep.cpp | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/launcher/minecraft/auth/steps/XboxAuthorizationStep.cpp b/launcher/minecraft/auth/steps/XboxAuthorizationStep.cpp index c33d7e629..36a76b870 100644 --- a/launcher/minecraft/auth/steps/XboxAuthorizationStep.cpp +++ b/launcher/minecraft/auth/steps/XboxAuthorizationStep.cpp @@ -126,7 +126,34 @@ bool XboxAuthorizationStep::processSTSError(QNetworkReply::NetworkError error, Q emit finished( AccountTaskState::STATE_FAILED_SOFT, tr("This Microsoft account is underaged and is not linked to a family.\n\nPlease set up your account according to %1.") - .arg("help.minecraft.net")); + .arg("help.minecraft.net")); + return true; + } + case 2148916236: { + emit finished(AccountTaskState::STATE_FAILED_SOFT, + tr("This Microsoft account requires proof of age to play. Please login to %1 to provide proof of age.") + .arg("login.live.com")); + return true; + } + case 2148916237: + emit finished(AccountTaskState::STATE_FAILED_SOFT, tr("This Microsoft account has reached the its limit for playtime. This " + "Microsoft account has been blocked from logging in.")); + return true; + case 2148916227: { + emit finished(AccountTaskState::STATE_FAILED_SOFT, tr("This Microsoft account was banned by Xbox for violating one or more " + "Community Standards for Xbox and is unable to be used.")); + return true; + } + case 2148916229: { + emit finished(AccountTaskState::STATE_FAILED_SOFT, + tr("This Microsoft account is currently restricted and your guardian has not given you permission to play " + "online. Login to %1 and have your guardian change your permissions.") + .arg("account.microsoft.com")); + return true; + } + case 2148916234: { + emit finished(AccountTaskState::STATE_FAILED_SOFT, + tr("This Microsoft account has not accepted Xbox's Terms of Service. Please login and accept them.")); return true; } default: { From b854c56c8ce5ead25f539e334bf4c757ff871ac1 Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Tripon Date: Tue, 31 Oct 2023 08:43:26 +0200 Subject: [PATCH 08/30] Update launcher/minecraft/auth/steps/XboxAuthorizationStep.cpp Co-authored-by: Tayou Signed-off-by: Alexandru Ionut Tripon --- launcher/minecraft/auth/steps/XboxAuthorizationStep.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher/minecraft/auth/steps/XboxAuthorizationStep.cpp b/launcher/minecraft/auth/steps/XboxAuthorizationStep.cpp index 36a76b870..820e03ec9 100644 --- a/launcher/minecraft/auth/steps/XboxAuthorizationStep.cpp +++ b/launcher/minecraft/auth/steps/XboxAuthorizationStep.cpp @@ -136,7 +136,7 @@ bool XboxAuthorizationStep::processSTSError(QNetworkReply::NetworkError error, Q return true; } case 2148916237: - emit finished(AccountTaskState::STATE_FAILED_SOFT, tr("This Microsoft account has reached the its limit for playtime. This " + emit finished(AccountTaskState::STATE_FAILED_SOFT, tr("This Microsoft account has reached its limit for playtime. This " "Microsoft account has been blocked from logging in.")); return true; case 2148916227: { From 7c2a9df98e1570d02a71d964b9114eba38e647e1 Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Tripon Date: Thu, 21 Mar 2024 00:07:06 +0200 Subject: [PATCH 09/30] Update launcher/minecraft/auth/steps/XboxAuthorizationStep.cpp Signed-off-by: Alexandru Ionut Tripon --- launcher/minecraft/auth/steps/XboxAuthorizationStep.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/launcher/minecraft/auth/steps/XboxAuthorizationStep.cpp b/launcher/minecraft/auth/steps/XboxAuthorizationStep.cpp index 820e03ec9..84c52c386 100644 --- a/launcher/minecraft/auth/steps/XboxAuthorizationStep.cpp +++ b/launcher/minecraft/auth/steps/XboxAuthorizationStep.cpp @@ -129,6 +129,7 @@ bool XboxAuthorizationStep::processSTSError(QNetworkReply::NetworkError error, Q .arg("help.minecraft.net")); return true; } + // the following codes where copied from: https://github.com/PrismarineJS/prismarine-auth/pull/44 case 2148916236: { emit finished(AccountTaskState::STATE_FAILED_SOFT, tr("This Microsoft account requires proof of age to play. Please login to %1 to provide proof of age.") From fc4b5205dd8879f01c42ac2039530f63392369de Mon Sep 17 00:00:00 2001 From: Trial97 Date: Sun, 19 Nov 2023 02:02:02 +0200 Subject: [PATCH 10/30] Added all supported files filter Signed-off-by: Trial97 --- launcher/ui/pages/modplatform/ImportPage.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/launcher/ui/pages/modplatform/ImportPage.cpp b/launcher/ui/pages/modplatform/ImportPage.cpp index ba53d0330..df7cfb1af 100644 --- a/launcher/ui/pages/modplatform/ImportPage.cpp +++ b/launcher/ui/pages/modplatform/ImportPage.cpp @@ -134,7 +134,9 @@ void ImportPage::setUrl(const QString& url) void ImportPage::on_modpackBtn_clicked() { - auto filter = QMimeDatabase().mimeTypeForName("application/zip").filterString(); + auto filter = + tr("Supported files") + QString(" (%1 *.mrpack)").arg(QMimeDatabase().mimeTypeForName("application/zip").globPatterns().join(" ")); + filter += ";;" + QMimeDatabase().mimeTypeForName("application/zip").filterString(); //: Option for filtering for *.mrpack files when importing filter += ";;" + tr("Modrinth pack") + " (*.mrpack)"; const QUrl url = QFileDialog::getOpenFileUrl(this, tr("Choose modpack"), modpackUrl(), filter); From f9df20aae33a590c4d9f3ccf265c28e1cec64e78 Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Tripon Date: Sun, 19 Nov 2023 15:26:47 +0200 Subject: [PATCH 11/30] Update launcher/ui/pages/modplatform/ImportPage.cpp Co-authored-by: TheKodeToad Signed-off-by: Alexandru Ionut Tripon --- launcher/ui/pages/modplatform/ImportPage.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/launcher/ui/pages/modplatform/ImportPage.cpp b/launcher/ui/pages/modplatform/ImportPage.cpp index df7cfb1af..9c1fbbf54 100644 --- a/launcher/ui/pages/modplatform/ImportPage.cpp +++ b/launcher/ui/pages/modplatform/ImportPage.cpp @@ -134,9 +134,10 @@ void ImportPage::setUrl(const QString& url) void ImportPage::on_modpackBtn_clicked() { - auto filter = - tr("Supported files") + QString(" (%1 *.mrpack)").arg(QMimeDatabase().mimeTypeForName("application/zip").globPatterns().join(" ")); - filter += ";;" + QMimeDatabase().mimeTypeForName("application/zip").filterString(); + const QMimeType zip = QMimeDatabase().mimeTypeForName("application/zip"); + const QString filter = + tr("Supported files") + QString(" (%1 *.mrpack)").arg(zip.globPatterns().join(" ")); + filter += ";;" + zip.filterString(); //: Option for filtering for *.mrpack files when importing filter += ";;" + tr("Modrinth pack") + " (*.mrpack)"; const QUrl url = QFileDialog::getOpenFileUrl(this, tr("Choose modpack"), modpackUrl(), filter); From d262a081c5e81d4acfdf959b4ee2b6931774e4dc Mon Sep 17 00:00:00 2001 From: Trial97 Date: Sun, 19 Nov 2023 15:37:18 +0200 Subject: [PATCH 12/30] fixed const stuff Signed-off-by: Trial97 --- launcher/ui/pages/modplatform/ImportPage.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/launcher/ui/pages/modplatform/ImportPage.cpp b/launcher/ui/pages/modplatform/ImportPage.cpp index 9c1fbbf54..16b439783 100644 --- a/launcher/ui/pages/modplatform/ImportPage.cpp +++ b/launcher/ui/pages/modplatform/ImportPage.cpp @@ -134,9 +134,8 @@ void ImportPage::setUrl(const QString& url) void ImportPage::on_modpackBtn_clicked() { - const QMimeType zip = QMimeDatabase().mimeTypeForName("application/zip"); - const QString filter = - tr("Supported files") + QString(" (%1 *.mrpack)").arg(zip.globPatterns().join(" ")); + const QMimeType zip = QMimeDatabase().mimeTypeForName("application/zip"); + auto filter = tr("Supported files") + QString(" (%1 *.mrpack)").arg(zip.globPatterns().join(" ")); filter += ";;" + zip.filterString(); //: Option for filtering for *.mrpack files when importing filter += ";;" + tr("Modrinth pack") + " (*.mrpack)"; From 0a3b85dbc5e1065e04fb3fa9b545249133e4deb7 Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Wed, 3 Apr 2024 21:04:26 +0200 Subject: [PATCH 13/30] fix(nix): add jdk21 Signed-off-by: Sefa Eyeoglu (cherry picked from commit 0d372d2fbfd76b54f156faeca6a31fff80875999) --- nix/pkg/wrapper.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nix/pkg/wrapper.nix b/nix/pkg/wrapper.nix index cd356c8d7..1bcff1f9b 100644 --- a/nix/pkg/wrapper.nix +++ b/nix/pkg/wrapper.nix @@ -15,6 +15,7 @@ openal, jdk8, jdk17, + jdk21, gamemode, flite, mesa-demos, @@ -24,7 +25,7 @@ gamemodeSupport ? stdenv.isLinux, textToSpeechSupport ? stdenv.isLinux, controllerSupport ? stdenv.isLinux, - jdks ? [jdk17 jdk8], + jdks ? [jdk21 jdk17 jdk8], additionalLibs ? [], additionalPrograms ? [], }: let From 17d5d78a5bc96ed953e17f270fdc85edcba8897f Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Fri, 5 Apr 2024 23:12:31 +0100 Subject: [PATCH 14/30] Replace invalid characters when extracting ZIP Signed-off-by: TheKodeToad (cherry picked from commit 8056a2fa460b11739b080d96deda35cd8897c40c) --- launcher/FileSystem.cpp | 19 ++++++++++++++----- launcher/FileSystem.h | 2 ++ launcher/MMCZip.cpp | 5 ++++- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/launcher/FileSystem.cpp b/launcher/FileSystem.cpp index f9be91a2a..7bfa24de9 100644 --- a/launcher/FileSystem.cpp +++ b/launcher/FileSystem.cpp @@ -801,15 +801,24 @@ QString NormalizePath(QString path) } } -QString badFilenameChars = "\"\\/?<>:;*|!+\r\n"; +static const QString BAD_PATH_CHARS = "\"?<>:;*|!+\r\n"; +static const QString BAD_FILENAME_CHARS = BAD_PATH_CHARS + "\\/"; QString RemoveInvalidFilenameChars(QString string, QChar replaceWith) { - for (int i = 0; i < string.length(); i++) { - if (badFilenameChars.contains(string[i])) { + for (int i = 0; i < string.length(); i++) + if (string.at(i).toLatin1() < ' ' || BAD_FILENAME_CHARS.contains(string.at(i))) string[i] = replaceWith; - } - } + + return string; +} + +QString RemoveInvalidPathChars(QString string, QChar replaceWith) +{ + for (int i = 0; i < string.length(); i++) + if (string.at(i) < ' ' || BAD_PATH_CHARS.contains(string.at(i))) + string[i] = replaceWith; + return string; } diff --git a/launcher/FileSystem.h b/launcher/FileSystem.h index f13fb9f28..1c9ba2672 100644 --- a/launcher/FileSystem.h +++ b/launcher/FileSystem.h @@ -342,6 +342,8 @@ QString NormalizePath(QString path); QString RemoveInvalidFilenameChars(QString string, QChar replaceWith = '-'); +QString RemoveInvalidPathChars(QString string, QChar replaceWith = '-'); + QString DirNameFromString(QString string, QString inDir = "."); /// Checks if the a given Path contains "!" diff --git a/launcher/MMCZip.cpp b/launcher/MMCZip.cpp index ce2573329..6c77e7f1a 100644 --- a/launcher/MMCZip.cpp +++ b/launcher/MMCZip.cpp @@ -286,10 +286,13 @@ std::optional extractSubDir(QuaZip* zip, const QString& subdir, con do { QString file_name = zip->getCurrentFileName(); +#ifdef Q_OS_WIN + file_name = FS::RemoveInvalidPathChars(file_name); +#endif if (!file_name.startsWith(subdir)) continue; - auto relative_file_name = QDir::fromNativeSeparators(file_name.remove(0, subdir.size())); + auto relative_file_name = QDir::fromNativeSeparators(file_name.mid(subdir.size())); auto original_name = relative_file_name; // Fix subdirs/files ending with a / getting transformed into absolute paths From 1e5a29c423194758286aed6ffbf83fb6c1e41f66 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Wed, 3 Apr 2024 19:34:35 +0300 Subject: [PATCH 15/30] Fixed crash on non-latin instance name Signed-off-by: Trial97 (cherry picked from commit 450b73328e20941eba12be3b7c7f8bb13dc0f944) --- .../minecraft/launch/LauncherPartLaunch.cpp | 26 ++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/launcher/minecraft/launch/LauncherPartLaunch.cpp b/launcher/minecraft/launch/LauncherPartLaunch.cpp index aa94edb5d..dcfb3d148 100644 --- a/launcher/minecraft/launch/LauncherPartLaunch.cpp +++ b/launcher/minecraft/launch/LauncherPartLaunch.cpp @@ -74,16 +74,36 @@ QString shortPathName(const QString& file) auto input = file.toStdWString(); std::wstring output; long length = GetShortPathNameW(input.c_str(), NULL, 0); + if (length == 0) + return {}; // NOTE: this resizing might seem weird... // when GetShortPathNameW fails, it returns length including null character // when it succeeds, it returns length excluding null character // See: https://msdn.microsoft.com/en-us/library/windows/desktop/aa364989(v=vs.85).aspx output.resize(length); - GetShortPathNameW(input.c_str(), (LPWSTR)output.c_str(), length); + if (GetShortPathNameW(input.c_str(), (LPWSTR)output.c_str(), length) == 0) + return {}; output.resize(length - 1); QString ret = QString::fromStdWString(output); return ret; } + +QString getShortPathName(const QString& file) +{ + auto path = shortPathName(file); + if (!path.isEmpty()) + return path; + // the path can not be getted due to the file/folder not existing + // so create the parrent folder + // and assume that we can concatenate the short path of the parent folder with the file name + // usually the 8 bit characters are in the instance name not in the name of the end files/folders we need + FS::ensureFilePathExists(file); + QFileInfo a(file); + auto partialShortPath = shortPathName(a.path()); + if (!partialShortPath.isEmpty()) + return FS::PathCombine(partialShortPath, a.fileName()); + return file; +} #endif // if the string survives roundtrip through local 8bit encoding... @@ -137,7 +157,7 @@ void LauncherPartLaunch::executeTask() auto natPath = minecraftInstance->getNativePath(); #ifdef Q_OS_WIN if (!fitsInLocal8bit(natPath)) { - args << "-Djava.library.path=" + shortPathName(natPath); + args << "-Djava.library.path=" + getShortPathName(natPath); } else { args << "-Djava.library.path=" + natPath; } @@ -150,7 +170,7 @@ void LauncherPartLaunch::executeTask() QStringList processed; for (auto& item : classPath) { if (!fitsInLocal8bit(item)) { - processed << shortPathName(item); + processed << getShortPathName(item); } else { processed << item; } From 3e5e131a94387823efc26c6b4186ea9dbad48d62 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Thu, 4 Apr 2024 13:49:27 +0300 Subject: [PATCH 16/30] Moved the creation of natives folder in ExtractNatives task Signed-off-by: Trial97 (cherry picked from commit 8ecab305ac67afb70a278d286df13cc85134dec2) --- launcher/minecraft/launch/ExtractNatives.cpp | 1 + launcher/minecraft/launch/ExtractNatives.h | 2 -- .../minecraft/launch/LauncherPartLaunch.cpp | 36 ++++++------------- 3 files changed, 12 insertions(+), 27 deletions(-) diff --git a/launcher/minecraft/launch/ExtractNatives.cpp b/launcher/minecraft/launch/ExtractNatives.cpp index 8f3cac4d1..405008f40 100644 --- a/launcher/minecraft/launch/ExtractNatives.cpp +++ b/launcher/minecraft/launch/ExtractNatives.cpp @@ -79,6 +79,7 @@ void ExtractNatives::executeTask() auto settings = minecraftInstance->settings(); auto outputPath = minecraftInstance->getNativePath(); + FS::ensureFolderPathExists(outputPath); auto javaVersion = minecraftInstance->getJavaVersion(); bool jniHackEnabled = javaVersion.major() >= 8; for (const auto& source : toExtract) { diff --git a/launcher/minecraft/launch/ExtractNatives.h b/launcher/minecraft/launch/ExtractNatives.h index 2ab8816bd..4837a9dbb 100644 --- a/launcher/minecraft/launch/ExtractNatives.h +++ b/launcher/minecraft/launch/ExtractNatives.h @@ -16,8 +16,6 @@ #pragma once #include -#include -#include "minecraft/auth/AuthSession.h" // FIXME: temporary wrapper for existing task. class ExtractNatives : public LaunchStep { diff --git a/launcher/minecraft/launch/LauncherPartLaunch.cpp b/launcher/minecraft/launch/LauncherPartLaunch.cpp index dcfb3d148..3662f2bb6 100644 --- a/launcher/minecraft/launch/LauncherPartLaunch.cpp +++ b/launcher/minecraft/launch/LauncherPartLaunch.cpp @@ -88,20 +88,15 @@ QString shortPathName(const QString& file) return ret; } -QString getShortPathName(const QString& file) +QString getPathNameInLocal8bit(const QString& file) { - auto path = shortPathName(file); - if (!path.isEmpty()) - return path; - // the path can not be getted due to the file/folder not existing - // so create the parrent folder - // and assume that we can concatenate the short path of the parent folder with the file name - // usually the 8 bit characters are in the instance name not in the name of the end files/folders we need - FS::ensureFilePathExists(file); - QFileInfo a(file); - auto partialShortPath = shortPathName(a.path()); - if (!partialShortPath.isEmpty()) - return FS::PathCombine(partialShortPath, a.fileName()); + if (!fitsInLocal8bit(file)) { + auto path = shortPathName(file); + if (!path.isEmpty()) { + return path; + } + // in case shortPathName fails just return the path as is + } return file; } #endif @@ -156,24 +151,15 @@ void LauncherPartLaunch::executeTask() auto natPath = minecraftInstance->getNativePath(); #ifdef Q_OS_WIN - if (!fitsInLocal8bit(natPath)) { - args << "-Djava.library.path=" + getShortPathName(natPath); - } else { - args << "-Djava.library.path=" + natPath; - } -#else - args << "-Djava.library.path=" + natPath; + natPath = getPathNameInLocal8bit(natPath); #endif + args << "-Djava.library.path=" + natPath; args << "-cp"; #ifdef Q_OS_WIN QStringList processed; for (auto& item : classPath) { - if (!fitsInLocal8bit(item)) { - processed << getShortPathName(item); - } else { - processed << item; - } + processed << getPathNameInLocal8bit(item); } args << processed.join(';'); #else From b2cca30cd918b8c4e87411c4bf67932f9e340ebf Mon Sep 17 00:00:00 2001 From: Trial97 Date: Thu, 4 Apr 2024 18:01:24 +0300 Subject: [PATCH 17/30] Moved getPathNameInLocal8bit inside FileSystem namespace Signed-off-by: Trial97 (cherry picked from commit 3ddcadcdd1f72f8135333986e55cf583204da1e2) --- launcher/FileSystem.cpp | 40 +++++++++++++++++ launcher/FileSystem.h | 4 ++ launcher/InstanceImportTask.h | 4 -- launcher/java/JavaChecker.cpp | 3 ++ .../minecraft/launch/LauncherPartLaunch.cpp | 45 +------------------ 5 files changed, 49 insertions(+), 47 deletions(-) diff --git a/launcher/FileSystem.cpp b/launcher/FileSystem.cpp index 7bfa24de9..b909ad614 100644 --- a/launcher/FileSystem.cpp +++ b/launcher/FileSystem.cpp @@ -1594,4 +1594,44 @@ uintmax_t hardLinkCount(const QString& path) return count; } +#ifdef Q_OS_WIN +// returns 8.3 file format from long path +QString shortPathName(const QString& file) +{ + auto input = file.toStdWString(); + std::wstring output; + long length = GetShortPathNameW(input.c_str(), NULL, 0); + if (length == 0) + return {}; + // NOTE: this resizing might seem weird... + // when GetShortPathNameW fails, it returns length including null character + // when it succeeds, it returns length excluding null character + // See: https://msdn.microsoft.com/en-us/library/windows/desktop/aa364989(v=vs.85).aspx + output.resize(length); + if (GetShortPathNameW(input.c_str(), (LPWSTR)output.c_str(), length) == 0) + return {}; + output.resize(length - 1); + QString ret = QString::fromStdWString(output); + return ret; +} + +// if the string survives roundtrip through local 8bit encoding... +bool fitsInLocal8bit(const QString& string) +{ + return string == QString::fromLocal8Bit(string.toLocal8Bit()); +} + +QString getPathNameInLocal8bit(const QString& file) +{ + if (!fitsInLocal8bit(file)) { + auto path = shortPathName(file); + if (!path.isEmpty()) { + return path; + } + // in case shortPathName fails just return the path as is + } + return file; +} +#endif + } // namespace FS diff --git a/launcher/FileSystem.h b/launcher/FileSystem.h index 1c9ba2672..5496c3795 100644 --- a/launcher/FileSystem.h +++ b/launcher/FileSystem.h @@ -553,4 +553,8 @@ bool canLink(const QString& src, const QString& dst); uintmax_t hardLinkCount(const QString& path); +#ifdef Q_OS_WIN +QString getPathNameInLocal8bit(const QString& file); +#endif + } // namespace FS diff --git a/launcher/InstanceImportTask.h b/launcher/InstanceImportTask.h index a1cf2560b..28efd7ec5 100644 --- a/launcher/InstanceImportTask.h +++ b/launcher/InstanceImportTask.h @@ -47,9 +47,6 @@ #include class QuaZip; -namespace Flame { -class FileResolvingTask; -} class InstanceImportTask : public InstanceTask { Q_OBJECT @@ -79,7 +76,6 @@ class InstanceImportTask : public InstanceTask { private: /* data */ NetJob::Ptr m_filesNetJob; - shared_qobject_ptr m_modIdResolver; QUrl m_sourceUrl; QString m_archivePath; bool m_downloadRequired = false; diff --git a/launcher/java/JavaChecker.cpp b/launcher/java/JavaChecker.cpp index 20caba189..fc8da55c2 100644 --- a/launcher/java/JavaChecker.cpp +++ b/launcher/java/JavaChecker.cpp @@ -55,6 +55,9 @@ void JavaChecker::performCheck() qDebug() << "Java checker library could not be found. Please check your installation."; return; } +#ifdef Q_OS_WIN + checkerJar = FS::getPathNameInLocal8bit(checkerJar); +#endif QStringList args; diff --git a/launcher/minecraft/launch/LauncherPartLaunch.cpp b/launcher/minecraft/launch/LauncherPartLaunch.cpp index 3662f2bb6..4e021c4a8 100644 --- a/launcher/minecraft/launch/LauncherPartLaunch.cpp +++ b/launcher/minecraft/launch/LauncherPartLaunch.cpp @@ -66,47 +66,6 @@ LauncherPartLaunch::LauncherPartLaunch(LaunchTask* parent) : LaunchStep(parent) connect(&m_process, &LoggedProcess::stateChanged, this, &LauncherPartLaunch::on_state); } -#ifdef Q_OS_WIN -// returns 8.3 file format from long path -#include -QString shortPathName(const QString& file) -{ - auto input = file.toStdWString(); - std::wstring output; - long length = GetShortPathNameW(input.c_str(), NULL, 0); - if (length == 0) - return {}; - // NOTE: this resizing might seem weird... - // when GetShortPathNameW fails, it returns length including null character - // when it succeeds, it returns length excluding null character - // See: https://msdn.microsoft.com/en-us/library/windows/desktop/aa364989(v=vs.85).aspx - output.resize(length); - if (GetShortPathNameW(input.c_str(), (LPWSTR)output.c_str(), length) == 0) - return {}; - output.resize(length - 1); - QString ret = QString::fromStdWString(output); - return ret; -} - -QString getPathNameInLocal8bit(const QString& file) -{ - if (!fitsInLocal8bit(file)) { - auto path = shortPathName(file); - if (!path.isEmpty()) { - return path; - } - // in case shortPathName fails just return the path as is - } - return file; -} -#endif - -// if the string survives roundtrip through local 8bit encoding... -bool fitsInLocal8bit(const QString& string) -{ - return string == QString::fromLocal8Bit(string.toLocal8Bit()); -} - void LauncherPartLaunch::executeTask() { QString jarPath = APPLICATION->getJarPath("NewLaunch.jar"); @@ -151,7 +110,7 @@ void LauncherPartLaunch::executeTask() auto natPath = minecraftInstance->getNativePath(); #ifdef Q_OS_WIN - natPath = getPathNameInLocal8bit(natPath); + natPath = FS::getPathNameInLocal8bit(natPath); #endif args << "-Djava.library.path=" + natPath; @@ -159,7 +118,7 @@ void LauncherPartLaunch::executeTask() #ifdef Q_OS_WIN QStringList processed; for (auto& item : classPath) { - processed << getPathNameInLocal8bit(item); + processed << FS::getPathNameInLocal8bit(item); } args << processed.join(';'); #else From e43341ce92794164603c560d862bb776bb4a25db Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Sat, 6 Apr 2024 13:28:42 +0100 Subject: [PATCH 18/30] Fix unicode characters being invalid in filenames Signed-off-by: TheKodeToad (cherry picked from commit 9986fe4c45be7f3ce22fdce64812677f16cf7b4c) --- launcher/FileSystem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher/FileSystem.cpp b/launcher/FileSystem.cpp index b909ad614..70704e1d3 100644 --- a/launcher/FileSystem.cpp +++ b/launcher/FileSystem.cpp @@ -807,7 +807,7 @@ static const QString BAD_FILENAME_CHARS = BAD_PATH_CHARS + "\\/"; QString RemoveInvalidFilenameChars(QString string, QChar replaceWith) { for (int i = 0; i < string.length(); i++) - if (string.at(i).toLatin1() < ' ' || BAD_FILENAME_CHARS.contains(string.at(i))) + if (string.at(i) < ' ' || BAD_FILENAME_CHARS.contains(string.at(i))) string[i] = replaceWith; return string; From d9b133a28d6d0f98eb78991fb81c7a7cdba9d17f Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Tue, 19 Mar 2024 20:34:55 +0000 Subject: [PATCH 19/30] Use UTF-8 for ZIP creation Signed-off-by: TheKodeToad (cherry picked from commit d72bd70c055d23223ee78fa62e6ae4ccfcb490d7) --- launcher/MMCZip.cpp | 2 ++ launcher/MMCZip.h | 1 + 2 files changed, 3 insertions(+) diff --git a/launcher/MMCZip.cpp b/launcher/MMCZip.cpp index 6c77e7f1a..145dd77ad 100644 --- a/launcher/MMCZip.cpp +++ b/launcher/MMCZip.cpp @@ -119,6 +119,7 @@ bool compressDirFiles(QuaZip* zip, QString dir, QFileInfoList files, bool follow bool compressDirFiles(QString fileCompressed, QString dir, QFileInfoList files, bool followSymlinks) { QuaZip zip(fileCompressed); + zip.setUtf8Enabled(true); QDir().mkpath(QFileInfo(fileCompressed).absolutePath()); if (!zip.open(QuaZip::mdCreate)) { QFile::remove(fileCompressed); @@ -141,6 +142,7 @@ bool compressDirFiles(QString fileCompressed, QString dir, QFileInfoList files, bool createModdedJar(QString sourceJarPath, QString targetJarPath, const QList& mods) { QuaZip zipOut(targetJarPath); + zipOut.setUtf8Enabled(true); if (!zipOut.open(QuaZip::mdCreate)) { QFile::remove(targetJarPath); qCritical() << "Failed to open the minecraft.jar for modding"; diff --git a/launcher/MMCZip.h b/launcher/MMCZip.h index 93692d0d2..43b4ab933 100644 --- a/launcher/MMCZip.h +++ b/launcher/MMCZip.h @@ -163,6 +163,7 @@ class ExportToZipTask : public Task { , m_follow_symlinks(followSymlinks) { setAbortable(true); + m_output.setUtf8Enabled(true); }; ExportToZipTask(QString outputPath, QString dir, QFileInfoList files, QString destinationPrefix = "", bool followSymlinks = false) : ExportToZipTask(outputPath, QDir(dir), files, destinationPrefix, followSymlinks){}; From f221b08f11b56c1185b3c23d0e256ac1526b95c2 Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Sat, 6 Apr 2024 15:12:41 +0200 Subject: [PATCH 20/30] chore: bump to 8.3 Signed-off-by: Sefa Eyeoglu --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9f808ec87..c70b79051 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -179,7 +179,7 @@ set(Launcher_HELP_URL "https://prismlauncher.org/wiki/help-pages/%1" CACHE STRIN ######## Set version numbers ######## set(Launcher_VERSION_MAJOR 8) -set(Launcher_VERSION_MINOR 2) +set(Launcher_VERSION_MINOR 3) set(Launcher_VERSION_NAME "${Launcher_VERSION_MAJOR}.${Launcher_VERSION_MINOR}") set(Launcher_VERSION_NAME4 "${Launcher_VERSION_MAJOR}.${Launcher_VERSION_MINOR}.0.0") From 95cfcedc966d2540127a373908602622be9e7bfe Mon Sep 17 00:00:00 2001 From: DioEgizio <83089242+DioEgizio@users.noreply.github.com> Date: Sat, 6 Apr 2024 20:21:43 +0200 Subject: [PATCH 21/30] chore: update to qt 6.6.3 on 8.x qt bug fix release Signed-off-by: DioEgizio <83089242+DioEgizio@users.noreply.github.com> --- .github/workflows/build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 25038d572..fa6ea9bcd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -76,7 +76,7 @@ jobs: qt_ver: 6 qt_host: windows qt_arch: '' - qt_version: '6.6.2' + qt_version: '6.6.3' qt_modules: 'qt5compat qtimageformats' qt_tools: '' @@ -88,7 +88,7 @@ jobs: qt_ver: 6 qt_host: windows qt_arch: 'win64_msvc2019_arm64' - qt_version: '6.6.2' + qt_version: '6.6.3' qt_modules: 'qt5compat qtimageformats' qt_tools: '' @@ -98,7 +98,7 @@ jobs: qt_ver: 6 qt_host: mac qt_arch: '' - qt_version: '6.6.2' + qt_version: '6.6.3' qt_modules: 'qt5compat qtimageformats' qt_tools: '' From 1a44258c9d6b16aa34df8be42f9ad167fc249c21 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Sun, 7 Apr 2024 21:25:08 +0300 Subject: [PATCH 22/30] Fixed crash on invalid curseforge link on import Signed-off-by: Trial97 (cherry picked from commit 9cc58fe62c776dd206bb6dd99c886ce491662214) --- launcher/ui/pages/modplatform/ImportPage.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/launcher/ui/pages/modplatform/ImportPage.cpp b/launcher/ui/pages/modplatform/ImportPage.cpp index ae4bd49d7..ed7ebfad9 100644 --- a/launcher/ui/pages/modplatform/ImportPage.cpp +++ b/launcher/ui/pages/modplatform/ImportPage.cpp @@ -123,6 +123,10 @@ void ImportPage::updateState() // need to find the download link for the modpack // format of url curseforge://install?addonId=IDHERE&fileId=IDHERE QUrlQuery query(url); + if (query.allQueryItemValues("addonId").isEmpty() || query.allQueryItemValues("fileId").isEmpty()) { + qDebug() << "Invalid curseforge link:" << url; + return; + } auto addonId = query.allQueryItemValues("addonId")[0]; auto fileId = query.allQueryItemValues("fileId")[0]; auto array = std::make_shared(); From 160c8cb70d4f8841acee276ccb0bd11912bf89e8 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Tue, 9 Apr 2024 08:28:09 +0300 Subject: [PATCH 23/30] Fixed application close on open file dialog Signed-off-by: Trial97 (cherry picked from commit 9f48694eb2be5f62efb122b554c7066e49f3383d) --- launcher/Application.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/launcher/Application.cpp b/launcher/Application.cpp index 0f7548853..db3487726 100644 --- a/launcher/Application.cpp +++ b/launcher/Application.cpp @@ -225,6 +225,7 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv) // Don't quit on hiding the last window this->setQuitOnLastWindowClosed(false); + this->setQuitLockEnabled(false); // Commandline parsing QCommandLineParser parser; From 7960282e07ca1a378507aa4e1efaaef9823b521c Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Fri, 19 Apr 2024 21:19:36 +0100 Subject: [PATCH 24/30] Support neoforge.mods.toml Signed-off-by: TheKodeToad (cherry picked from commit 252406ba3e793b4b096ed1e7bde43c2d2a9c2eca) --- launcher/minecraft/mod/tasks/LocalModParseTask.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher/minecraft/mod/tasks/LocalModParseTask.cpp b/launcher/minecraft/mod/tasks/LocalModParseTask.cpp index e9e12d86a..3982f3338 100644 --- a/launcher/minecraft/mod/tasks/LocalModParseTask.cpp +++ b/launcher/minecraft/mod/tasks/LocalModParseTask.cpp @@ -469,7 +469,7 @@ bool processZIP(Mod& mod, [[maybe_unused]] ProcessingLevel level) QuaZipFile file(&zip); - if (zip.setCurrentFile("META-INF/mods.toml")) { + if (zip.setCurrentFile("META-INF/mods.toml") || zip.setCurrentFile("META-INF/neoforge.mods.toml")) { if (!file.open(QIODevice::ReadOnly)) { zip.close(); return false; From 47bd02637af5188c4a6a838bed813bad9112955e Mon Sep 17 00:00:00 2001 From: William Gray Date: Sun, 21 Apr 2024 03:35:27 -0500 Subject: [PATCH 25/30] Update JavaUtils.cpp Signed-off-by: William Gray (cherry picked from commit 9f4654ede91a81a3d1099c949164690e295995a4) --- launcher/java/JavaUtils.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/launcher/java/JavaUtils.cpp b/launcher/java/JavaUtils.cpp index 074bf54df..639eaf4e7 100644 --- a/launcher/java/JavaUtils.cpp +++ b/launcher/java/JavaUtils.cpp @@ -413,6 +413,8 @@ QList JavaUtils::FindJavaPaths() scanJavaDirs(FS::PathCombine(home, ".jdks")); // javas downloaded by sdkman scanJavaDirs(FS::PathCombine(home, ".sdkman/candidates/java")); + // javas downloaded by gradle (toolchains) + scanJavaDirs(FS::PathCombine(home, ".gradle/jdks")); javas.append(getMinecraftJavaBundle()); javas = addJavasFromEnv(javas); From 565c7d81b3c6f93b020680ba161789da32641910 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Sun, 21 Apr 2024 14:48:27 +0300 Subject: [PATCH 26/30] Removed java from appimage Signed-off-by: Trial97 --- .github/scripts/prepare_JREs.sh | 41 --------------------------------- .github/workflows/build.yml | 11 +-------- 2 files changed, 1 insertion(+), 51 deletions(-) delete mode 100755 .github/scripts/prepare_JREs.sh diff --git a/.github/scripts/prepare_JREs.sh b/.github/scripts/prepare_JREs.sh deleted file mode 100755 index ee713f81f..000000000 --- a/.github/scripts/prepare_JREs.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env bash - -URL_JDK8="https://api.adoptium.net/v3/binary/version/jdk8u312-b07/linux/x64/jre/hotspot/normal/eclipse" -URL_JDK17="https://api.adoptium.net/v3/binary/latest/17/ga/linux/x64/jre/hotspot/normal/eclipse" - -mkdir -p JREs -pushd JREs - -wget --content-disposition "$URL_JDK8" -wget --content-disposition "$URL_JDK17" - -for file in *; -do - mkdir temp - - re='(OpenJDK([[:digit:]]+)U-jre_x64_linux_hotspot_([[:digit:]]+)(.*).tar.gz)' - if [[ $file =~ $re ]]; - then - version_major=${BASH_REMATCH[2]} - version_trailing=${BASH_REMATCH[4]} - - if [ $version_major = 17 ]; - then - hyphen='-' - else - hyphen='' - fi - - version_edit=$(echo $version_trailing | sed -e 's/_/+/g' | sed -e 's/b/-b/g') - dir_name=jdk$hyphen$version_major$version_edit-jre - mkdir jre$version_major - tar -xzf $file -C temp - pushd temp/$dir_name - cp -r . ../../jre$version_major - popd - fi - - rm -rf temp -done - -popd diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fa6ea9bcd..078ae7877 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -259,7 +259,6 @@ jobs: wget "https://github.com/AppImageCommunity/AppImageUpdate/releases/download/continuous/AppImageUpdate-x86_64.AppImage" - ${{ github.workspace }}/.github/scripts/prepare_JREs.sh sudo apt install libopengl0 - name: Add QT_HOST_PATH var (Windows MSVC arm64) @@ -528,13 +527,9 @@ jobs: chmod +x linuxdeploy-*.AppImage - mkdir -p ${{ env.INSTALL_APPIMAGE_DIR }}/usr/lib/jvm/java-{8,17}-openjdk + mkdir -p ${{ env.INSTALL_APPIMAGE_DIR }}/usr/lib mkdir -p ${{ env.INSTALL_APPIMAGE_DIR }}/usr/plugins/iconengines - cp -r ${{ github.workspace }}/JREs/jre8/* ${{ env.INSTALL_APPIMAGE_DIR }}/usr/lib/jvm/java-8-openjdk - - cp -r ${{ github.workspace }}/JREs/jre17/* ${{ env.INSTALL_APPIMAGE_DIR }}/usr/lib/jvm/java-17-openjdk - cp -r ${{ runner.workspace }}/Qt/${{ matrix.qt_version }}/gcc_64/plugins/iconengines/* ${{ env.INSTALL_APPIMAGE_DIR }}/usr/plugins/iconengines cp /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1 ${{ env.INSTALL_APPIMAGE_DIR }}/usr/lib/ @@ -542,10 +537,6 @@ jobs: cp /usr/lib/x86_64-linux-gnu/libOpenGL.so.0* ${{ env.INSTALL_APPIMAGE_DIR }}/usr/lib/ LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${{ env.INSTALL_APPIMAGE_DIR }}/usr/lib" - LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${{ env.INSTALL_APPIMAGE_DIR }}/usr/lib/jvm/java-8-openjdk/lib/amd64/server" - LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${{ env.INSTALL_APPIMAGE_DIR }}/usr/lib/jvm/java-8-openjdk/lib/amd64" - LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${{ env.INSTALL_APPIMAGE_DIR }}/usr/lib/jvm/java-17-openjdk/lib/server" - LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${{ env.INSTALL_APPIMAGE_DIR }}/usr/lib/jvm/java-17-openjdk/lib" export LD_LIBRARY_PATH chmod +x AppImageUpdate-x86_64.AppImage From c330452e84704eec578747820fbefecea0f3015a Mon Sep 17 00:00:00 2001 From: Trial97 Date: Tue, 23 Apr 2024 08:52:17 +0300 Subject: [PATCH 27/30] Fix bundled java detection on mac Signed-off-by: Trial97 (cherry picked from commit dbfd535b38d799a773b3843709bbeae7f5a9e7d3) --- launcher/java/JavaUtils.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/launcher/java/JavaUtils.cpp b/launcher/java/JavaUtils.cpp index 639eaf4e7..35d9ec610 100644 --- a/launcher/java/JavaUtils.cpp +++ b/launcher/java/JavaUtils.cpp @@ -441,13 +441,13 @@ QString JavaUtils::getJavaCheckPath() QStringList getMinecraftJavaBundle() { - QString partialPath; QString executable = "java"; QStringList processpaths; #if defined(Q_OS_OSX) - partialPath = FS::PathCombine(QDir::homePath(), "Library/Application Support"); + processpaths << FS::PathCombine(QDir::homePath(), FS::PathCombine("Library", "Application Support", "minecraft", "runtime")); #elif defined(Q_OS_WIN32) - partialPath = QProcessEnvironment::systemEnvironment().value("LOCALAPPDATA", ""); + QString partialPath = QProcessEnvironment::systemEnvironment().value("LOCALAPPDATA", ""); + processpaths << FS::PathCombine(partialPath, ".minecraft", "runtime"); executable += "w.exe"; // add the microsoft store version of the launcher to the search. the current path is: @@ -457,10 +457,8 @@ QStringList getMinecraftJavaBundle() minecraftMSStorePath = FS::PathCombine(minecraftMSStorePath, "LocalCache", "Local", "runtime"); processpaths << minecraftMSStorePath; #else - partialPath = QDir::homePath(); + processpaths << FS::PathCombine(QDir::homePath(), ".minecraft", "runtime"); #endif - auto minecraftDataPath = FS::PathCombine(partialPath, ".minecraft", "runtime"); - processpaths << minecraftDataPath; QStringList javas; while (!processpaths.isEmpty()) { From 877de6da40ab7fc0f06cf1e720e43fde56194d3f Mon Sep 17 00:00:00 2001 From: Trial97 Date: Tue, 23 Apr 2024 18:59:31 +0300 Subject: [PATCH 28/30] Fixed windows appdata path Signed-off-by: Trial97 (cherry picked from commit dac70278462913b7c0191c56a04e62529d5c774b) --- launcher/java/JavaUtils.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/launcher/java/JavaUtils.cpp b/launcher/java/JavaUtils.cpp index 35d9ec610..d1d58b0cf 100644 --- a/launcher/java/JavaUtils.cpp +++ b/launcher/java/JavaUtils.cpp @@ -446,16 +446,16 @@ QStringList getMinecraftJavaBundle() #if defined(Q_OS_OSX) processpaths << FS::PathCombine(QDir::homePath(), FS::PathCombine("Library", "Application Support", "minecraft", "runtime")); #elif defined(Q_OS_WIN32) - QString partialPath = QProcessEnvironment::systemEnvironment().value("LOCALAPPDATA", ""); - processpaths << FS::PathCombine(partialPath, ".minecraft", "runtime"); + auto appDataPath = QProcessEnvironment::systemEnvironment().value("AppData", ""); + processpaths << FS::PathCombine(QFileInfo(appDataPath).absolutePath(), ".minecraft", "runtime"); executable += "w.exe"; // add the microsoft store version of the launcher to the search. the current path is: // C:\Users\USERNAME\AppData\Local\Packages\Microsoft.4297127D64EC6_8wekyb3d8bbwe\LocalCache\Local\runtime + auto localAppDataPath = QProcessEnvironment::systemEnvironment().value("LOCALAPPDATA", ""); auto minecraftMSStorePath = - FS::PathCombine(QFileInfo(partialPath).absolutePath(), "Local", "Packages", "Microsoft.4297127D64EC6_8wekyb3d8bbwe"); - minecraftMSStorePath = FS::PathCombine(minecraftMSStorePath, "LocalCache", "Local", "runtime"); - processpaths << minecraftMSStorePath; + FS::PathCombine(QFileInfo(localAppDataPath).absolutePath(), "Local", "Packages", "Microsoft.4297127D64EC6_8wekyb3d8bbwe"); + processpaths << FS::PathCombine(minecraftMSStorePath, "LocalCache", "Local", "runtime"); #else processpaths << FS::PathCombine(QDir::homePath(), ".minecraft", "runtime"); #endif From 0b535e44e129bb03364df5a1f7b4f106fd111ce3 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Tue, 23 Apr 2024 19:03:19 +0300 Subject: [PATCH 29/30] Changed env variable Signed-off-by: Trial97 (cherry picked from commit 73c3794c1bfa9d3cd01339039ad8597971b5fb53) --- launcher/java/JavaUtils.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/launcher/java/JavaUtils.cpp b/launcher/java/JavaUtils.cpp index d1d58b0cf..c0bb39d72 100644 --- a/launcher/java/JavaUtils.cpp +++ b/launcher/java/JavaUtils.cpp @@ -446,10 +446,11 @@ QStringList getMinecraftJavaBundle() #if defined(Q_OS_OSX) processpaths << FS::PathCombine(QDir::homePath(), FS::PathCombine("Library", "Application Support", "minecraft", "runtime")); #elif defined(Q_OS_WIN32) - auto appDataPath = QProcessEnvironment::systemEnvironment().value("AppData", ""); - processpaths << FS::PathCombine(QFileInfo(appDataPath).absolutePath(), ".minecraft", "runtime"); executable += "w.exe"; + auto appDataPath = QProcessEnvironment::systemEnvironment().value("APPDATA", ""); + processpaths << FS::PathCombine(QFileInfo(appDataPath).absolutePath(), ".minecraft", "runtime"); + // add the microsoft store version of the launcher to the search. the current path is: // C:\Users\USERNAME\AppData\Local\Packages\Microsoft.4297127D64EC6_8wekyb3d8bbwe\LocalCache\Local\runtime auto localAppDataPath = QProcessEnvironment::systemEnvironment().value("LOCALAPPDATA", ""); From f06bd54d6f95f676f6ef68a16fc58ebd8563f9d2 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Tue, 23 Apr 2024 19:08:14 +0300 Subject: [PATCH 30/30] Removed duplicate local Signed-off-by: Trial97 (cherry picked from commit 10d1720da5c350250390fa8b38a5c4db6429462b) --- launcher/java/JavaUtils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher/java/JavaUtils.cpp b/launcher/java/JavaUtils.cpp index c0bb39d72..b12461f44 100644 --- a/launcher/java/JavaUtils.cpp +++ b/launcher/java/JavaUtils.cpp @@ -455,7 +455,7 @@ QStringList getMinecraftJavaBundle() // C:\Users\USERNAME\AppData\Local\Packages\Microsoft.4297127D64EC6_8wekyb3d8bbwe\LocalCache\Local\runtime auto localAppDataPath = QProcessEnvironment::systemEnvironment().value("LOCALAPPDATA", ""); auto minecraftMSStorePath = - FS::PathCombine(QFileInfo(localAppDataPath).absolutePath(), "Local", "Packages", "Microsoft.4297127D64EC6_8wekyb3d8bbwe"); + FS::PathCombine(QFileInfo(localAppDataPath).absolutePath(), "Packages", "Microsoft.4297127D64EC6_8wekyb3d8bbwe"); processpaths << FS::PathCombine(minecraftMSStorePath, "LocalCache", "Local", "runtime"); #else processpaths << FS::PathCombine(QDir::homePath(), ".minecraft", "runtime");