Add #getSkinPart and #getJavaServerFavicon
This commit is contained in:
parent
d834badb78
commit
3e42ed414a
@ -1,9 +1,9 @@
|
||||
import { WebRequest } from "@/lib/webRequest";
|
||||
import { MojangServerStatus } from "@/types/mojang";
|
||||
import type { CachedPlayer } from "@/types/player";
|
||||
import { Platform } from "@/types/server";
|
||||
import { CachedBedrockMinecraftServer } from "@/types/server/bedrock-server";
|
||||
import { CachedJavaMinecraftServer } from "@/types/server/java-server";
|
||||
import { MojangServerStatus } from "../types/mojang";
|
||||
import { CachedPlayer, SkinPart } from "../types/player";
|
||||
import { CachedBedrockMinecraftServer } from "../types/server/bedrock-server";
|
||||
import { CachedJavaMinecraftServer } from "../types/server/java-server";
|
||||
import { Platform } from "../types/server/server";
|
||||
import { WebRequest } from "./webRequest";
|
||||
|
||||
/**
|
||||
* Get a player by their username or UUID.
|
||||
@ -14,6 +14,26 @@ import { CachedJavaMinecraftServer } from "@/types/server/java-server";
|
||||
export const getPlayer = (query: string): Promise<CachedPlayer> =>
|
||||
new WebRequest(`/player/${query}`).execute<CachedPlayer>();
|
||||
|
||||
/**
|
||||
* Get the part of a skin texture for
|
||||
* a player by their username or UUID.
|
||||
*
|
||||
* @param part the part of the player's skin to get
|
||||
* @param query the query to search for the player by
|
||||
* @param extension the skin part image extension
|
||||
* @param size the size of the skin part image
|
||||
* @returns the promised skin part texture
|
||||
*/
|
||||
export const getSkinPart = (
|
||||
part: SkinPart,
|
||||
query: string,
|
||||
extension: "png" | "jpg" = "png",
|
||||
size: number = 128
|
||||
): Promise<ArrayBuffer> =>
|
||||
new WebRequest(
|
||||
`/player/${part}/${query}.${extension}?size=${size}`
|
||||
).execute<ArrayBuffer>();
|
||||
|
||||
/**
|
||||
* Get a Minecraft server by its platform and hostname.
|
||||
*
|
||||
@ -25,7 +45,7 @@ export const getMinecraftServer = (
|
||||
platform: Platform,
|
||||
hostname: string
|
||||
): Promise<CachedJavaMinecraftServer | CachedBedrockMinecraftServer> =>
|
||||
platform === Platform.Java
|
||||
platform === Platform.JAVA
|
||||
? new WebRequest(
|
||||
`/server/${platform}/${hostname}`
|
||||
).execute<CachedJavaMinecraftServer>()
|
||||
@ -43,6 +63,16 @@ export const getMinecraftServer = (
|
||||
export const isMojangBlocked = (hostname: string): Promise<boolean> =>
|
||||
new WebRequest(`/server/blocked/${hostname}`).execute<boolean>();
|
||||
|
||||
/**
|
||||
* Get the icon of the Java Minecraft
|
||||
* server with the given hostname.
|
||||
*
|
||||
* @param hostname the hostname of the server
|
||||
* @returns the primised server icon
|
||||
*/
|
||||
export const getJavaServerFavicon = (hostname: string): Promise<ArrayBuffer> =>
|
||||
new WebRequest(`/server/icon/${hostname}`).execute<ArrayBuffer>();
|
||||
|
||||
/**
|
||||
* Get the status of Mojang servers.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user