Range Start | Range End | Java Version |
---|---|---|
1.18 | 1.19.4 | 17 |
1.17 | 1.17.1 | 16 |
1.0 | 1.16.5 | 8 |
Last active
April 24, 2023 00:59
-
-
Save leumasme/d4746fde940fca3561522784cf22f916 to your computer and use it in GitHub Desktop.
minecraft java edition required java editions according to the manifest files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// deno script.ts --allow-net --allow-write | |
const response = await fetch("https://piston-meta.mojang.com/mc/game/version_manifest_v2.json"); | |
const json = await response.json(); | |
const versions = new Map<string, string>(); | |
for (const version of json.versions) { | |
if (!(version.type === "release")) continue; | |
const response = await fetch(version.url); | |
const manifest = await response.json(); | |
if (!manifest.javaVersion) { | |
console.warn(`Warning: manifest.javaVersion is missing for version ${version.id}`); | |
continue; | |
} | |
console.log(version.id, manifest.javaVersion.majorVersion); | |
versions.set(version.id, manifest.javaVersion.majorVersion); | |
} | |
// write versions to file | |
await Deno.writeTextFile("versions.json", JSON.stringify(Object.fromEntries(versions), null, 4)); | |
interface MinecraftVersion { | |
major: number; | |
minor: number; | |
patch: number; | |
} | |
function parseMinecraftVersion(version: string): MinecraftVersion { | |
const [major, minor, patch] = version.split(".").map(Number); | |
return { | |
major: major || 0, | |
minor: minor || 0, | |
patch: patch || 0, | |
}; | |
} | |
function compareMinecraftVersions(a: MinecraftVersion, b: MinecraftVersion): number { | |
if (a.major !== b.major) return b.major - a.major; | |
if (a.minor !== b.minor) return b.minor - a.minor; | |
return b.patch - a.patch; | |
} | |
interface Range { | |
start: string; | |
end: string; | |
javaVersion: string; | |
} | |
const sortedVersions = Array.from(versions.entries()) | |
.map(([id, javaVersion]) => ({ | |
id, | |
javaVersion, | |
minecraftVersion: parseMinecraftVersion(id), | |
})) | |
.sort((a, b) => compareMinecraftVersions(a.minecraftVersion, b.minecraftVersion)); | |
const ranges: Range[] = []; | |
let currentRange: Range | null = null; | |
for (const { id, javaVersion } of sortedVersions) { | |
if (!currentRange) { | |
currentRange = { start: id, end: id, javaVersion }; | |
} else if (versions.get(currentRange.end) === javaVersion) { | |
currentRange.start = id; | |
} else { | |
ranges.push(currentRange); | |
currentRange = { start: id, end: id, javaVersion }; | |
} | |
} | |
if (currentRange) { | |
ranges.push(currentRange); | |
} | |
console.log("Ranges:", ranges); | |
// write ranges to file | |
await Deno.writeTextFile("ranges.json", JSON.stringify(ranges, null, 4)); | |
// Create a formatted table | |
const tableHeader = `| Range Start | Range End | Java Version |\n|-------------|-----------|--------------|\n`; | |
const tableRows = ranges | |
.map((range) => `| ${range.start} | ${range.end} | ${range.javaVersion} |`) | |
.join("\n"); | |
const formattedTable = tableHeader + tableRows; | |
// Write the formatted table to "version.txt" | |
await Deno.writeTextFile("version.txt", formattedTable); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"1.19.4": 17, | |
"1.19.3": 17, | |
"1.19.2": 17, | |
"1.19.1": 17, | |
"1.19": 17, | |
"1.18.2": 17, | |
"1.18.1": 17, | |
"1.18": 17, | |
"1.17.1": 16, | |
"1.17": 16, | |
"1.16.5": 8, | |
"1.16.4": 8, | |
"1.16.3": 8, | |
"1.16.2": 8, | |
"1.16.1": 8, | |
"1.16": 8, | |
"1.15.2": 8, | |
"1.15.1": 8, | |
"1.15": 8, | |
"1.14.4": 8, | |
"1.14.3": 8, | |
"1.14.2": 8, | |
"1.14.1": 8, | |
"1.14": 8, | |
"1.13.2": 8, | |
"1.13.1": 8, | |
"1.13": 8, | |
"1.12.2": 8, | |
"1.12.1": 8, | |
"1.12": 8, | |
"1.11.2": 8, | |
"1.11.1": 8, | |
"1.11": 8, | |
"1.10.2": 8, | |
"1.10.1": 8, | |
"1.10": 8, | |
"1.9.4": 8, | |
"1.9.3": 8, | |
"1.9.2": 8, | |
"1.9.1": 8, | |
"1.9": 8, | |
"1.8.9": 8, | |
"1.8.8": 8, | |
"1.8.7": 8, | |
"1.8.6": 8, | |
"1.8.5": 8, | |
"1.8.4": 8, | |
"1.8.3": 8, | |
"1.8.2": 8, | |
"1.8.1": 8, | |
"1.8": 8, | |
"1.7.10": 8, | |
"1.7.9": 8, | |
"1.7.8": 8, | |
"1.7.7": 8, | |
"1.7.6": 8, | |
"1.7.5": 8, | |
"1.7.4": 8, | |
"1.7.3": 8, | |
"1.7.2": 8, | |
"1.5.2": 8, | |
"1.5.1": 8, | |
"1.4.7": 8, | |
"1.4.6": 8, | |
"1.4.5": 8, | |
"1.4.4": 8, | |
"1.4.2": 8, | |
"1.3.2": 8, | |
"1.3.1": 8, | |
"1.2.5": 8, | |
"1.2.4": 8, | |
"1.2.3": 8, | |
"1.2.2": 8, | |
"1.2.1": 8, | |
"1.1": 8, | |
"1.0": 8 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment