NOISSUE shortcut creation: blacklist versions by date instead of regex

This commit is contained in:
arthomnix 2022-07-03 16:57:20 +01:00
parent 6faa0ef711
commit 7df413db1a
2 changed files with 10 additions and 17 deletions

View File

@ -47,8 +47,10 @@ CreateShortcutDialog::CreateShortcutDialog(QWidget *parent, InstancePtr instance
{
MinecraftInstancePtr minecraftInstance = qobject_pointer_cast<MinecraftInstance>(m_instance);
minecraftInstance->getPackProfile()->reload(Net::Mode::Online);
QString version = minecraftInstance->getPackProfile()->getComponentVersion("net.minecraft");
bool enableJoinServer = !QRegExp(JOIN_SERVER_DISALLOWED_VERSIONS).exactMatch(version);
QDateTime versionDate = minecraftInstance->getPackProfile()->getComponent("net.minecraft")->getReleaseDateTime();
bool enableJoinServer = (versionDate < MC_145102_START)
|| (versionDate >= MC_145102_END && versionDate < MC_228828_START)
|| (versionDate >= MC_228828_END);
ui->joinServerCheckBox->setEnabled(enableJoinServer);
ui->joinServer->setEnabled(enableJoinServer);
}

View File

@ -10,26 +10,17 @@
#include <QDialog>
#include "minecraft/auth/MinecraftAccount.h"
#include "BaseInstance.h"
#include "minecraft/ParseUtils.h"
#ifdef Q_OS_WIN
#include <windows.h>
#endif
const QString JOIN_SERVER_DISALLOWED_VERSIONS(
"(19w0[89][a-z])"
"|(19w1[0-9][a-z])"
"|(1.14.?[1-4]?-pre[0-9])"
"|(1.14.?[1-4]?)"
"|(19w[34][0-9][a-z])"
"|(1.15.?[0-9]?-pre[0-9])"
"|(1.15.?[0-9]?)"
"|(20w[01][0-9][a-z])"
"|(20w20a)"
"|(21w[12][0-9][a-z])"
"|(1.17-pre[0-9])"
"|(1.17-rc[0-9])"
"|(1.17)"
);
// Dates when the game was affected by bugs that crashed the game when using the option to join a server on startup
const QDateTime MC_145102_START = timeFromS3Time("2019-02-20T14:56:58+00:00");
const QDateTime MC_145102_END = timeFromS3Time("2020-05-14T08:16:26+00:00");
const QDateTime MC_228828_START = timeFromS3Time("2021-03-10T15:24:38+00:00");
const QDateTime MC_228828_END = timeFromS3Time("2021-06-18T12:24:40+00:00");
namespace Ui
{