update data file when players leave and join

This commit is contained in:
rockyhawk64 2025-10-12 10:51:42 +11:00
parent 4b1a7c87f8
commit 8b80ab0ed3

View File

@ -15,14 +15,20 @@ public class SessionDataUtils implements Listener {
this.ctx = ctx; this.ctx = ctx;
} }
/**
* On player Join and Leave,
* Remove Session data and do an async save of the data file
*/
@EventHandler @EventHandler
public void onJoinEvent(PlayerJoinEvent e) { public void onJoinEvent(PlayerJoinEvent e) {
removeSessionData(e.getPlayer()); removeSessionData(e.getPlayer());
ctx.dataLoader.saveDataFileAsync();
} }
@EventHandler @EventHandler
public void onQuitEvent(PlayerQuitEvent e) { public void onQuitEvent(PlayerQuitEvent e) {
removeSessionData(e.getPlayer()); removeSessionData(e.getPlayer());
ctx.dataLoader.saveDataFileAsync();
} }
private void removeSessionData(Player p){ private void removeSessionData(Player p){