Skip to content

Commit

Permalink
replaced "addedMods" folder by "additionalFiles"
Browse files Browse the repository at this point in the history
  • Loading branch information
Kensaa committed Sep 18, 2023
1 parent da5de81 commit 076be84
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 27 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ You can download the last version from the [release](https://github.com/Kensaa/k

- **Reset Config** : Kinda explicit too

### Adding mods to existing profile
### Adding files to existing profile

If your want to had mods to an existing modded profile, you can add them in [game folder]/addedMods/[profile]. They will be automatically added in the game folder when you start the game. This is made so that people who want to add mods like Optifine, Betterfps, etc... can had them without them being removed at each start by the updater or the creator of the profile adding them to the profile which would install them for all the users
If your want to add file (like mods) to an existing profile, you can add them in :\
`[game folder]/additionalFiles/[profile]`.\
They will be automatically added in the game folder when you start the game. This is made so that people who want to add mods like Optifine, Betterfps, etc... can add them without them being removed at each start by the updater or without the creator of the profile having to add them to the profile which would install them for all the users

## Server

Expand Down
40 changes: 17 additions & 23 deletions launcher/electron/electron.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
JSONFetch,
checkExist,
checkServer,
copyFolder,
download,
folderTree,
getHash
Expand Down Expand Up @@ -501,37 +502,30 @@ ipcMain.handle('start-game', async (event, args: Profile) => {
.replace(/[^a-zA-Z0-9]/g, '_')
.toLowerCase()
}
const addedModsFolder = path.join(

const gameFolder = path.join(
config.rootDir,
'profiles',
args.gameFolder
)

const additionalFileFolder = path.join(
config.rootDir,
'addedMods',
'additionalFiles',
args.gameFolder
)
checkExist(addedModsFolder)
checkExist(additionalFileFolder)
// Copy added mods
const addedMods = fs.readdirSync(addedModsFolder)
logger.debug(addedMods)
if (addedMods.length > 0) {
checkExist(
path.join(config.rootDir, 'profiles', args.gameFolder, 'mods')
)
for (const mod of addedMods) {
fs.copyFileSync(
path.join(addedModsFolder, mod),
path.join(
config.rootDir,
'profiles',
args.gameFolder,
'mods',
mod
)
)
}
const additionalFiles = fs.readdirSync(additionalFileFolder)
if (additionalFiles.length > 0) {
checkExist(gameFolder)
copyFolder(additionalFileFolder, gameFolder)
}

let opts = {
const opts = {
clientPackage: null,
authorization: msmc.getMCLC().getAuth(loginInfo),
root: path.join(config.rootDir, 'profiles', args.gameFolder),
root: gameFolder,
version: {
number: args.version.mc,
type: 'release'
Expand Down
16 changes: 15 additions & 1 deletion launcher/electron/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import fetch from 'electron-fetch'

export function checkExist(path: string) {
if (!fs.existsSync(path)) {
fs.mkdirSync(path)
fs.mkdirSync(path, { recursive: true })
}
}

Expand Down Expand Up @@ -67,3 +67,17 @@ export function checkServer(address: string) {
export function JSONFetch(address: string) {
return fetch(address).then(res => res.json())
}

export function copyFolder(source: string, destination: string) {
const files = fs.readdirSync(source)
checkExist(destination)
for (const filename of files) {
const filepath = path.join(source, filename)
const fileDestination = path.join(destination, filename)
if (fs.statSync(filepath).isFile()) {
fs.copyFileSync(filepath, fileDestination)
} else {
copyFolder(filepath, fileDestination)
}
}
}
2 changes: 1 addition & 1 deletion launcher/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "A Minecraft launcher with auto-update feature to facilitate playing modded minecraft",
"author": "Kensa",
"private": true,
"version": "2.3.2",
"version": "2.4.0",
"main": "dist-electron/electron.js",
"scripts": {
"dev": "vite",
Expand Down

0 comments on commit 076be84

Please sign in to comment.