From b82e1d986cdb20952e26dd6153a0749b87c56b38 Mon Sep 17 00:00:00 2001 From: mat <27899617+mat-1@users.noreply.github.com> Date: Mon, 1 Mar 2021 14:21:53 -0600 Subject: add skills and zones as constants --- src/hypixelCached.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/hypixelCached.ts') diff --git a/src/hypixelCached.ts b/src/hypixelCached.ts index 4ddb07c..b407a69 100644 --- a/src/hypixelCached.ts +++ b/src/hypixelCached.ts @@ -20,13 +20,13 @@ const usernameCache = new NodeCache({ const basicProfilesCache = new NodeCache({ stdTTL: 60 * 10, checkperiod: 60, - useClones: false, + useClones: true, }) const playerCache = new NodeCache({ stdTTL: 60, checkperiod: 10, - useClones: false, + useClones: true, }) const profileCache = new NodeCache({ @@ -64,6 +64,10 @@ function waitForSet(cache: NodeCache, key?: string, value?: string): Promise { + // if the user is 32 characters long, it has to be a uuid + if (undashUuid(user).length === 32) + return undashUuid(user) + if (usernameCache.has(undashUuid(user))) { // check if the uuid is a key const username: any = usernameCache.get(undashUuid(user)) @@ -132,9 +136,8 @@ export async function fetchPlayer(user: string): Promise { if (!cleanPlayer) return // clone in case it gets modified somehow later - const cleanPlayerClone = Object.assign({}, cleanPlayer) - playerCache.set(playerUuid, cleanPlayerClone) - usernameCache.set(playerUuid, cleanPlayerClone.username) + playerCache.set(playerUuid, cleanPlayer) + usernameCache.set(playerUuid, cleanPlayer.username) return cleanPlayer } -- cgit