Files
Epicnabbo-Catalogus-Updated…/src/lib/habbo-gamedata-hotel.ts
T
SimoandCursor d1baaf798a Add multi-hotel Habbo gamedata locale in CMS settings.
Furni name suggestions, import enrichment, and badge texts now follow habbo_gamedata_hotel instead of hardcoded habbo.it.

Co-authored-by: Cursor <[email protected]>
2026-07-17 22:28:18 +02:00

58 lines
2.1 KiB
TypeScript

/** Official Habbo hotel TLDs used for gamedata (furnidata / external texts). */
export const HABBO_GAMEDATA_HOTELS = [
{ value: "it", label: "Italy (habbo.it)" },
{ value: "com", label: "International (habbo.com)" },
{ value: "es", label: "Spain (habbo.es)" },
{ value: "de", label: "Germany (habbo.de)" },
{ value: "fr", label: "France (habbo.fr)" },
{ value: "fi", label: "Finland (habbo.fi)" },
{ value: "nl", label: "Netherlands (habbo.nl)" },
{ value: "com.br", label: "Brazil (habbo.com.br)" },
{ value: "com.tr", label: "Turkey (habbo.com.tr)" },
] as const;
export type HabboGamedataHotel =
(typeof HABBO_GAMEDATA_HOTELS)[number]["value"];
export const HABBO_GAMEDATA_HOTEL_SETTING_KEY = "habbo_gamedata_hotel";
export const DEFAULT_HABBO_GAMEDATA_HOTEL: HabboGamedataHotel = "it";
const ALLOWED = new Set<string>(HABBO_GAMEDATA_HOTELS.map((h) => h.value));
export function normalizeHabboGamedataHotel(
raw: string | null | undefined,
): HabboGamedataHotel {
const v = (raw ?? "").trim().toLowerCase();
if (ALLOWED.has(v)) return v as HabboGamedataHotel;
return DEFAULT_HABBO_GAMEDATA_HOTEL;
}
export function habboGamedataHotelLabel(hotel: string): string {
const found = HABBO_GAMEDATA_HOTELS.find((h) => h.value === hotel);
return found?.label ?? `habbo.${hotel}`;
}
/** Short badge for buttons, e.g. IT / COM / COM.BR */
export function habboGamedataHotelShort(hotel: string): string {
return normalizeHabboGamedataHotel(hotel).toUpperCase();
}
export function habboFurnidataUrl(hotel: string): string {
const h = normalizeHabboGamedataHotel(hotel);
return `https://www.habbo.${h}/gamedata/furnidata_json/1`;
}
export function habboExternalTextsUrl(hotel: string): string {
const h = normalizeHabboGamedataHotel(hotel);
return `https://www.habbo.${h}/gamedata/external_flash_texts/1`;
}
export async function getHabboGamedataHotel(): Promise<HabboGamedataHotel> {
const { siteSettings } = await import("@/lib/services/site-settings");
const raw = await siteSettings.get(
HABBO_GAMEDATA_HOTEL_SETTING_KEY,
DEFAULT_HABBO_GAMEDATA_HOTEL,
);
return normalizeHabboGamedataHotel(raw);
}