MCPcopy Create free account
hub / github.com/ElyPrismLauncher/Launcher / setMinecraftRunning

Method setMinecraftRunning

launcher/BaseInstance.cpp:287–305  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

285}
286
287void BaseInstance::setMinecraftRunning(bool running)
288{
289 if (!settings()->get("RecordGameTime").toBool()) {
290 return;
291 }
292
293 if (running) {
294 m_timeStarted = QDateTime::currentDateTime();
295 setLastLaunch(m_timeStarted.toMSecsSinceEpoch());
296 } else {
297 QDateTime timeEnded = QDateTime::currentDateTime();
298
299 qint64 current = settings()->get("totalTimePlayed").toLongLong();
300 settings()->set("totalTimePlayed", current + m_timeStarted.secsTo(timeEnded));
301 settings()->set("lastTimePlayed", m_timeStarted.secsTo(timeEnded));
302
303 emit propertiesChanged(this);
304 }
305}
306
307int64_t BaseInstance::totalTimePlayed() const
308{

Callers 2

on_stateMethod · 0.80
proceedMethod · 0.80

Calls 2

getMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected