diff options
author | mat <27899617+mat-1@users.noreply.github.com> | 2021-03-01 14:21:53 -0600 |
---|---|---|
committer | mat <27899617+mat-1@users.noreply.github.com> | 2021-03-01 14:21:53 -0600 |
commit | b82e1d986cdb20952e26dd6153a0749b87c56b38 (patch) | |
tree | 4f1ea6b504d6f86beba1791f24c0fc9ab93246fc /src/hypixelCached.ts | |
parent | 8bb52e3318c92ed0e296757becc210bcf61e3c6d (diff) | |
download | skyblock-api-b82e1d986cdb20952e26dd6153a0749b87c56b38.tar.gz skyblock-api-b82e1d986cdb20952e26dd6153a0749b87c56b38.tar.bz2 skyblock-api-b82e1d986cdb20952e26dd6153a0749b87c56b38.zip |
add skills and zones as constants
Diffstat (limited to 'src/hypixelCached.ts')
-rw-r--r-- | src/hypixelCached.ts | 13 |
1 files changed, 8 insertions, 5 deletions
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<any * @param user A user can be either a uuid or a username */ export async function uuidFromUser(user: string): Promise<string> { + // 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<CleanPlayer> { 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 } |