Skip to content

Commit

Permalink
Add filtering for Fabric loader versions below 0.12
Browse files Browse the repository at this point in the history
  • Loading branch information
undeadjess committed Oct 17, 2024
1 parent 8fbf3b1 commit 92ef667
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions fetcher/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,38 @@ async function getFabricServerURLs() {
for (const minecraftVersion of supportedMinecraftVersions) {
// data structure: {version: "1.16.4", builds: [{build: 1, fabricLoaderVersion: "something", downloadURL: "something"}]}
const fabricServerURLsForVersion = [];
// let buildCounter = 1;

// filter out any loader versions below 0.12
fabricLoaderVersions = fabricLoaderVersions.map(version => {
// split the version string into an array of numbers
const versionNumbers = version.split('.').map(Number)
// discard any array items after the first 2
versionNumbers.length = 2;
// check if the second number is less than 12, else return the version
if (versionNumbers[1] < 12) {
return;
} else {
return version;
}
})
// remove any undefined values
.filter(Boolean)
// sort the subversions - 0.14.11 is 2 versions ahead of 0.14.9
.sort((a, b) => {
const aNumbers = a.split('.').map(Number);
const bNumbers = b.split('.').map(Number);

for (let i = 0; i < Math.max(aNumbers.length, bNumbers.length); i++) {
const diff = (aNumbers[i] || 0) - (bNumbers[i] || 0);
if (diff !== 0) return diff;
}
return 0;
});

for (const fabricLoaderVersion of fabricLoaderVersions) {
const downloadURL = (`https://meta.fabricmc.net/v2/versions/loader/${minecraftVersion}/${fabricLoaderVersion}/${installerVersion}/server/jar`);

fabricServerURLsForVersion.push({
// build: buildCounter++,
build: fabricLoaderVersion,
downloadURL: downloadURL
});
Expand Down

0 comments on commit 92ef667

Please sign in to comment.