Skip to content
This repository has been archived by the owner on Oct 27, 2024. It is now read-only.

Add backpacks to inventories #223

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion src/cleaners/skyblock/inventory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,13 @@ export const INVENTORIES = {
personal_vault: 'personal_vault_contents'
}

export type Inventories = { [name in keyof typeof INVENTORIES]: Item[] }
export type Backpack = {
icon: Item | null,
items: Item[],
slot: string,
};

export type Inventories = { backpacks: Backpack[] } & { [name in keyof typeof INVENTORIES]: Item[] }

export async function cleanInventories(data: typedHypixelApi.SkyBlockProfileMember): Promise<Inventories> {
const cleanInventories: any = {}
Expand All @@ -125,5 +131,22 @@ export async function cleanInventories(data: typedHypixelApi.SkyBlockProfileMemb
cleanInventories[cleanInventoryName] = inventoryContents
}
}
const backpacks = data.backpack_contents
const backpackIcons = data.backpack_icons ?? {};
const cleanBackpacks: Backpack[] = [];
if (backpacks) {
for (const backpackId in backpacks) {
const backpack = backpacks[backpackId]
const contents = await cleanInventory(backpack.data)
const icon = backpackIcons[backpackId]

cleanBackpacks.push({
items: contents,
slot: backpackId,
icon: (icon && (await cleanInventory(icon.data))[0]) ?? null,
})
}
}
cleanInventories['backpacks'] = cleanBackpacks;
return cleanInventories
}