pollymc/logic/minecraft/JarMod.cpp
Petr Mrázek 6fd18a5cce GH-1016 print list of mods, coremods and jarmods
Includes a change to jar mods, where they gain an 'originalName' attribute used only for display
2015-05-31 21:50:01 +02:00

28 lines
654 B
C++

#include "JarMod.h"
#include "MMCJson.h"
using namespace MMCJson;
JarmodPtr Jarmod::fromJson(const QJsonObject &libObj, const QString &filename, const QString &originalName)
{
JarmodPtr out(new Jarmod());
if (!libObj.contains("name"))
{
throw JSONValidationError(filename +
"contains a jarmod that doesn't have a 'name' field");
}
out->name = libObj.value("name").toString();
out->originalName = libObj.value("originalName").toString();
return out;
}
QJsonObject Jarmod::toJson()
{
QJsonObject out;
writeString(out, "name", name);
if(!originalName.isEmpty())
{
writeString(out, "originalName", originalName);
}
return out;
}