fix: properly parse mrpacks without the 'env' field
It's optional, so some files may not have it (like most of FO).
This commit is contained in:
parent
309013efb3
commit
46e403b20b
@ -582,6 +582,7 @@ void InstanceImportTask::processMultiMC()
|
|||||||
emitSucceeded();
|
emitSucceeded();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://docs.modrinth.com/docs/modpacks/format_definition/
|
||||||
void InstanceImportTask::processModrinth()
|
void InstanceImportTask::processModrinth()
|
||||||
{
|
{
|
||||||
std::vector<Modrinth::File> files;
|
std::vector<Modrinth::File> files;
|
||||||
@ -600,26 +601,30 @@ void InstanceImportTask::processModrinth()
|
|||||||
|
|
||||||
auto jsonFiles = Json::requireIsArrayOf<QJsonObject>(obj, "files", "modrinth.index.json");
|
auto jsonFiles = Json::requireIsArrayOf<QJsonObject>(obj, "files", "modrinth.index.json");
|
||||||
bool had_optional = false;
|
bool had_optional = false;
|
||||||
for (auto& modInfo : jsonFiles) {
|
for (auto modInfo : jsonFiles) {
|
||||||
Modrinth::File file;
|
Modrinth::File file;
|
||||||
file.path = Json::requireString(modInfo, "path");
|
file.path = Json::requireString(modInfo, "path");
|
||||||
|
|
||||||
auto env = Json::ensureObject(modInfo, "env");
|
auto env = Json::ensureObject(modInfo, "env");
|
||||||
QString support = Json::ensureString(env, "client", "unsupported");
|
// 'env' field is optional
|
||||||
if (support == "unsupported") {
|
if (!env.isEmpty()) {
|
||||||
continue;
|
QString support = Json::ensureString(env, "client", "unsupported");
|
||||||
} else if (support == "optional") {
|
if (support == "unsupported") {
|
||||||
// TODO: Make a review dialog for choosing which ones the user wants!
|
continue;
|
||||||
if (!had_optional) {
|
} else if (support == "optional") {
|
||||||
had_optional = true;
|
// TODO: Make a review dialog for choosing which ones the user wants!
|
||||||
auto info = CustomMessageBox::selectable(
|
if (!had_optional) {
|
||||||
m_parent, tr("Optional mod detected!"),
|
had_optional = true;
|
||||||
tr("One or more mods from this modpack are optional. They will be downloaded, but disabled by default!"), QMessageBox::Information);
|
auto info = CustomMessageBox::selectable(
|
||||||
info->exec();
|
m_parent, tr("Optional mod detected!"),
|
||||||
}
|
tr("One or more mods from this modpack are optional. They will be downloaded, but disabled by default!"),
|
||||||
|
QMessageBox::Information);
|
||||||
|
info->exec();
|
||||||
|
}
|
||||||
|
|
||||||
if (file.path.endsWith(".jar"))
|
if (file.path.endsWith(".jar"))
|
||||||
file.path += ".disabled";
|
file.path += ".disabled";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonObject hashes = Json::requireObject(modInfo, "hashes");
|
QJsonObject hashes = Json::requireObject(modInfo, "hashes");
|
||||||
|
Loading…
Reference in New Issue
Block a user