diff options
Diffstat (limited to 'src/hypixelCached.ts')
-rw-r--r-- | src/hypixelCached.ts | 14 |
1 files changed, 0 insertions, 14 deletions
diff --git a/src/hypixelCached.ts b/src/hypixelCached.ts index 3dc89a3..c347a1a 100644 --- a/src/hypixelCached.ts +++ b/src/hypixelCached.ts @@ -143,32 +143,18 @@ export async function usernameFromUser(user: string): Promise<string> { return username } -let fetchingPlayers: Set<string> = new Set() export async function fetchPlayer(user: string): Promise<CleanPlayer> { const playerUuid = await uuidFromUser(user) - if (playerCache.has(playerUuid)) return playerCache.get(playerUuid) - // if it's already in the process of fetching, check every 100ms until it's not fetching the player anymore and fetch it again, since it'll be cached now - if (fetchingPlayers.has(playerUuid)) { - while (fetchingPlayers.has(playerUuid)) { - await new Promise(resolve => setTimeout(resolve, 100)) - } - return await fetchPlayer(user) - } - - fetchingPlayers.add(playerUuid) - const cleanPlayer: CleanPlayer = await hypixel.sendCleanApiRequest({ path: 'player', args: { uuid: playerUuid } }) - fetchingPlayers.delete(playerUuid) - if (!cleanPlayer) return // clone in case it gets modified somehow later |