29 lines
637 B
TypeScript
29 lines
637 B
TypeScript
import fs from "fs"
|
|
|
|
interface Item {
|
|
id: number
|
|
id_aux: number
|
|
name: string
|
|
}
|
|
|
|
interface ItemAPI {
|
|
version: string
|
|
length: number
|
|
items: Item[]
|
|
}
|
|
|
|
async function main() {
|
|
const itemlist: string[] = ["export enum ItemAuxID {"]
|
|
|
|
const { items }: ItemAPI = await fetch("https://www.asakiyuki.com/api/minecraft/items/id").then(v => v.json())
|
|
for (const { name: fullname, id, id_aux } of items) {
|
|
const [namespace, name] = fullname.split(":")
|
|
const enumName = name.toUpperCase()
|
|
itemlist.push(` ${enumName} = ${id_aux},`)
|
|
}
|
|
|
|
itemlist.push("}")
|
|
fs.writeFileSync("src/types/enums/Items.ts", itemlist.join("\n"))
|
|
}
|
|
|
|
main()
|