Skip to content

Commit

Permalink
Save meta data
Browse files Browse the repository at this point in the history
  • Loading branch information
tastybento committed Jan 1, 2025
1 parent 373fb28 commit 85b6514
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ public void setHandler(Database<Players> handler) {
}

public void shutdown(){
// Save all players in cache
playerCache.forEach((uuid, player) -> handler.saveObject(player));
handler.close();
playerCache.shutdown();
}
Expand Down

0 comments on commit 85b6514

Please sign in to comment.