| 240 | } |
| 241 | |
| 242 | VersionFilePtr MojangVersionFormat::versionFileFromJson(const QJsonDocument &doc, const QString &filename) |
| 243 | { |
| 244 | VersionFilePtr out(new VersionFile()); |
| 245 | if (doc.isEmpty() || doc.isNull()) |
| 246 | { |
| 247 | throw JSONValidationError(filename + " is empty or null"); |
| 248 | } |
| 249 | if (!doc.isObject()) |
| 250 | { |
| 251 | throw JSONValidationError(filename + " is not an object"); |
| 252 | } |
| 253 | |
| 254 | QJsonObject root = doc.object(); |
| 255 | |
| 256 | readVersionProperties(root, out.get()); |
| 257 | |
| 258 | out->name = "Minecraft"; |
| 259 | out->uid = "net.minecraft"; |
| 260 | out->version = out->minecraftVersion; |
| 261 | // out->filename = filename; |
| 262 | |
| 263 | |
| 264 | if (root.contains("libraries")) |
| 265 | { |
| 266 | for (auto libVal : requireArray(root.value("libraries"))) |
| 267 | { |
| 268 | auto libObj = requireObject(libVal); |
| 269 | |
| 270 | auto lib = MojangVersionFormat::libraryFromJson(*out, libObj, filename); |
| 271 | out->libraries.append(lib); |
| 272 | } |
| 273 | } |
| 274 | return out; |
| 275 | } |
| 276 | |
| 277 | void MojangVersionFormat::writeVersionProperties(const VersionFile* in, QJsonObject& out) |
| 278 | { |
nothing calls this directly
no test coverage detected