Skip to content
This repository was archived by the owner on May 9, 2023. It is now read-only.

Commit 809a72d

Browse files
Update client
1 parent fcca211 commit 809a72d

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,12 @@ Use the following API to fetch versions:
1818
Example to latest bedrock: `curl -s https://mcpeversions.sirherobrine23.org/bedrock/latest` or search version: `curl -s https://mcpeversions.sirherobrine23.org/bedrock/search?version=1.18.1.02`
1919

2020
> Avaible to `/bedrock`, `/java`, `/pocketmine`, `/spigot`, `/paper` and `/powernukkit`.
21+
22+
### Static files
23+
24+
I'm releasing a static version of the versions to solve some problems.
25+
26+
> example:
27+
> `https://mcpeversion-static.sirherobrine23.org/{platform}/{version}.json`.
28+
>
29+
> `curl -s https://mcpeversion-static.sirherobrine23.org/bedrock/latest.json`.

src/index.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type { paperSchema } from "./db/paper";
55
import type { powernukkitSchema } from "./db/powernukkit";
66
import type { pocketminemmpSchema } from "./db/pocketmine";
77
import type { spigotSchema } from "./db/spigot";
8-
export const versionURLs = ["https://mcpeversions.sirherobrine23.org", "https://mcpeversions_backup.sirherobrine23.org", "http://168.138.140.152"];
8+
export const versionURLs = ["https://mcpeversion-static.sirherobrine23.org/", "https://mcpeversions.sirherobrine23.org", "https://mcpeversions_backup.sirherobrine23.org"];
99

1010
export type BdsCorePlatforms = "bedrock"|"java"|"paper"|"powernukkit"|"pocketmine"|"spigot";
1111
export type all = bedrockSchema|javaSchema|powernukkitSchema|paperSchema|pocketminemmpSchema|spigotSchema
@@ -23,9 +23,16 @@ export async function findVersion<PlatformSchema = all>(bdsPlaform: BdsCorePlatf
2323
export async function findVersion<PlatformSchema = all|all[]>(bdsPlaform: BdsCorePlatforms, version?: string|boolean): Promise<PlatformSchema> {
2424
for (let url of versionURLs) {
2525
url += "/"+bdsPlaform;
26-
if (typeof version !== "undefined") {
27-
if (typeof version === "boolean"||version === "latest") url += "/latest";
28-
else url += `/search?version=${version}`;
26+
if (/static/.test(url)) {
27+
if (version === undefined) url += "/all.json";
28+
else if (typeof version === "boolean") url += "/latest.json";
29+
else url += `/${version}.json`;
30+
31+
} else {
32+
if (typeof version !== "undefined") {
33+
if (typeof version === "boolean"||version === "latest") url += "/latest";
34+
else url += `/search?version=${version}`;
35+
}
2936
}
3037
const res = await httpRequests.fetchBuffer(url).catch(() => false);
3138
if (res === false) continue;

static_version.mjs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,41 +18,47 @@ if (!fsOld.existsSync(Paper)) await fs.mkdir(Paper, {recursive: true});
1818

1919
const bedrockData = await (await fetch("https://mcpeversions.sirherobrine23.org/bedrock")).json();
2020
fs.writeFile(path.join(Bedrock, "latest.json"), JSON.stringify(bedrockData.find(release => release.latest), null, 2));
21+
fs.writeFile(path.join(Bedrock, "all.json"), JSON.stringify(bedrockData, null, 2));
2122
await Promise.all(bedrockData.map(releases => {
2223
const version = path.join(Bedrock, `${releases.version}.json`);
2324
return fs.writeFile(version, JSON.stringify(releases, null, 2));
2425
}));
2526

2627
const PocketmineData = await (await fetch("https://mcpeversions.sirherobrine23.org/Pocketmine")).json();
2728
fs.writeFile(path.join(Pocketmine, "latest.json"), JSON.stringify(PocketmineData.find(release => release.latest), null, 2));
29+
fs.writeFile(path.join(Pocketmine, "all.json"), JSON.stringify(PocketmineData, null, 2));
2830
await Promise.all(PocketmineData.map(releases => {
2931
const version = path.join(Pocketmine, `${releases.version}.json`);
3032
return fs.writeFile(version, JSON.stringify(releases, null, 2));
3133
}));
3234

3335
const PowernukkitData = await (await fetch("https://mcpeversions.sirherobrine23.org/Powernukkit")).json();
3436
fs.writeFile(path.join(Powernukkit, "latest.json"), JSON.stringify(PowernukkitData.find(release => release.latest), null, 2));
37+
fs.writeFile(path.join(Powernukkit, "all.json"), JSON.stringify(PowernukkitData, null, 2));
3538
await Promise.all(PowernukkitData.map(releases => {
3639
const version = path.join(Powernukkit, `${releases.version}.json`);
3740
return fs.writeFile(version, JSON.stringify(releases, null, 2));
3841
}));
3942

4043
const JavaData = await (await fetch("https://mcpeversions.sirherobrine23.org/Java")).json();
4144
fs.writeFile(path.join(Java, "latest.json"), JSON.stringify(JavaData.find(release => release.latest), null, 2));
45+
fs.writeFile(path.join(Java, "all.json"), JSON.stringify(JavaData, null, 2));
4246
await Promise.all(JavaData.map(releases => {
4347
const version = path.join(Java, `${releases.version}.json`);
4448
return fs.writeFile(version, JSON.stringify(releases, null, 2));
4549
}));
4650

4751
const SpigotData = await (await fetch("https://mcpeversions.sirherobrine23.org/Spigot")).json();
4852
fs.writeFile(path.join(Spigot, "latest.json"), JSON.stringify(SpigotData.find(release => release.latest), null, 2));
53+
fs.writeFile(path.join(Spigot, "all.json"), JSON.stringify(SpigotData, null, 2));
4954
await Promise.all(SpigotData.map(releases => {
5055
const version = path.join(Spigot, `${releases.version}.json`);
5156
return fs.writeFile(version, JSON.stringify(releases, null, 2));
5257
}));
5358

5459
const PaperData = await (await fetch("https://mcpeversions.sirherobrine23.org/Paper")).json();
5560
fs.writeFile(path.join(Paper, "latest.json"), JSON.stringify(PaperData.find(release => release.latest), null, 2));
61+
fs.writeFile(path.join(Paper, "all.json"), JSON.stringify(PaperData, null, 2));
5662
await Promise.all(PaperData.map(releases => {
5763
const version = path.join(Paper, `${releases.version}_${releases.build}.json`);
5864
return fs.writeFile(version, JSON.stringify(releases, null, 2));

0 commit comments

Comments
 (0)