From 85b65141faa4fb8deb4ec6e99e74a4c38f71fd26 Mon Sep 17 00:00:00 2001 From: tastybento Date: Wed, 1 Jan 2025 11:13:15 -0800 Subject: [PATCH] Save meta data --- .../world/bentobox/bentobox/listeners/JoinLeaveListener.java | 5 ++++- .../world/bentobox/bentobox/managers/PlayersManager.java | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/world/bentobox/bentobox/listeners/JoinLeaveListener.java b/src/main/java/world/bentobox/bentobox/listeners/JoinLeaveListener.java index cb88fda96..48a877cce 100644 --- a/src/main/java/world/bentobox/bentobox/listeners/JoinLeaveListener.java +++ b/src/main/java/world/bentobox/bentobox/listeners/JoinLeaveListener.java @@ -41,6 +41,7 @@ public JoinLeaveListener(@NonNull BentoBox plugin) { players = plugin.getPlayers(); } + @SuppressWarnings("deprecation") @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onPlayerJoin(final PlayerJoinEvent event) { // Remove them from the cache, just in case they were not removed for some @@ -69,7 +70,7 @@ public void onPlayerJoin(final PlayerJoinEvent event) { // Reset island resets if required plugin.getIWM().getOverWorlds().stream() - .filter(w -> event.getPlayer().getLastPlayed() < plugin.getIWM().getResetEpoch(w)) + .filter(w -> event.getPlayer().getLastSeen() < plugin.getIWM().getResetEpoch(w)) .forEach(w -> players.setResets(w, playerUUID, 0)); // Update the island range of the islands the player owns @@ -271,6 +272,8 @@ public void onPlayerQuit(final PlayerQuitEvent event) { // Remove any onisland placeholder plugin.getAddonsManager().getGameModeAddons().forEach(addon -> plugin.getPlaceholdersManager() .unregisterPlaceholder(addon, "onisland_" + event.getPlayer().getName())); + // Save player on exit + plugin.getPlayers().savePlayer(event.getPlayer().getUniqueId()); User.removePlayer(event.getPlayer()); } } diff --git a/src/main/java/world/bentobox/bentobox/managers/PlayersManager.java b/src/main/java/world/bentobox/bentobox/managers/PlayersManager.java index 0cf8945c1..2a1f7f5b4 100644 --- a/src/main/java/world/bentobox/bentobox/managers/PlayersManager.java +++ b/src/main/java/world/bentobox/bentobox/managers/PlayersManager.java @@ -60,6 +60,8 @@ public void setHandler(Database handler) { } public void shutdown(){ + // Save all players in cache + playerCache.forEach((uuid, player) -> handler.saveObject(player)); handler.close(); playerCache.shutdown(); }