mirror of
https://github.com/barkeser2002/minecraft-data.git
synced 2026-11-24 05:06:05 +03:00
27 lines
932 B
JavaScript
27 lines
932 B
JavaScript
const fs = require('fs')
|
|
const path = require('path')
|
|
|
|
const file = path.join(__dirname, '..', '..', 'data', 'pc', 'common', 'protocolVersions.json')
|
|
const arr = JSON.parse(fs.readFileSync(file, 'utf8'))
|
|
|
|
let current = arr.find(e => typeof e.dataVersion === 'number')?.dataVersion || 0
|
|
for (const entry of arr) {
|
|
if (typeof entry.dataVersion === 'number') {
|
|
current = entry.dataVersion
|
|
} else {
|
|
current -= 1
|
|
entry.dataVersion = current
|
|
}
|
|
}
|
|
|
|
const keyOrder = ['minecraftVersion', 'version', 'dataVersion', 'usesNetty', 'majorVersion', 'releaseType']
|
|
function ordered (obj) {
|
|
const out = {}
|
|
for (const key of keyOrder) if (Object.prototype.hasOwnProperty.call(obj, key)) out[key] = obj[key]
|
|
for (const key of Object.keys(obj)) if (!Object.prototype.hasOwnProperty.call(out, key)) out[key] = obj[key]
|
|
return out
|
|
}
|
|
|
|
const formatted = JSON.stringify(arr.map(ordered), null, 2)
|
|
fs.writeFileSync(file, formatted)
|