fix: use configured furni source and catalog assets
This commit is contained in:
1 parent
aed70db81f
commit
c78f8812ad
25 files changed
+368
-129
No files matched your search
@@ -3,7 +3,7 @@
|
||||
* (`habbo_gamedata_hotel`). Downloads once per hotel, keeps in memory.
|
||||
*/
|
||||
|
||||
export type { HabboItFurniEntry } from "@/types/furni";
|
||||
export type { OfficialHabboFurniEntry } from "@/types/furni";
|
||||
|
||||
import {
|
||||
type HabboGamedataHotel,
|
||||
@@ -11,21 +11,21 @@ import {
|
||||
} from "@/lib/habbo-gamedata-hotel";
|
||||
import { logger } from "@/lib/logger";
|
||||
import { getHabboGamedataHotel } from "@/lib/services/habbo-gamedata-hotel";
|
||||
import type { HabboItFurniEntry } from "@/types/furni";
|
||||
import type { OfficialHabboFurniEntry } from "@/types/furni";
|
||||
|
||||
const CACHE_TTL = 30 * 60 * 1000; // 30 minutes
|
||||
|
||||
let cache: Map<string, HabboItFurniEntry> | null = null;
|
||||
let cache: Map<string, OfficialHabboFurniEntry> | null = null;
|
||||
let cacheHotel: HabboGamedataHotel | null = null;
|
||||
let cacheTimestamp = 0;
|
||||
let loading: Promise<Map<string, HabboItFurniEntry>> | null = null;
|
||||
let loading: Promise<Map<string, OfficialHabboFurniEntry>> | null = null;
|
||||
|
||||
/**
|
||||
* Fetches and parses the full official Habbo furnidata JSON for the
|
||||
* configured hotel. Results are cached in memory for 30 minutes.
|
||||
*/
|
||||
export async function getHabboItFurnidata(): Promise<
|
||||
Map<string, HabboItFurniEntry>
|
||||
export async function getOfficialHabboFurnidata(): Promise<
|
||||
Map<string, OfficialHabboFurniEntry>
|
||||
> {
|
||||
const hotel = await getHabboGamedataHotel();
|
||||
const now = Date.now();
|
||||
@@ -51,7 +51,7 @@ export async function getHabboItFurnidata(): Promise<
|
||||
}
|
||||
|
||||
const data = await res.json();
|
||||
const map = new Map<string, HabboItFurniEntry>();
|
||||
const map = new Map<string, OfficialHabboFurniEntry>();
|
||||
|
||||
const roomTypes = data?.roomitemtypes?.furnitype;
|
||||
if (Array.isArray(roomTypes)) {
|
||||
@@ -137,10 +137,10 @@ export async function getHabboItFurnidata(): Promise<
|
||||
* Lookup a single item by classname from official Habbo furnidata.
|
||||
* Tries exact match first, then base classname (without color variant).
|
||||
*/
|
||||
export async function lookupHabboIt(
|
||||
export async function lookupOfficialHabboFurni(
|
||||
classname: string,
|
||||
): Promise<HabboItFurniEntry | null> {
|
||||
const map = await getHabboItFurnidata();
|
||||
): Promise<OfficialHabboFurniEntry | null> {
|
||||
const map = await getOfficialHabboFurnidata();
|
||||
|
||||
const exact = map.get(classname);
|
||||
if (exact) return exact;
|
||||
@@ -162,7 +162,7 @@ export async function lookupHabboIt(
|
||||
}
|
||||
|
||||
/** Clear the cache (e.g. after changing habbo_gamedata_hotel). */
|
||||
export function clearHabboItCache(): void {
|
||||
export function clearOfficialHabboFurnidataCache(): void {
|
||||
cache = null;
|
||||
cacheHotel = null;
|
||||
cacheTimestamp = 0;
|
||||
|
||||
Reference in new issue
Block a user