Skip to content

Commit 40d036c

Browse files
Merge pull request #4 from OrnitheMC/update-develop
update develop page
2 parents 8ca8449 + 713f410 commit 40d036c

2 files changed

Lines changed: 136 additions & 51 deletions

File tree

public/develop.js

Lines changed: 134 additions & 49 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
}
@@ -150,26 +141,120 @@
150141
}
151142

152143
async function updateOrnitheDependencies() {
153-
setExtraMsg("");
154144
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");
145+
document.getElementById("ornithe-dependencies").innerText = await constructOrnitheDependenciesMessage();
170146
}
171147
}
172148

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

175260
versionSelectorInput.addEventListener("input", async _ => await updateOrnitheDependencies())
@@ -198,4 +283,4 @@
198283
updateVersionList()
199284
updateOrnitheDependencies()
200285

201-
})()
286+
})()

src/pages/develop.astro

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import Layout from "../layouts/Layout.astro";
1313
If you are updating the Loom or Ploceus version in <code
1414
>build.gradle</code
1515
> file, make sure their version match (example, Ploceus of version <code
16-
>1.5-SNAPSHOT</code
17-
> needs Loom to be of version <code>1.5-SNAPSHOT</code> as well)
16+
>1.9-SNAPSHOT</code
17+
> needs Loom to be of version <code>1.9-SNAPSHOT</code> as well)
1818
</p>
1919
<h2>Latest versions</h2>
2020
<div class="flex flex-col gap-2 items-start">

0 commit comments

Comments
 (0)