feat: paper channel badges (#5850)
This commit is contained in:
@@ -1,11 +1,9 @@
|
||||
import { $fetch } from 'ofetch'
|
||||
|
||||
import { AbstractModule } from '../../core/abstract-module'
|
||||
import type { LauncherMeta } from './types'
|
||||
|
||||
export type { LauncherMeta } from './types'
|
||||
|
||||
const BASE_URL = 'https://launcher-meta.modrinth.com'
|
||||
const LAUNCHER_META_BASE_URL = 'https://launcher-meta.modrinth.com'
|
||||
|
||||
export class LauncherMetaManifestV0Module extends AbstractModule {
|
||||
public getModuleID(): string {
|
||||
@@ -18,6 +16,11 @@ export class LauncherMetaManifestV0Module extends AbstractModule {
|
||||
* @param loader - Loader platform (fabric, forge, quilt, neo)
|
||||
*/
|
||||
public async getManifest(loader: string): Promise<LauncherMeta.Manifest.v0.Manifest> {
|
||||
return $fetch<LauncherMeta.Manifest.v0.Manifest>(`${BASE_URL}/${loader}/v0/manifest.json`)
|
||||
return this.client.request<LauncherMeta.Manifest.v0.Manifest>('/manifest.json', {
|
||||
api: LAUNCHER_META_BASE_URL,
|
||||
version: `${loader}/v0`,
|
||||
method: 'GET',
|
||||
skipAuth: true,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,8 +6,16 @@ export namespace Paper {
|
||||
versions: Record<string, string[]>
|
||||
}
|
||||
|
||||
export type BuildChannel = 'STABLE' | 'BETA' | 'ALPHA'
|
||||
|
||||
export type Build = {
|
||||
id: number
|
||||
time: string
|
||||
channel: BuildChannel | string
|
||||
}
|
||||
|
||||
export type VersionBuilds = {
|
||||
builds: number[]
|
||||
builds: Build[]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
import { $fetch } from 'ofetch'
|
||||
|
||||
import { AbstractModule } from '../../core/abstract-module'
|
||||
import type { Paper } from './types'
|
||||
|
||||
export type { Paper } from './types'
|
||||
|
||||
const BASE_URL = 'https://fill.papermc.io/v3'
|
||||
const PAPER_BASE_URL = 'https://fill.papermc.io'
|
||||
|
||||
export class PaperVersionsV3Module extends AbstractModule {
|
||||
public getModuleID(): string {
|
||||
@@ -16,17 +14,27 @@ export class PaperVersionsV3Module extends AbstractModule {
|
||||
* Get the Paper project info including all supported Minecraft versions.
|
||||
*/
|
||||
public async getProject(): Promise<Paper.Versions.v3.Project> {
|
||||
return $fetch<Paper.Versions.v3.Project>(`${BASE_URL}/projects/paper`)
|
||||
return this.client.request<Paper.Versions.v3.Project>('/projects/paper', {
|
||||
api: PAPER_BASE_URL,
|
||||
version: 'v3',
|
||||
method: 'GET',
|
||||
skipAuth: true,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Get available Paper builds for a Minecraft version.
|
||||
* Get available Paper builds for a Minecraft version (includes channel per build).
|
||||
*
|
||||
* Fill (`fill.papermc.io`) returns a JSON array of builds at this path — not a `{ builds }`
|
||||
* wrapper like some other Paper API shapes — so we normalize to `VersionBuilds`.
|
||||
*
|
||||
* @param mcVersion - Minecraft version (e.g. "1.21.4")
|
||||
*/
|
||||
public async getBuilds(mcVersion: string): Promise<Paper.Versions.v3.VersionBuilds> {
|
||||
return $fetch<Paper.Versions.v3.VersionBuilds>(
|
||||
`${BASE_URL}/projects/paper/versions/${mcVersion}`,
|
||||
const builds = await this.client.request<Paper.Versions.v3.Build[]>(
|
||||
`/projects/paper/versions/${mcVersion}/builds`,
|
||||
{ api: PAPER_BASE_URL, version: 'v3', method: 'GET', skipAuth: true },
|
||||
)
|
||||
return { builds }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
import { $fetch } from 'ofetch'
|
||||
|
||||
import { AbstractModule } from '../../core/abstract-module'
|
||||
import type { Purpur } from './types'
|
||||
|
||||
export type { Purpur } from './types'
|
||||
|
||||
const BASE_URL = 'https://api.purpurmc.org/v2'
|
||||
const PURPUR_BASE_URL = 'https://api.purpurmc.org'
|
||||
|
||||
export class PurpurVersionsV2Module extends AbstractModule {
|
||||
public getModuleID(): string {
|
||||
@@ -16,7 +14,12 @@ export class PurpurVersionsV2Module extends AbstractModule {
|
||||
* Get the Purpur project info including all supported Minecraft versions.
|
||||
*/
|
||||
public async getProject(): Promise<Purpur.Versions.v2.Project> {
|
||||
return $fetch<Purpur.Versions.v2.Project>(`${BASE_URL}/purpur`)
|
||||
return this.client.request<Purpur.Versions.v2.Project>('/purpur', {
|
||||
api: PURPUR_BASE_URL,
|
||||
version: 'v2',
|
||||
method: 'GET',
|
||||
skipAuth: true,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -25,6 +28,11 @@ export class PurpurVersionsV2Module extends AbstractModule {
|
||||
* @param mcVersion - Minecraft version (e.g. "1.21.4")
|
||||
*/
|
||||
public async getBuilds(mcVersion: string): Promise<Purpur.Versions.v2.VersionBuilds> {
|
||||
return $fetch<Purpur.Versions.v2.VersionBuilds>(`${BASE_URL}/purpur/${mcVersion}`)
|
||||
return this.client.request<Purpur.Versions.v2.VersionBuilds>(`/purpur/${mcVersion}`, {
|
||||
api: PURPUR_BASE_URL,
|
||||
version: 'v2',
|
||||
method: 'GET',
|
||||
skipAuth: true,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user