From 0cf52fcd6876a0176504de41b7de16851c529694 Mon Sep 17 00:00:00 2001 From: Neutronic Date: Sun, 27 Oct 2024 15:47:25 -0700 Subject: [PATCH] feat: add player search endpoint --- package.json | 2 +- src/index.ts | 11 +++++++++-- src/player/data.ts | 6 ++++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 185c4c7..0c6dae4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hive-tools-wrapper", - "version": "5.3.0", + "version": "5.5.0", "description": "Type-safe wrapper for the Hive Bedrock API", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/src/index.ts b/src/index.ts index 0dc7e4f..2f98b70 100644 --- a/src/index.ts +++ b/src/index.ts @@ -14,7 +14,7 @@ import { AllTimeStatsProcessors, MonthlyStatsProcessors } from "./games/processors"; -import { Player } from "./player/data"; +import { Player, PlayerSearchResult } from "./player/data"; import { GameMap } from "./map/data"; const cachedResponses: { @@ -360,9 +360,16 @@ export async function getGameMetainfo( return await fetchData(`/game/meta/${game}`, controller, init); } +export async function searchPlayer( + partial: string, + controller?: AbortController, + init?: RequestInit +): Promise { + return await fetchData(`/player/search/${partial}`, controller, init); +} + export * from "./games/data"; export * from "./games/info"; export * from "./games/processors"; export * from "./map/data"; export * from "./player/data"; - diff --git a/src/player/data.ts b/src/player/data.ts index fe0ded9..cc0e1e4 100644 --- a/src/player/data.ts +++ b/src/player/data.ts @@ -83,3 +83,9 @@ export type Player = { pets: string[]; mounts: string[]; }; + +export type PlayerSearchResult = { + UUID: string; + username: string; + username_cc: string; +};