Skip to content

Commit 3620d15

Browse files
committed
update develop page
- fix handling of nests for pre-beta versions - remove nests line entirely if no nests are available (the note at the bottom still stays) - add raven and sparrow builds to the dependencies
1 parent 8ca8449 commit 3620d15

1 file changed

Lines changed: 131 additions & 47 deletions

File tree

public/develop.js

Lines changed: 131 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@
2727
return await getFromMeta("versions", "feather", mcVersion);
2828
}
2929

30+
async function getRavenVersionMeta(mcVersion) {
31+
return await getFromMeta("versions", "raven", mcVersion);
32+
}
33+
34+
async function getSparrowVersionMeta(mcVersion) {
35+
return await getFromMeta("versions", "sparrow", mcVersion);
36+
}
37+
3038
async function getNestsVersionMeta(mcVersion) {
3139
return await getFromMeta("versions", "nests", mcVersion);
3240
}
@@ -75,6 +83,20 @@
7583
.then(e => e !== undefined ? e.build : null);
7684
}
7785

86+
async function getLatestRavenBuild(mcVersion) {
87+
return await getRavenVersionMeta(mcVersion)
88+
.then(l => l.sort((e1, e2) => e2.build - e1.build))
89+
.then(([head, ..._]) => head)
90+
.then(e => e !== undefined ? e.build : null);
91+
}
92+
93+
async function getLatestSparrowBuild(mcVersion) {
94+
return await getSparrowVersionMeta(mcVersion)
95+
.then(l => l.sort((e1, e2) => e2.build - e1.build))
96+
.then(([head, ..._]) => head)
97+
.then(e => e !== undefined ? e.build : null);
98+
}
99+
78100
async function getLatestNestsBuild(mcVersion) {
79101
return await getNestsVersionMeta(mcVersion)
80102
.then(l => l.sort((e1, e2) => e2.build - e1.build))
@@ -106,41 +128,10 @@
106128
const versionListElement = document.getElementById("version-list");
107129
const allowSnapshotsCheck = document.getElementById("allow-snapshots");
108130

109-
async function getNestsFeatherBuilds(minecraftVersion) {
110-
const featherBuild = await getLatestFeatherBuild(minecraftVersion);
111-
if (featherBuild !== null) {
112-
const nestsBuild = await getLatestNestsBuild(minecraftVersion);
113-
addExtraMsg("Make sure to use the \"merged\" mod template for this Minecraft version!");
114-
if (nestsBuild === null)
115-
addExtraMsg("Nests are unavailable for this Minecraft version - make sure to edit your build.gradle appropriately!");
116-
return [
117-
`feather_build = ${featherBuild}`,
118-
nestsBuild ? `nests_build = ${nestsBuild}` : "# nests aren't used for this version"
119-
].join("\n");
120-
} else {
121-
addExtraMsg("Make sure to use the \"split\" mod template for this Minecraft version!");
122-
const featherBuildClient = await getLatestFeatherBuild(minecraftVersion + "-client");
123-
const featherBuildServer = await getLatestFeatherBuild(minecraftVersion + "-server");
124-
const nestsBuildClient = await getLatestNestsBuild(minecraftVersion + "-client");
125-
const nestsBuildServer = await getLatestNestsBuild(minecraftVersion + "-server");
126-
return [
127-
"",
128-
"### <project root>/client/gradle.properties",
129-
"environement = client",
130-
`feather_build = ${featherBuildClient}`,
131-
`nests_build = ${nestsBuildClient}`,
132-
"",
133-
"### <project root>/server/gradle.properties",
134-
"environment = server",
135-
`feather_build = ${featherBuildServer}`,
136-
`nests_build = ${nestsBuildServer}`
137-
].join("\n");
138-
}
139-
}
140-
141131
function setExtraMsg(message) {
142132
document.getElementById("dependencies-extra-message").innerText = message;
143133
}
134+
144135
function getExtraMsg() {
145136
return document.getElementById("dependencies-extra-message").innerText;
146137
}
@@ -152,24 +143,117 @@
152143
async function updateOrnitheDependencies() {
153144
setExtraMsg("");
154145
if (possibleVersions.some(version => versionSelectorInput.value === version)) {
155-
const loader = Object.entries(loaderSelectorRadios).find(([_, button]) => button.checked)[0];
156-
157-
const minecraftVersion = versionSelectorInput.value;
158-
const loaderVersion = await getLatestLoader(loader);
159-
const oslVersion = await getLatestOsl();
160-
const nestsFeatherBuildsStr = await getNestsFeatherBuilds(minecraftVersion);
161-
document.getElementById("ornithe-dependencies").innerText =
162-
[
163-
"### <project root>/gradle.properties",
164-
"# Dependencies",
165-
`minecraft_version = ${minecraftVersion}`,
166-
`loader_version = ${loaderVersion}`,
167-
`osl_version = ${oslVersion}`,
168-
nestsFeatherBuildsStr
169-
].join("\n");
146+
document.getElementById("ornithe-dependencies").innerText = await constructOrnitheDependenciesMessage(minecraftVersion);
170147
}
171148
}
172149

150+
async function constructOrnitheDependenciesMessage(minecraftVersion) {
151+
const lines = [
152+
"### <project root>/gradle.properties",
153+
"# Dependencies"
154+
];
155+
156+
const loader = Object.entries(loaderSelectorRadios).find(([_, button]) => button.checked)[0];
157+
158+
const minecraftVersion = versionSelectorInput.value;
159+
const loaderVersion = await getLatestLoader(loader);
160+
const oslVersion = await getLatestOsl();
161+
162+
lines.push(
163+
`minecraft_version = ${minecraftVersion}`,
164+
`loader_version = ${loaderVersion}`,
165+
`osl_version = ${oslVersion}`
166+
);
167+
168+
const featherBuild = await getLatestFeatherBuild(minecraftVersion);
169+
170+
if (featherBuild !== null) {
171+
addExtraMsg("Make sure to use the \"merged\" mod template for this Minecraft version!");
172+
173+
lines.concat(await getOrnitheDependenciesForMerged(minecraftVersion, featherBuild));
174+
} else {
175+
addExtraMsg("Make sure to use the \"split\" mod template for this Minecraft version!");
176+
177+
lines.concat(await getOrnitheDependenciesForSplit(minecraftVersion, "client"));
178+
lines.concat(await getOrnitheDependenciesForSplit(minecraftVersion, "server"));
179+
}
180+
181+
return lines.join("\n");
182+
}
183+
184+
async function getOrnitheDependenciesForSplit(minecraftVersion, featherBuild) {
185+
lines = [];
186+
187+
const ravenBuild = await getLatestRavenBuild(minecraftVersion);
188+
const sparrowBuild = await getLatestSparrowBuild(minecraftVersion);
189+
const nestsBuild = await getLatestNestsBuild(minecraftVersion);
190+
191+
lines.push(`feather_build = ${featherBuild}`);
192+
if (ravenBuild !== null) {
193+
lines.push(`raven_build = ${ravenBuild}`);
194+
} else {
195+
addExtraMsg("Raven is unavailable for this Minecraft version - make sure to edit your build.gradle appropriately!");
196+
}
197+
if (sparrowBuild !== null) {
198+
lines.push(`sparrow_build = ${sparrowBuild}`);
199+
} else {
200+
addExtraMsg("Sparrow is unavailable for this Minecraft version - make sure to edit your build.gradle appropriately!");
201+
}
202+
if (nestsBuild !== null) {
203+
lines.push(`nests_build = ${nestsBuild}`);
204+
} else {
205+
addExtraMsg("Nests are unavailable for this Minecraft version - make sure to edit your build.gradle appropriately!");
206+
}
207+
208+
return lines;
209+
}
210+
211+
async function getOrnitheDependenciesForMerged(minecraftVersion, environment) {
212+
const featherBuild = await getLatestFeatherBuild(`${minecraftVersion}-${environment}`);
213+
214+
if (featherBuild !== null) {
215+
const lines = [
216+
"",
217+
`### <project root>/${environment}/gradle.properties`,
218+
`environement = ${environment}`
219+
];
220+
221+
const ravenBuild = await getLatestRavenBuild(minecraftVersion);
222+
if (ravenBuild === null) {
223+
ravenBuild = await getLatestRavenBuild(`${minecraftVersion}-${environment}`);
224+
}
225+
const sparrowBuild = await getLatestSparrowBuild(minecraftVersion);
226+
if (sparrowBuild === null) {
227+
sparrowBuild = await getLatestSparrowBuild(`${minecraftVersion}-${environment}`);
228+
}
229+
const nestsBuild = await getLatestNestsBuild(minecraftVersion);
230+
if (nestsBuild === null) {
231+
nestsBuild = await getLatestNestsBuild(`${minecraftVersion}-${environment}`);
232+
}
233+
234+
lines.push(`feather_build = ${featherBuild}`);
235+
if (ravenBuild !== null) {
236+
lines.push(`raven_build = ${ravenBuild}`);
237+
} else {
238+
addExtraMsg(`Raven is unavailable on the ${environment} for this Minecraft version - make sure to edit your build.gradle appropriately!`);
239+
}
240+
if (sparrowBuild !== null) {
241+
lines.push(`sparrow_build = ${sparrowBuild}`);
242+
} else {
243+
addExtraMsg(`Sparrow is unavailable on the ${environment} for this Minecraft version - make sure to edit your build.gradle appropriately!`);
244+
}
245+
if (nestsBuild !== null) {
246+
lines.push(`nests_build = ${nestsBuild}`);
247+
} else {
248+
addExtraMsg(`Nests are unavailable on the ${environment} for this Minecraft version - make sure to edit your build.gradle appropriately!`);
249+
}
250+
251+
return lines;
252+
}
253+
254+
return [];
255+
}
256+
173257
Object.entries(loaderSelectorRadios).forEach(([_, button]) => button.addEventListener("change", async _ => await updateOrnitheDependencies()));
174258

175259
versionSelectorInput.addEventListener("input", async _ => await updateOrnitheDependencies())

0 commit comments

Comments
 (0)