diff --git a/api/logic/launch/steps/LookupServerAddress.cpp b/api/logic/launch/steps/LookupServerAddress.cpp index c8e2a20c..c6ca5bd5 100644 --- a/api/logic/launch/steps/LookupServerAddress.cpp +++ b/api/logic/launch/steps/LookupServerAddress.cpp @@ -16,11 +16,6 @@ void LookupServerAddress::setLookupAddress(const QString &lookupAddress) m_dnsLookup->setName(QString("_minecraft._tcp.%1").arg(lookupAddress)); } -void LookupServerAddress::setPort(quint16 port) -{ - m_port = port; -} - void LookupServerAddress::setOutputAddressPtr(MinecraftServerTargetPtr output) { m_output = std::move(output); @@ -50,7 +45,7 @@ void LookupServerAddress::on_dnsLookupFinished() { emit logLine(QString("Failed to resolve server address (this is NOT an error!) %1: %2\n") .arg(m_dnsLookup->name(), m_dnsLookup->errorString()), MessageLevel::MultiMC); - resolve(m_lookupAddress, m_port); // Technically the task failed, however, we don't abort the launch + resolve(m_lookupAddress, 25565); // Technically the task failed, however, we don't abort the launch // and leave it up to minecraft to fail (or maybe not) when connecting return; } @@ -61,28 +56,17 @@ void LookupServerAddress::on_dnsLookupFinished() emit logLine( QString("Failed to resolve server address %1: the DNS lookup succeeded, but no records were returned.\n") .arg(m_dnsLookup->name()), MessageLevel::Warning); - resolve(m_lookupAddress, m_port); // Technically the task failed, however, we don't abort the launch + resolve(m_lookupAddress, 25565); // Technically the task failed, however, we don't abort the launch // and leave it up to minecraft to fail (or maybe not) when connecting return; } const auto &firstRecord = records.at(0); - - if (firstRecord.port() != m_port && m_port != 0) - { - emit logLine( - QString("DNS record for %1 suggested %2 as server port, but user supplied %3. Using user override," - " but the port may be wrong!\n").arg(m_dnsLookup->name(), QString::number(firstRecord.port()), QString::number(m_port)), - MessageLevel::Warning); - } - else if (m_port == 0) - { - m_port = firstRecord.port(); - } + quint16 port = firstRecord.port(); emit logLine(QString("Resolved server address %1 to %2 with port %3\n").arg( - m_dnsLookup->name(), firstRecord.target(), QString::number(m_port)),MessageLevel::MultiMC); - resolve(firstRecord.target(), m_port); + m_dnsLookup->name(), firstRecord.target(), QString::number(port)),MessageLevel::MultiMC); + resolve(firstRecord.target(), port); } void LookupServerAddress::resolve(const QString &address, quint16 port) diff --git a/api/logic/launch/steps/LookupServerAddress.h b/api/logic/launch/steps/LookupServerAddress.h index 1f70e97b..5a5c3de1 100644 --- a/api/logic/launch/steps/LookupServerAddress.h +++ b/api/logic/launch/steps/LookupServerAddress.h @@ -35,7 +35,6 @@ public: } void setLookupAddress(const QString &lookupAddress); - void setPort(quint16 port); void setOutputAddressPtr(MinecraftServerTargetPtr output); private slots: @@ -46,6 +45,5 @@ private: QDnsLookup *m_dnsLookup; QString m_lookupAddress; - quint16 m_port; MinecraftServerTargetPtr m_output; }; diff --git a/api/logic/minecraft/MinecraftInstance.cpp b/api/logic/minecraft/MinecraftInstance.cpp index 54c7f594..abb360f2 100644 --- a/api/logic/minecraft/MinecraftInstance.cpp +++ b/api/logic/minecraft/MinecraftInstance.cpp @@ -859,12 +859,20 @@ shared_qobject_ptr MinecraftInstance::createLaunchTask(AuthSessionPt if (m_settings->get("JoinServerOnLaunch").toBool()) { - // Resolve server address to join on launch - auto *step = new LookupServerAddress(pptr); - step->setLookupAddress(m_settings->get("JoinServerOnLaunchAddress").toString()); - step->setPort(m_settings->get("JoinServerOnLaunchPort").toInt()); - step->setOutputAddressPtr(serverToJoin); - process->appendStep(step); + quint16 port = m_settings->get("JoinServerOnLaunchPort").toInt(); + QString address = m_settings->get("JoinServerOnLaunchAddress").toString(); + + serverToJoin->port = port; + serverToJoin->address = address; + + if(port == 25565) + { + // Resolve server address to join on launch + auto *step = new LookupServerAddress(pptr); + step->setLookupAddress(address); + step->setOutputAddressPtr(serverToJoin); + process->appendStep(step); + } } // run pre-launch command if that's needed diff --git a/application/pages/instance/InstanceSettingsPage.ui b/application/pages/instance/InstanceSettingsPage.ui index 50c3ac6b..eb8ed13a 100644 --- a/application/pages/instance/InstanceSettingsPage.ui +++ b/application/pages/instance/InstanceSettingsPage.ui @@ -39,7 +39,7 @@ QTabWidget::Rounded - 4 + 0