mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2025-06-12 13:17:41 +02:00
Merge branch 'develop' of https://github.com/PrismLauncher/PrismLauncher into feature/java-downloader
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
@ -22,8 +22,8 @@
|
||||
class CheckJava : public LaunchStep {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CheckJava(LaunchTask* parent) : LaunchStep(parent){};
|
||||
virtual ~CheckJava(){};
|
||||
explicit CheckJava(LaunchTask* parent) : LaunchStep(parent) {};
|
||||
virtual ~CheckJava() {};
|
||||
|
||||
virtual void executeTask();
|
||||
virtual bool canAbort() const { return false; }
|
||||
|
@ -25,7 +25,7 @@ class LookupServerAddress : public LaunchStep {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit LookupServerAddress(LaunchTask* parent);
|
||||
virtual ~LookupServerAddress(){};
|
||||
virtual ~LookupServerAddress() {};
|
||||
|
||||
virtual void executeTask();
|
||||
virtual bool abort();
|
||||
|
@ -22,7 +22,7 @@ class PostLaunchCommand : public LaunchStep {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit PostLaunchCommand(LaunchTask* parent);
|
||||
virtual ~PostLaunchCommand(){};
|
||||
virtual ~PostLaunchCommand() {};
|
||||
|
||||
virtual void executeTask();
|
||||
virtual bool abort();
|
||||
|
@ -22,7 +22,7 @@ class PreLaunchCommand : public LaunchStep {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit PreLaunchCommand(LaunchTask* parent);
|
||||
virtual ~PreLaunchCommand(){};
|
||||
virtual ~PreLaunchCommand() {};
|
||||
|
||||
virtual void executeTask();
|
||||
virtual bool abort();
|
||||
|
65
launcher/launch/steps/PrintServers.cpp
Normal file
65
launcher/launch/steps/PrintServers.cpp
Normal file
@ -0,0 +1,65 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
/*
|
||||
* Prism Launcher - Minecraft Launcher
|
||||
* Copyright (c) 2024 Leia uwu <leia@tutamail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "PrintServers.h"
|
||||
#include "QHostInfo"
|
||||
|
||||
PrintServers::PrintServers(LaunchTask* parent, const QStringList& servers) : LaunchStep(parent)
|
||||
{
|
||||
m_servers = servers;
|
||||
}
|
||||
|
||||
void PrintServers::executeTask()
|
||||
{
|
||||
for (QString server : m_servers) {
|
||||
QHostInfo::lookupHost(server, this, &PrintServers::resolveServer);
|
||||
}
|
||||
}
|
||||
|
||||
void PrintServers::resolveServer(const QHostInfo& host_info)
|
||||
{
|
||||
QString server = host_info.hostName();
|
||||
QString addresses = server + " resolves to:\n [";
|
||||
|
||||
if (!host_info.addresses().isEmpty()) {
|
||||
for (QHostAddress address : host_info.addresses()) {
|
||||
addresses += address.toString();
|
||||
if (!host_info.addresses().endsWith(address)) {
|
||||
addresses += ", ";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
addresses += "N/A";
|
||||
}
|
||||
addresses += "]\n\n";
|
||||
|
||||
m_server_to_address.insert(server, addresses);
|
||||
|
||||
// print server info in order once all servers are resolved
|
||||
if (m_server_to_address.size() >= m_servers.size()) {
|
||||
for (QString serv : m_servers) {
|
||||
emit logLine(m_server_to_address.value(serv), MessageLevel::Launcher);
|
||||
}
|
||||
emitSucceeded();
|
||||
}
|
||||
}
|
||||
|
||||
bool PrintServers::canAbort() const
|
||||
{
|
||||
return true;
|
||||
}
|
37
launcher/launch/steps/PrintServers.h
Normal file
37
launcher/launch/steps/PrintServers.h
Normal file
@ -0,0 +1,37 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
/*
|
||||
* Prism Launcher - Minecraft Launcher
|
||||
* Copyright (c) 2024 Leia uwu <leia@tutamail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <LoggedProcess.h>
|
||||
#include <java/JavaChecker.h>
|
||||
#include <launch/LaunchStep.h>
|
||||
#include <QHostInfo>
|
||||
|
||||
class PrintServers : public LaunchStep {
|
||||
Q_OBJECT
|
||||
public:
|
||||
PrintServers(LaunchTask* parent, const QStringList& servers);
|
||||
|
||||
virtual void executeTask();
|
||||
virtual bool canAbort() const;
|
||||
|
||||
private:
|
||||
void resolveServer(const QHostInfo& host_info);
|
||||
QMap<QString, QString> m_server_to_address;
|
||||
QStringList m_servers;
|
||||
};
|
@ -23,8 +23,8 @@
|
||||
class QuitAfterGameStop : public LaunchStep {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QuitAfterGameStop(LaunchTask* parent) : LaunchStep(parent){};
|
||||
virtual ~QuitAfterGameStop(){};
|
||||
explicit QuitAfterGameStop(LaunchTask* parent) : LaunchStep(parent) {};
|
||||
virtual ~QuitAfterGameStop() {};
|
||||
|
||||
virtual void executeTask();
|
||||
virtual bool canAbort() const { return false; }
|
||||
|
@ -28,7 +28,7 @@ class TextPrint : public LaunchStep {
|
||||
public:
|
||||
explicit TextPrint(LaunchTask* parent, const QStringList& lines, MessageLevel::Enum level);
|
||||
explicit TextPrint(LaunchTask* parent, const QString& line, MessageLevel::Enum level);
|
||||
virtual ~TextPrint(){};
|
||||
virtual ~TextPrint() {};
|
||||
|
||||
virtual void executeTask();
|
||||
virtual bool canAbort() const;
|
||||
|
@ -25,8 +25,8 @@
|
||||
class Update : public LaunchStep {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit Update(LaunchTask* parent, Net::Mode mode) : LaunchStep(parent), m_mode(mode){};
|
||||
virtual ~Update(){};
|
||||
explicit Update(LaunchTask* parent, Net::Mode mode) : LaunchStep(parent), m_mode(mode) {};
|
||||
virtual ~Update() {};
|
||||
|
||||
void executeTask() override;
|
||||
bool canAbort() const override;
|
||||
|
Reference in New Issue
Block a user