2020-12-08 19:59:56 +01:00
|
|
|
const { app, BrowserWindow, Menu, ipcMain, Notification } = require('electron')
|
|
|
|
const path = require('path')
|
|
|
|
const { Client, Authenticator } = require('minecraft-launcher-core')
|
|
|
|
|
|
|
|
const launcher = new Client();
|
2020-12-07 23:57:48 +01:00
|
|
|
const iconPath = path.join(__dirname, "icon.png");
|
2020-12-08 19:59:56 +01:00
|
|
|
let win = null
|
|
|
|
let auth = null
|
|
|
|
|
2020-12-08 23:04:57 +01:00
|
|
|
let Minecraftpath = "game"
|
2020-12-08 19:59:56 +01:00
|
|
|
let clientPackage = "https://www.dropbox.com/s/ww6a052nzzgojdm/modpack.zip?dl=1"
|
2020-12-08 23:04:57 +01:00
|
|
|
let version = "1.16.4"
|
|
|
|
let versionFolder = "fabric-loader-0.10.8-1.16.4"
|
2020-12-05 21:08:32 +01:00
|
|
|
|
|
|
|
function createWindow () {
|
2020-12-08 19:59:56 +01:00
|
|
|
win = new BrowserWindow({
|
2020-12-07 23:57:48 +01:00
|
|
|
width: 1000,
|
2020-12-08 23:04:57 +01:00
|
|
|
minWidth: 900,
|
2020-12-05 21:08:32 +01:00
|
|
|
height: 600,
|
2020-12-08 23:04:57 +01:00
|
|
|
minHeight: 600,
|
2020-12-07 23:57:48 +01:00
|
|
|
icon: iconPath,
|
2020-12-05 21:08:32 +01:00
|
|
|
webPreferences: {
|
|
|
|
nodeIntegration: true,
|
|
|
|
enableRemoteModule: true
|
|
|
|
},
|
|
|
|
frame: false
|
|
|
|
})
|
2020-12-08 19:59:56 +01:00
|
|
|
Menu.setApplicationMenu(null)
|
|
|
|
win.loadFile('login.html')
|
2020-12-05 21:08:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
app.whenReady().then(() => {
|
|
|
|
createWindow()
|
|
|
|
})
|
|
|
|
|
|
|
|
app.on('window-all-closed', () => {
|
|
|
|
if (process.platform !== 'darwin') {
|
|
|
|
app.quit()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
app.on('activate', () => {
|
|
|
|
if (win === null){
|
|
|
|
createWindow()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2020-12-08 19:59:56 +01:00
|
|
|
ipcMain.on("login", (event, args) => {
|
|
|
|
auth = Authenticator.getAuth(args.user, args.pass)
|
|
|
|
auth.then(v => {
|
|
|
|
win.loadFile('index.html')
|
|
|
|
setTimeout(() => {
|
|
|
|
event.sender.send("nick", {
|
|
|
|
name: v.name
|
|
|
|
})
|
|
|
|
}, 1000)
|
|
|
|
|
|
|
|
}).catch((err) => {
|
|
|
|
console.warn(err)
|
|
|
|
showNotification("Erreur de connexion")
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
function showNotification(title="", body="") {
|
|
|
|
const notification = {
|
|
|
|
title: title,
|
|
|
|
body: body
|
|
|
|
}
|
|
|
|
new Notification(notification).show()
|
|
|
|
}
|
|
|
|
|
|
|
|
ipcMain.on("notification", (event, args) => {
|
|
|
|
showNotification(args.title, args.body)
|
|
|
|
})
|
|
|
|
|
|
|
|
ipcMain.on("launch", (event, args) => {
|
|
|
|
let opts = {
|
|
|
|
clientPackage: clientPackage,
|
|
|
|
authorization: auth,
|
|
|
|
root: Minecraftpath,
|
|
|
|
version: {
|
2020-12-08 23:04:57 +01:00
|
|
|
number: version,
|
2020-12-08 19:59:56 +01:00
|
|
|
type: "release",
|
2020-12-08 23:04:57 +01:00
|
|
|
custom: versionFolder
|
2020-12-08 19:59:56 +01:00
|
|
|
},
|
|
|
|
memory: {
|
|
|
|
max: args.maxMem,
|
|
|
|
min: args.minMem
|
|
|
|
}
|
|
|
|
}
|
|
|
|
launcher.launch(opts)
|
2020-12-08 23:04:57 +01:00
|
|
|
launcher.on('debug', (e) => console.log("debug", e));
|
|
|
|
launcher.on('data', (e) => console.log("data", e));
|
|
|
|
launcher.on('progress', (e) => event.sender.send("progress", e));
|
|
|
|
launcher.on('close', (e) => event.sender.send("close", e));
|
2020-12-08 19:59:56 +01:00
|
|
|
|
|
|
|
})
|