diff --git a/src/lib/server/helper.ts b/src/lib/server/helper.ts index f3d2f4c01..d0a9b3004 100644 --- a/src/lib/server/helper.ts +++ b/src/lib/server/helper.ts @@ -108,7 +108,7 @@ export async function applyResourcePack(item: ProcessedItem, packs: string[]) { return item; } - // ? NOTE: we're ignoring enchanted books because they're quite expensive to render and not really useful the performance hit + // ? NOTE: we're ignoring enchanted books because they're quite expensive to render and not really worth the performance hit if (item.tag?.ExtraAttributes?.id === "ENCHANTED_BOOK") { const enchantedBookItem = getItemData({ id: 403 }) as ProcessedItem; const texture = getTexture(enchantedBookItem); diff --git a/src/lib/server/helper/item.ts b/src/lib/server/helper/item.ts index cacddc762..9d6528507 100644 --- a/src/lib/server/helper/item.ts +++ b/src/lib/server/helper/item.ts @@ -1,5 +1,4 @@ -import type { DatabaseItem, Item, ItemQuery } from "$types/stats"; -import sanitize from "mongo-sanitize"; +import type { Item, ItemQuery } from "$types/stats"; import * as constants from "../constants/constants"; /** @@ -24,31 +23,8 @@ function rgbToHex(rgb: string) { */ export function getItemData(query: ItemQuery) { query = Object.assign({ skyblockId: undefined, id: undefined, name: undefined, damage: undefined }, query); + const dbItem = query.skyblockId ? (constants.ITEMS.get(query.skyblockId) ?? {}) : {}; const item: Item = { id: -1, Damage: 0, Count: 1, tag: { ExtraAttributes: {} } }; - let dbItem: DatabaseItem = {}; - - if (query.skyblockId) { - query.skyblockId = sanitize(query.skyblockId); - - if (query.skyblockId !== undefined && query.skyblockId.includes(":")) { - const split = query.skyblockId.split(":"); - - query.skyblockId = split[0]; - query.damage = Number(split[1]); - } - - dbItem = { ...(item as unknown as DatabaseItem), ...constants.ITEMS.get(query.skyblockId) }; - } - - if (query && query.name !== undefined) { - const results = Object.values(constants.ITEMS) as DatabaseItem[]; - - const filteredResults = results.filter((a) => a.name && a.name.toLowerCase() == (query.name ?? "").toLowerCase()); - - if (filteredResults.length > 0) { - dbItem = filteredResults[0] ?? {}; - } - } if (query.id !== undefined) { item.id = query.id; @@ -78,6 +54,10 @@ export function getItemData(query: ItemQuery) { item.texture = dbItem.texture as string; } + if ("glowing" in dbItem || "shiny" in dbItem) { + item.glowing = true; + } + if (dbItem.item_id && dbItem.item_id >= 298 && dbItem.item_id <= 301) { const type = ["helmet", "chestplate", "leggings", "boots"][dbItem.item_id - 298]; if (dbItem.color !== undefined) { diff --git a/src/lib/server/stats/items/processing.ts b/src/lib/server/stats/items/processing.ts index 9aa79311a..0cdded410 100644 --- a/src/lib/server/stats/items/processing.ts +++ b/src/lib/server/stats/items/processing.ts @@ -72,8 +72,8 @@ function getCategories(type: string, item: Item) { // Process items returned by API export async function processItems(items: ProcessedItem[], source: string, packs: string[]): Promise { for (const item of items) { - if (!item.tag?.ExtraAttributes?.id) { - // continue; + if (!item.tag?.ExtraAttributes?.id && item.exp === undefined) { + continue; } // POTIONS @@ -116,7 +116,6 @@ export async function processItems(items: ProcessedItem[], source: string, packs } } - // Set HTML lore to be displayed on the website if (itemLore.length > 0 && item.tag.ExtraAttributes) { if (item.tag.ExtraAttributes.rarity_upgrades) { itemLore.push("ยง8(Recombobulated)"); @@ -147,7 +146,7 @@ export async function processItems(items: ProcessedItem[], source: string, packs } } - if (item?.tag || item?.exp) { + if (item.tag || item.exp !== undefined) { if (source.startsWith("storage_icons") === false) { try { const ITEM_PRICE = await getItemNetworth(item, { cache: true });