Added java metadata
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
parent
25bca28707
commit
e897032383
@ -430,6 +430,9 @@ set(JAVA_SOURCES
|
||||
java/JavaUtils.cpp
|
||||
java/JavaVersion.h
|
||||
java/JavaVersion.cpp
|
||||
|
||||
java/JavaRuntime.h
|
||||
java/JavaRuntime.cpp
|
||||
)
|
||||
|
||||
set(TRANSLATIONS_SOURCES
|
||||
|
@ -109,3 +109,23 @@ bool JavaVersion::operator>(const JavaVersion& rhs)
|
||||
{
|
||||
return (!operator<(rhs)) && (!operator==(rhs));
|
||||
}
|
||||
|
||||
JavaVersion::JavaVersion(int major, int minor, int security, int build, QString name)
|
||||
: m_major(major), m_minor(minor), m_security(security), m_name(name), m_parseable(true)
|
||||
{
|
||||
if (build != 0) {
|
||||
m_prerelease = QString::number(build);
|
||||
m_string = m_prerelease;
|
||||
}
|
||||
if (m_security != 0)
|
||||
m_string = QString::number(m_security) + "." + m_string;
|
||||
else if (!m_string.isEmpty()) {
|
||||
m_string = "0." + m_string;
|
||||
}
|
||||
if (m_minor != 0)
|
||||
m_string = QString::number(m_minor) + "." + m_string;
|
||||
else if (!m_string.isEmpty()) {
|
||||
m_string = "0." + m_string;
|
||||
}
|
||||
m_string = QString::number(m_major) + "." + m_string;
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ class JavaVersion {
|
||||
public:
|
||||
JavaVersion() {}
|
||||
JavaVersion(const QString& rhs);
|
||||
JavaVersion(int major, int minor, int security, int build = 0, QString name = "");
|
||||
|
||||
JavaVersion& operator=(const QString& rhs);
|
||||
|
||||
@ -32,12 +33,15 @@ class JavaVersion {
|
||||
int major() { return m_major; }
|
||||
int minor() { return m_minor; }
|
||||
int security() { return m_security; }
|
||||
QString build() { return m_prerelease; }
|
||||
QString name() { return m_name; }
|
||||
|
||||
private:
|
||||
QString m_string;
|
||||
int m_major = 0;
|
||||
int m_minor = 0;
|
||||
int m_security = 0;
|
||||
QString m_name = "";
|
||||
bool m_parseable = false;
|
||||
QString m_prerelease;
|
||||
};
|
||||
|
@ -185,6 +185,9 @@ void MojangVersionFormat::readVersionProperties(const QJsonObject& in, VersionFi
|
||||
out->compatibleJavaMajors.append(requireInteger(compatible));
|
||||
}
|
||||
}
|
||||
if (in.contains("compatibleJavaName")) {
|
||||
out->compatibleJavaName = requireString(in.value("compatibleJavaName"));
|
||||
}
|
||||
|
||||
if (in.contains("downloads")) {
|
||||
auto downloadsObj = requireObject(in, "downloads");
|
||||
@ -259,6 +262,9 @@ void MojangVersionFormat::writeVersionProperties(const VersionFile* in, QJsonObj
|
||||
}
|
||||
out.insert("compatibleJavaMajors", compatibleJavaMajorsOut);
|
||||
}
|
||||
if (!in->compatibleJavaName.isEmpty()) {
|
||||
writeString(out, "compatibleJavaName", in->compatibleJavaName);
|
||||
}
|
||||
}
|
||||
|
||||
QJsonDocument MojangVersionFormat::versionFileToJson(const VersionFilePtr& patch)
|
||||
|
@ -36,6 +36,8 @@
|
||||
#include "OneSixVersionFormat.h"
|
||||
#include <Json.h>
|
||||
#include <minecraft/MojangVersionFormat.h>
|
||||
#include <QList>
|
||||
#include "java/JavaRuntime.h"
|
||||
#include "minecraft/Agent.h"
|
||||
#include "minecraft/ParseUtils.h"
|
||||
|
||||
@ -255,6 +257,18 @@ VersionFilePtr OneSixVersionFormat::versionFileFromJson(const QJsonDocument& doc
|
||||
out->m_volatile = requireBoolean(root, "volatile");
|
||||
}
|
||||
|
||||
if (root.contains("runtimes")) {
|
||||
auto runtimes = requireObject(root, "runtimes");
|
||||
out->runtimes = {};
|
||||
for (auto key : runtimes.keys()) {
|
||||
QList<JavaRuntime::MetaPtr> list;
|
||||
for (auto runtime : ensureArray(runtimes, key)) {
|
||||
list.append(JavaRuntime::parseJavaMeta(ensureObject(runtime)));
|
||||
}
|
||||
out->runtimes[key] = list;
|
||||
}
|
||||
}
|
||||
|
||||
/* removed features that shouldn't be used */
|
||||
if (root.contains("tweakers")) {
|
||||
out->addProblem(ProblemSeverity::Error, QObject::tr("Version file contains unsupported element 'tweakers'"));
|
||||
|
@ -36,6 +36,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QHash>
|
||||
#include <QList>
|
||||
#include <QSet>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
@ -45,6 +47,7 @@
|
||||
#include "Agent.h"
|
||||
#include "Library.h"
|
||||
#include "ProblemProvider.h"
|
||||
#include "java/JavaRuntime.h"
|
||||
#include "minecraft/Rule.h"
|
||||
|
||||
class PackProfile;
|
||||
@ -98,6 +101,9 @@ class VersionFile : public ProblemContainer {
|
||||
/// Mojang: list of compatible java majors
|
||||
QList<int> compatibleJavaMajors;
|
||||
|
||||
/// Mojang: the name of recomended java version
|
||||
QString compatibleJavaName;
|
||||
|
||||
/// Mojang: type of the Minecraft version
|
||||
QString type;
|
||||
|
||||
@ -149,6 +155,8 @@ class VersionFile : public ProblemContainer {
|
||||
/// is volatile -- may be removed as soon as it is no longer needed by something else
|
||||
bool m_volatile = false;
|
||||
|
||||
QHash<QString, QList<JavaRuntime::MetaPtr>> runtimes;
|
||||
|
||||
public:
|
||||
// Mojang: DEPRECATED list of 'downloads' - client jar, server jar, windows server exe, maybe more.
|
||||
QMap<QString, std::shared_ptr<MojangDownloadInfo>> mojangDownloads;
|
||||
|
@ -796,8 +796,6 @@
|
||||
<tabstop>enableFeralGamemodeCheck</tabstop>
|
||||
<tabstop>enableMangoHud</tabstop>
|
||||
<tabstop>useDiscreteGpuCheck</tabstop>
|
||||
<tabstop>modLoaderSettingsGroupBox</tabstop>
|
||||
<tabstop>disableQuiltBeaconCheckBox</tabstop>
|
||||
<tabstop>gameTimeGroupBox</tabstop>
|
||||
<tabstop>serverJoinGroupBox</tabstop>
|
||||
<tabstop>serverJoinAddress</tabstop>
|
||||
|
Loading…
Reference in New Issue
Block a user