Upload via GUI (43 Dateien)

This commit is contained in:
2026-08-15 14:20:19 +00:00
parent 425b94fd93
commit 3b54217989
5 changed files with 257 additions and 6 deletions
+12 -3
View File
@@ -32,6 +32,7 @@ const crashreports = require('./crashreports');
const skins = require('./skins');
const servers = require('./servers');
const mcping = require('./mcping');
const discordpresence = require('./discordpresence');
// undici als globales fetch verwenden -> ermöglicht Proxy via setGlobalDispatcher
const undici = require('undici');
@@ -297,6 +298,7 @@ app.whenReady().then(() => {
decrypt: (b) => safeStorage.decryptString(Buffer.from(b, 'base64')),
});
applyProxy(store.getSettings());
discordpresence.configure(store.getSettings());
const autostartAn = !!store.getSettings().autostart;
// Autostart-Eintrag/Tray mit der Einstellung synchron halten (falls z. B.
// von Hand an der Registry gedreht wurde oder nach einem Update)
@@ -362,7 +364,7 @@ app.on('window-all-closed', () => {
if (process.platform !== 'darwin') app.quit();
});
app.on('before-quit', () => { appIsQuitting = true; });
app.on('before-quit', () => { appIsQuitting = true; discordpresence.shutdown(); });
// ---------------------------------------------------------------------------
// Java-Erkennung (für Anzeige in den Einstellungen)
@@ -390,6 +392,7 @@ ipcMain.handle('settings:save', (_e, patch) => {
const s = store.saveSettings(patch);
applyProxy(s);
if (patch && Object.prototype.hasOwnProperty.call(patch, 'autostart')) applyAutostart(s.autostart);
if (patch && Object.prototype.hasOwnProperty.call(patch, 'discordClientId')) discordpresence.configure(s);
return s;
});
@@ -1935,9 +1938,15 @@ ipcMain.handle('instances:launch', async (_e, id, accountId, launchOpts) => {
if (evt.phase === 'launch') {
launchStart = Date.now();
if (!gezaehlt) { gezaehlt = true; kontoSpieltJetzt(kontoId); }
discordpresence.setActivity({
details: 'Spielt Minecraft',
state: `${inst.name} · ${inst.minecraft.version}`,
startTimestamp: launchStart,
});
}
if (evt.phase === 'exit') {
if (gezaehlt) { gezaehlt = false; kontoSpieltNichtMehr(kontoId); }
discordpresence.clearActivity();
if (launchStart) {
const secs = Math.max(0, Math.round((Date.now() - launchStart) / 1000));
launchStart = 0; // Spielzeit nur einmal gutschreiben
@@ -1951,11 +1960,11 @@ ipcMain.handle('instances:launch', async (_e, id, accountId, launchOpts) => {
});
// Start fehlgeschlagen, obwohl schon gezählt -> Zählung zurücknehmen,
// sonst bliebe das Konto für immer als "spielt" stehen
if (!res.ok && gezaehlt) { gezaehlt = false; kontoSpieltNichtMehr(kontoId); }
if (!res.ok && gezaehlt) { gezaehlt = false; kontoSpieltNichtMehr(kontoId); discordpresence.clearActivity(); }
if (res.ok) store.updateInstance(id, { lastPlayed: new Date().toISOString() });
return res;
} catch (err) {
if (gezaehlt) { gezaehlt = false; kontoSpieltNichtMehr(kontoId); }
if (gezaehlt) { gezaehlt = false; kontoSpieltNichtMehr(kontoId); discordpresence.clearActivity(); }
return { ok: false, message: 'Start fehlgeschlagen: ' + err.message };
}
});