summaryrefslogtreecommitdiffstats
path: root/logic/minecraft
diff options
context:
space:
mode:
Diffstat (limited to 'logic/minecraft')
-rw-r--r--logic/minecraft/LegacyInstance.cpp16
-rw-r--r--logic/minecraft/MinecraftInstance.cpp33
-rw-r--r--logic/minecraft/MinecraftInstance.h3
-rw-r--r--logic/minecraft/OneSixInstance.cpp16
4 files changed, 38 insertions, 30 deletions
diff --git a/logic/minecraft/LegacyInstance.cpp b/logic/minecraft/LegacyInstance.cpp
index ed0b1001..782135eb 100644
--- a/logic/minecraft/LegacyInstance.cpp
+++ b/logic/minecraft/LegacyInstance.cpp
@@ -170,21 +170,7 @@ std::shared_ptr<LaunchTask> LegacyInstance::createLaunchTask(AuthSessionPtr sess
}
if (session)
{
- QMap<QString, QString> filter;
- if (session->session != "-")
- filter[session->session] = tr("<SESSION ID>");
- filter[session->access_token] = tr("<ACCESS TOKEN>");
- filter[session->client_token] = tr("<CLIENT TOKEN>");
- filter[session->uuid] = tr("<PROFILE ID>");
- filter[session->player_name] = tr("<PROFILE NAME>");
-
- auto i = session->u.properties.begin();
- while (i != session->u.properties.end())
- {
- filter[i.value()] = "<" + i.key().toUpper() + ">";
- ++i;
- }
- process->setCensorFilter(filter);
+ process->setCensorFilter(createCensorFilterFromSession(session));
}
return process;
}
diff --git a/logic/minecraft/MinecraftInstance.cpp b/logic/minecraft/MinecraftInstance.cpp
index 13e696b9..d576ef4f 100644
--- a/logic/minecraft/MinecraftInstance.cpp
+++ b/logic/minecraft/MinecraftInstance.cpp
@@ -204,6 +204,39 @@ QProcessEnvironment MinecraftInstance::createEnvironment()
return env;
}
+QMap<QString, QString> MinecraftInstance::createCensorFilterFromSession(AuthSessionPtr session)
+{
+ if(!session)
+ {
+ return QMap<QString, QString>();
+ }
+ auto & sessionRef = *session.get();
+ QMap<QString, QString> filter;
+ auto addToFilter = [&filter](QString key, QString value)
+ {
+ if(key.trimmed().size())
+ {
+ filter[key] = value;
+ }
+ };
+ if (sessionRef.session != "-")
+ {
+ addToFilter(sessionRef.session, tr("<SESSION ID>"));
+ }
+ addToFilter(sessionRef.access_token, tr("<ACCESS TOKEN>"));
+ addToFilter(sessionRef.client_token, tr("<CLIENT TOKEN>"));
+ addToFilter(sessionRef.uuid, tr("<PROFILE ID>"));
+ addToFilter(sessionRef.player_name, tr("<PROFILE NAME>"));
+
+ auto i = sessionRef.u.properties.begin();
+ while (i != sessionRef.u.properties.end())
+ {
+ addToFilter(i.value(), "<" + i.key().toUpper() + ">");
+ ++i;
+ }
+ return filter;
+}
+
MessageLevel::Enum MinecraftInstance::guessLevel(const QString &line, MessageLevel::Enum level)
{
QRegularExpression re("\\[(?<timestamp>[0-9:]+)\\] \\[[^/]+/(?<level>[^\\]]+)\\]");
diff --git a/logic/minecraft/MinecraftInstance.h b/logic/minecraft/MinecraftInstance.h
index 7ed659a7..14a0f097 100644
--- a/logic/minecraft/MinecraftInstance.h
+++ b/logic/minecraft/MinecraftInstance.h
@@ -43,6 +43,9 @@ public:
/// guess log level from a line of minecraft log
virtual MessageLevel::Enum guessLevel(const QString &line, MessageLevel::Enum level);
+
+protected:
+ QMap<QString, QString> createCensorFilterFromSession(AuthSessionPtr session);
};
typedef std::shared_ptr<MinecraftInstance> MinecraftInstancePtr;
diff --git a/logic/minecraft/OneSixInstance.cpp b/logic/minecraft/OneSixInstance.cpp
index 3b2ff750..9a7ef99b 100644
--- a/logic/minecraft/OneSixInstance.cpp
+++ b/logic/minecraft/OneSixInstance.cpp
@@ -277,21 +277,7 @@ std::shared_ptr<LaunchTask> OneSixInstance::createLaunchTask(AuthSessionPtr sess
}
if (session)
{
- QMap<QString, QString> filter;
- if (session->session != "-")
- filter[session->session] = tr("<SESSION ID>");
- filter[session->access_token] = tr("<ACCESS TOKEN>");
- filter[session->client_token] = tr("<CLIENT TOKEN>");
- filter[session->uuid] = tr("<PROFILE ID>");
- filter[session->player_name] = tr("<PROFILE NAME>");
-
- auto i = session->u.properties.begin();
- while (i != session->u.properties.end())
- {
- filter[i.value()] = "<" + i.key().toUpper() + ">";
- ++i;
- }
- process->setCensorFilter(filter);
+ process->setCensorFilter(createCensorFilterFromSession(session));
}
return process;
}