MCPcopy Create free account
hub / github.com/PolyMC/PolyMC / ReadFabricModInfo

Function ReadFabricModInfo

launcher/minecraft/mod/tasks/LocalModParseTask.cpp:170–204  ·  view source on GitHub ↗

https://fabricmc.net/wiki/documentation:fabric_mod_json

Source from the content-addressed store, hash-verified

168
169// https://fabricmc.net/wiki/documentation:fabric_mod_json
170ModDetails ReadFabricModInfo(QByteArray contents)
171{
172 QJsonParseError jsonError;
173 QJsonDocument jsonDoc = QJsonDocument::fromJson(contents, &jsonError);
174 auto object = jsonDoc.object();
175 auto schemaVersion = object.contains("schemaVersion") ? object.value("schemaVersion").toInt(0) : 0;
176
177 ModDetails details;
178
179 details.mod_id = object.value("id").toString();
180 details.version = object.value("version").toString();
181
182 details.name = object.contains("name") ? object.value("name").toString() : details.mod_id;
183 details.description = object.value("description").toString();
184
185 if (schemaVersion >= 1) {
186 QJsonArray authors = object.value("authors").toArray();
187 for (auto author : authors) {
188 if (author.isObject()) {
189 details.authors.append(author.toObject().value("name").toString());
190 } else {
191 details.authors.append(author.toString());
192 }
193 }
194
195 if (object.contains("contact")) {
196 QJsonObject contact = object.value("contact").toObject();
197
198 if (contact.contains("homepage")) {
199 details.homeurl = contact.value("homepage").toString();
200 }
201 }
202 }
203 return details;
204}
205
206// https://github.com/QuiltMC/rfcs/blob/master/specification/0002-quilt.mod.json.md
207ModDetails ReadQuiltModInfo(QByteArray contents)

Callers 1

processAsZipMethod · 0.85

Calls 5

fromJsonFunction · 0.85
objectMethod · 0.80
appendMethod · 0.80
containsMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected