aboutsummaryrefslogtreecommitdiff
path: root/src/cleaners
diff options
context:
space:
mode:
authormat <27899617+mat-1@users.noreply.github.com>2021-04-27 20:02:26 -0500
committerGitHub <noreply@github.com>2021-04-27 20:02:26 -0500
commit39210646284cabc89256466646f8ea7834a78d31 (patch)
treee602e871a72681038e652907fefecf94ef82702f /src/cleaners
parent2b309975eec24b09dab95076c433e9392dc2e3ed (diff)
downloadskyblock-api-39210646284cabc89256466646f8ea7834a78d31.tar.gz
skyblock-api-39210646284cabc89256466646f8ea7834a78d31.tar.bz2
skyblock-api-39210646284cabc89256466646f8ea7834a78d31.zip
Add minion_count leaderboard (#15)
* add minion count leaderboard * fix error that happens sometimes * Update index.js
Diffstat (limited to 'src/cleaners')
-rw-r--r--src/cleaners/skyblock/inventory.ts1
-rw-r--r--src/cleaners/skyblock/member.ts2
-rw-r--r--src/cleaners/skyblock/profile.ts15
3 files changed, 15 insertions, 3 deletions
diff --git a/src/cleaners/skyblock/inventory.ts b/src/cleaners/skyblock/inventory.ts
index 5d72928..d23bbac 100644
--- a/src/cleaners/skyblock/inventory.ts
+++ b/src/cleaners/skyblock/inventory.ts
@@ -1,3 +1,4 @@
+// maybe todo?: create a fast replacement for prismarine-nbt
import * as nbt from 'prismarine-nbt'
function base64decode(base64: string): Buffer {
diff --git a/src/cleaners/skyblock/member.ts b/src/cleaners/skyblock/member.ts
index fb8132f..5d8d4f9 100644
--- a/src/cleaners/skyblock/member.ts
+++ b/src/cleaners/skyblock/member.ts
@@ -50,7 +50,7 @@ export async function cleanSkyBlockProfileMemberResponseBasic(member: any, inclu
/** Cleans up a member (from skyblock/profile) */
export async function cleanSkyBlockProfileMemberResponse(member, included: Included[] = null): Promise<CleanMember> {
// profiles.members[]
- const inventoriesIncluded = included == null || included.includes('inventories')
+ const inventoriesIncluded = included === null || included.includes('inventories')
const player = await cached.fetchPlayer(member.uuid)
if (!player) return
return {
diff --git a/src/cleaners/skyblock/profile.ts b/src/cleaners/skyblock/profile.ts
index 086cd31..433471b 100644
--- a/src/cleaners/skyblock/profile.ts
+++ b/src/cleaners/skyblock/profile.ts
@@ -45,7 +45,7 @@ export async function cleanSkyblockProfileResponseLighter(data): Promise<CleanPr
/**
* This function is somewhat costly and shouldn't be called often. Use cleanSkyblockProfileResponseLighter if you don't need all the data
*/
-export async function cleanSkyblockProfileResponse(data: any, options?: ApiOptions): Promise<CleanFullProfile> {
+export async function cleanSkyblockProfileResponse(data: any, options?: ApiOptions): Promise<CleanFullProfile|CleanProfile> {
// We use Promise.all so it can fetch all the users at once instead of waiting for the previous promise to complete
const promises: Promise<CleanMember>[] = []
@@ -54,12 +54,23 @@ export async function cleanSkyblockProfileResponse(data: any, options?: ApiOptio
memberRaw.uuid = memberUUID
promises.push(cleanSkyBlockProfileMemberResponse(
memberRaw,
- ['stats', options?.mainMemberUuid === memberUUID ? 'inventories' : undefined]
+ [
+ !options?.basic ? 'stats' : undefined,
+ options?.mainMemberUuid === memberUUID ? 'inventories' : undefined
+ ]
))
}
const cleanedMembers: CleanMember[] = (await Promise.all(promises)).filter(m => m !== null && m !== undefined)
+ if (options?.basic) {
+ return {
+ uuid: data.profile_id,
+ name: data.cute_name,
+ members: cleanedMembers,
+ }
+ }
+
const memberMinions: CleanMinion[][] = []
for (const member of cleanedMembers) {