summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--logic/minecraft/MinecraftVersion.cpp36
-rw-r--r--logic/minecraft/MinecraftVersion.h5
-rw-r--r--logic/minecraft/RawLibrary.cpp1
3 files changed, 34 insertions, 8 deletions
diff --git a/logic/minecraft/MinecraftVersion.cpp b/logic/minecraft/MinecraftVersion.cpp
index 982a5ac3..1451c39d 100644
--- a/logic/minecraft/MinecraftVersion.cpp
+++ b/logic/minecraft/MinecraftVersion.cpp
@@ -53,16 +53,28 @@ bool MinecraftVersion::isMinecraftVersion()
return true;
}
-// 1. assume the local file is good. load, check. If it's good, apply.
-// 2. if discrepancies are found, fall out and fail (impossible to apply incomplete version).
void MinecraftVersion::applyFileTo(MinecraftProfile *version)
{
- getVersionFile()->applyTo(version);
+ if(m_versionSource == Local && getVersionFile())
+ {
+ getVersionFile()->applyTo(version);
+ }
+ else
+ {
+ throw VersionIncomplete(QObject::tr("Can't apply incomplete/builtin Minecraft version %1").arg(m_name));
+ }
}
QJsonDocument MinecraftVersion::toJson(bool saveOrder)
{
- return getVersionFile()->toJson(saveOrder);
+ if(m_versionSource == Local && getVersionFile())
+ {
+ return getVersionFile()->toJson(saveOrder);
+ }
+ else
+ {
+ throw VersionIncomplete(QObject::tr("Can't write incomplete/builtin Minecraft version %1").arg(m_name));
+ }
}
VersionFilePtr MinecraftVersion::getVersionFile()
@@ -76,6 +88,22 @@ VersionFilePtr MinecraftVersion::getVersionFile()
return loadedVersionFile;
}
+bool MinecraftVersion::isCustomizable()
+{
+ switch(m_versionSource)
+ {
+ case Local:
+ case Remote:
+ // locally cached file, or a remote file that we can acquire can be customized
+ return true;
+ case Builtin:
+ // builtins do not follow the normal OneSix format. They are not customizable.
+ default:
+ // Everything else is undefined and therefore not customizable.
+ return false;
+ }
+ return false;
+}
void MinecraftVersion::applyTo(MinecraftProfile *version)
{
diff --git a/logic/minecraft/MinecraftVersion.h b/logic/minecraft/MinecraftVersion.h
index af15c1a4..3795cb41 100644
--- a/logic/minecraft/MinecraftVersion.h
+++ b/logic/minecraft/MinecraftVersion.h
@@ -52,10 +52,7 @@ public: /* methods */
{
return false;
}
- virtual bool isCustomizable() override
- {
- return true;
- }
+ virtual bool isCustomizable() override;
virtual bool isRemovable() override
{
return false;
diff --git a/logic/minecraft/RawLibrary.cpp b/logic/minecraft/RawLibrary.cpp
index bae6c66a..c4cd97a1 100644
--- a/logic/minecraft/RawLibrary.cpp
+++ b/logic/minecraft/RawLibrary.cpp
@@ -224,6 +224,7 @@ bool RawLibrary::filesExist(const QDir &base) const
}
return true;
}
+
QString RawLibrary::url() const
{
if (!m_absolute_url.isEmpty())