MCPcopy Create free account
hub / github.com/MultiMC/Launcher / versionFileFromJson

Method versionFileFromJson

launcher/minecraft/OneSixVersionFormat.cpp:41–254  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39}
40
41VersionFilePtr OneSixVersionFormat::versionFileFromJson(const QJsonDocument &doc, const QString &filename, const bool requireOrder)
42{
43 VersionFilePtr out(new VersionFile());
44 if (doc.isEmpty() || doc.isNull())
45 {
46 throw JSONValidationError(filename + " is empty or null");
47 }
48 if (!doc.isObject())
49 {
50 throw JSONValidationError(filename + " is not an object");
51 }
52
53 QJsonObject root = doc.object();
54
55 Meta::MetadataVersion formatVersion = Meta::parseFormatVersion(root, false);
56 switch(formatVersion)
57 {
58 case Meta::MetadataVersion::InitialRelease:
59 break;
60 case Meta::MetadataVersion::Invalid:
61 throw JSONValidationError(filename + " does not contain a recognizable version of the metadata format.");
62 }
63
64 if (requireOrder)
65 {
66 if (root.contains("order"))
67 {
68 out->order = requireInteger(root.value("order"));
69 }
70 else
71 {
72 // FIXME: evaluate if we don't want to throw exceptions here instead
73 qCritical() << filename << "doesn't contain an order field";
74 }
75 }
76
77 out->name = root.value("name").toString();
78
79 if(root.contains("uid"))
80 {
81 out->uid = root.value("uid").toString();
82 }
83 else
84 {
85 out->uid = root.value("fileId").toString();
86 }
87
88 out->version = root.value("version").toString();
89
90 MojangVersionFormat::readVersionProperties(root, out.get());
91
92 // added for legacy Minecraft window embedding, TODO: remove
93 readString(root, "appletClass", out->appletClass);
94
95 if (root.contains("+tweakers"))
96 {
97 for (auto tweakerVal : requireArray(root.value("+tweakers")))
98 {

Callers

nothing calls this directly

Calls 15

parseFormatVersionFunction · 0.85
requireArrayFunction · 0.85
requireObjectFunction · 0.85
GradleSpecifierClass · 0.85
QStringClass · 0.85
parseRequiresFunction · 0.85
isEmptyMethod · 0.80
objectMethod · 0.80
appendMethod · 0.80
insertMethod · 0.80
addProblemMethod · 0.80
setRawNameMethod · 0.80

Tested by

no test coverage detected