From 57c36da79544a6371315f80a61a7084ccfa8fce5 Mon Sep 17 00:00:00 2001 From: simoleo89 Date: Sat, 6 Jun 2026 14:03:58 +0200 Subject: [PATCH] feat(furni-editor): mirror furnidata display name into items_base.public_name On a successful furnidata name update (10046), after the JSON write + 10047 broadcast, also UPDATE items_base.public_name to the new (sanitized) name and refresh the in-memory Item cache via loadItems() so Item.getFullName() stays consistent without a restart. Guarded by name != null (description-only edits never blank the column), runs only on the success path, outside FurnidataLock, with a parameterized statement. --- .../FurniEditorUpdateFurnidataEvent.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Emulator/src/main/java/com/eu/habbo/messages/incoming/furnieditor/FurniEditorUpdateFurnidataEvent.java b/Emulator/src/main/java/com/eu/habbo/messages/incoming/furnieditor/FurniEditorUpdateFurnidataEvent.java index 4607364e..fcdea56c 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/incoming/furnieditor/FurniEditorUpdateFurnidataEvent.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/incoming/furnieditor/FurniEditorUpdateFurnidataEvent.java @@ -139,6 +139,24 @@ public class FurniEditorUpdateFurnidataEvent extends MessageHandler { FurnidataLock.LOCK.unlock(); } + // 5b. Auto-mirror the new display name into items_base.public_name (DB) so the + // server-side fallback (Item.getFullName) and the editor's read-only + // "Public Name" field stay in sync with the furnidata edit. Only when a + // name was actually supplied (description-only edits must not blank it). + // Kept outside FurnidataLock (independent DB write, like the audit log). + if (name != null) { + try (Connection c = Emulator.getDatabase().getDataSource().getConnection(); + PreparedStatement st = c.prepareStatement("UPDATE items_base SET public_name = ? WHERE id = ?")) { + st.setString(1, FurnitureTextProvider.sanitize(safeName)); + st.setInt(2, itemId); + st.executeUpdate(); + // Refresh the in-memory Item cache (Item.fullName) in place — no restart needed. + Emulator.getGameEnvironment().getItemManager().loadItems(); + } catch (Exception e) { + LOGGER.warn("Failed to mirror furnidata name into items_base.public_name for item {}", itemId, e); + } + } + // 6. Audit log (outside lock — DB write, not latency-sensitive) FurnidataAuditLog.record( adminId,