diff options
author | mat <github@matdoes.dev> | 2022-04-23 14:50:27 -0500 |
---|---|---|
committer | mat <github@matdoes.dev> | 2022-04-23 14:50:27 -0500 |
commit | 3a8393deb2f057e9b9601f23dc53b23913160e13 (patch) | |
tree | 27ebec4b7747c747c7b31a1652495fc9f5ab01e8 /src/cleaners/skyblock/inventory.ts | |
parent | ae55726abe66ef29fe410dc02e04db1bf6e99735 (diff) | |
download | skyblock-api-3a8393deb2f057e9b9601f23dc53b23913160e13.tar.gz skyblock-api-3a8393deb2f057e9b9601f23dc53b23913160e13.tar.bz2 skyblock-api-3a8393deb2f057e9b9601f23dc53b23913160e13.zip |
return better skin id in item list
Diffstat (limited to 'src/cleaners/skyblock/inventory.ts')
-rw-r--r-- | src/cleaners/skyblock/inventory.ts | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/cleaners/skyblock/inventory.ts b/src/cleaners/skyblock/inventory.ts index 9e5ee29..6be87c8 100644 --- a/src/cleaners/skyblock/inventory.ts +++ b/src/cleaners/skyblock/inventory.ts @@ -27,6 +27,16 @@ interface Item { export type Inventory = Item[] +export function headIdFromBase64(headDataBase64: string): string | undefined { + const headData = JSON.parse(base64decode(headDataBase64).toString()) + const headDataUrl = headData?.textures?.SKIN?.url + if (headDataUrl) { + const splitUrl = headDataUrl.split('/') + return splitUrl[splitUrl.length - 1] + } + return undefined +} + function cleanItem(rawItem): Item | null { // if the item doesn't have an id, it isn't an item if (rawItem.id === undefined) return null @@ -40,14 +50,8 @@ function cleanItem(rawItem): Item | null { if (vanillaId === 397) { const headDataBase64 = itemTag?.SkullOwner?.Properties?.textures?.[0]?.Value - if (headDataBase64) { - const headData = JSON.parse(base64decode(headDataBase64).toString()) - const headDataUrl = headData?.textures?.SKIN?.url - if (headDataUrl) { - const splitUrl = headDataUrl.split('/') - headId = splitUrl[splitUrl.length - 1] - } - } + if (headDataBase64) + headId = headIdFromBase64(headDataBase64) } return { |