diff --git a/JS-SDK/src/lib/restfulmc.ts b/JS-SDK/src/lib/restfulmc.ts index a638e9d..a7f8197 100644 --- a/JS-SDK/src/lib/restfulmc.ts +++ b/JS-SDK/src/lib/restfulmc.ts @@ -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 => new WebRequest(`/player/${query}`).execute(); +/** + * 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 => + new WebRequest( + `/player/${part}/${query}.${extension}?size=${size}` + ).execute(); + /** * Get a Minecraft server by its platform and hostname. * @@ -25,7 +45,7 @@ export const getMinecraftServer = ( platform: Platform, hostname: string ): Promise => - platform === Platform.Java + platform === Platform.JAVA ? new WebRequest( `/server/${platform}/${hostname}` ).execute() @@ -43,6 +63,16 @@ export const getMinecraftServer = ( export const isMojangBlocked = (hostname: string): Promise => new WebRequest(`/server/blocked/${hostname}`).execute(); +/** + * 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 => + new WebRequest(`/server/icon/${hostname}`).execute(); + /** * Get the status of Mojang servers. *