itzg / itzg/docker-minecraft-server
Additional mode for automatic CurseForge pack updates to download server pack rather than each mod individually
- Dominant language
- Shell
- Stars
- 14.3k
- Forks
- 1.9k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 31
Description
### Enhancement Type
Improve an existing feature
### Describe the enhancement
Most modpacks on CurseForge have mods that require manual downloads, so what if there was another mode for the automatic CurseForge updater to download the server pack instead? Environment variables could include pack ID, name of start script (possibly default to startserver.sh?), and whether Forge needs to be downloaded separately or if it's included. Example code to download the latest server pack in Node.js is below.
```js
const axios = require('axios')
const fs = require('fs')
const { curseforgeAPIKey, packID } = require('./config.json') // tested with pack ID of 715572 (All the Mods 9)
// https://stackoverflow.com/a/18650828
function formatBytes(bytes, decimals = 2) {
if (!+bytes) return '0 Bytes'
const k = 1024
const dm = decimals < 0 ? 0 : decimals
const sizes = ['Bytes', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB']
const i = Math.floor(Math.log(bytes) / Math.log(k))
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i]}`
}
function downloadServerPack(downloadUrl) {
axios.get(downloadUrl, {
responseType: 'stream'
}).then(response => {
if (fs.existsSync('server-pack.zip')) fs.unlinkSync('server-pack.zip')
response.data.pipe(fs.createWriteStream('server-pack.zip'))
}).catch(err => console.error(err))
}
axios.get(`https://api.curseforge.com/v1/mods/${packID}`, {
headers: {'x-api-key': curseforgeAPIKey}
})
.then(response => {
const mainFileId = response.data.data.mainFileId
axios.get(`https://api.curseforge.com/v1/mods/${packID}/files/${mainFileId}`, {
headers: {'x-api-key': curseforgeAPIKey}
}).then(response => {
axios.get(`https://api.curseforge.com/v1/mods/${packID}/files/${response.data.data.serverPackFileId}`, {
headers: {'x-api-key': curseforgeAPIKey}
}).then(response => {
console.log(`Downloading server pack (${formatBytes(Number(response.data.data.fileLength))})...`)
downloadServerPack(response.data.data.downloadUrl)
}).catch(err => console.error(err))
}).catch(err => console.error(err))
}).catch(err => console.error(err))
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by locating the automatic CurseForge updater and its environment-variable configuration in the docker-minecraft-server project. Review the proposed CurseForge server-pack API flow, then define how the new mode handles the pack ID, startup script, and Forge download; done means the latest server pack can be downloaded and started automatically.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, node.js, shell
- Domain
- devops
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100