You've already forked Arcturus-Morningstar-Extended
mirror of
https://github.com/duckietm/Arcturus-Morningstar-Extended.git
synced 2026-06-19 15:06:19 +00:00
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.
This commit is contained in:
+18
@@ -139,6 +139,24 @@ public class FurniEditorUpdateFurnidataEvent extends MessageHandler {
|
|||||||
FurnidataLock.LOCK.unlock();
|
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)
|
// 6. Audit log (outside lock — DB write, not latency-sensitive)
|
||||||
FurnidataAuditLog.record(
|
FurnidataAuditLog.record(
|
||||||
adminId,
|
adminId,
|
||||||
|
|||||||
Reference in New Issue
Block a user