User report: Twilight Forest 'Charm of Keeping' + ReviveMe interaction loses
inventory over multiple deaths. Analysis concludes this is a Twilight/ReviveMe
event-priority interaction, not a PlayerSync bug — but two dead config options
hid admin-facing levers that help mitigate the case.
(1) save_on_death was declared in JdbcConfig but NEVER read in code. The death
snapshot ran unconditionally. Now gated: setting save_on_death=false
disables the LivingDeathEvent-driven pre-drop snapshot. The normal
onPlayerLogout save still fires on disconnect, so nothing is lost — but
admins diagnosing a keeping-charm interaction can quickly turn off the
aggressive death snapshot to rule PlayerSync in or out.
(2) save_on_respawn was also declared but never read. Added a new
@SubscribeEvent PlayerEvent.PlayerRespawnEvent handler that calls
snapshotAndQueueSave(player, 'RESPAWN') after the respawn completes.
This captures the post-death state AFTER keeping-charms / Corail
Tombstone / similar mods have restored their preserved items, so
PlayerSync's DB row reflects the actual post-respawn inventory rather
than the pre-drop snapshot from onPlayerDeath.
Excludes end-portal exit (isEndConquered) since that's not a death
respawn — no need to overwrite.
Combined effect: if a player dies, charm-keeps items, respawns, the DB
ends up with:
t=0 death snapshot (pre-drop, full inventory)
t=X respawn snapshot (post-drop, kept items + whatever charm restored)
The respawn snapshot overwrites the death one by virtue of running later.
A disconnect between t=0 and t=X still saves via onPlayerLogout anyway,
so no loss window opens.
No change to the duplication-safety guarantees from Phases 15-18:
onPlayerDeath still checks event.isCanceled() for ReviveMe, the RESPAWN
snapshot goes through the normal snapshotAndQueueSave pipeline with all
the P0-a/b/c guards and the 2-phase-commit logout_started_at tracking.
Answer to the user's question: the keep-charm inventory loss is
overwhelmingly likely to be a ReviveMe x Twilight Forest event-priority
bug outside PlayerSync's control, but this commit exposes two levers
(save_on_death, save_on_respawn) that let admins test whether PlayerSync
is contributing — setting save_on_death=false should make the symptom
unchanged if the root cause is external.