Skip to content

Improve async user loading and leaderboard updates#5

Merged
CroaBeast merged 1 commit intomainfrom
codex/optimizar-consumo-de-recursos-de-cyberlevels
Nov 30, 2025
Merged

Improve async user loading and leaderboard updates#5
CroaBeast merged 1 commit intomainfrom
codex/optimizar-consumo-de-recursos-de-cyberlevels

Conversation

@CroaBeast
Copy link
Copy Markdown
Owner

Summary

  • move database and flat-file player loading/saving onto async tasks and debounce leaderboard refreshes
  • batch offline and online player loading to avoid large startup spikes
  • queue leaderboard updates instead of triggering an update for every loaded player

Testing

  • ./gradlew test (fails: gradle wrapper jar missing in repository)

Codex Task

@CroaBeast CroaBeast merged commit 34871fa into main Nov 30, 2025
@CroaBeast CroaBeast deleted the codex/optimizar-consumo-de-recursos-de-cyberlevels branch November 30, 2025 16:58
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

if (user == null) {
OfflinePlayer player = Bukkit.getPlayer(uuid);
if (player == null) player = Bukkit.getOfflinePlayer(uuid);
loadUser(player);
return users.get(uuid);

P0 Badge Update getUser(UUID) to call an existing loader

getUser(UUID) still calls loadUser(player) even though the refactor removed that method in favor of the new async loaders. With no matching method in this class, this call does not compile, so the project fails to build until the call is updated (e.g., use loadUserAsync/loadPlayer or restore the old helper).

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +358 to +362
" &7offline player(s) in &a" +
(System.currentTimeMillis() - l) +
"ms&7.", "");

scheduleLeaderboardUpdate();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Wait for offline async loads before refreshing leaderboard

loadOfflinePlayers now enqueues loadUserAsync calls but immediately logs completion and calls scheduleLeaderboardUpdate() once the queue is filled. Because user data is added to users later in finishUserLoad, the leaderboard update can run before the async loads finish, producing a stale leaderboard and misleading “loaded X players” timing when many offline users exist. The refresh should be triggered after the async callbacks complete.

Useful? React with 👍 / 👎.

Comment on lines 384 to +387
" &7online player(s) in &a" +
(System.currentTimeMillis() - l) +
"ms&7.", "");
scheduleLeaderboardUpdate();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Defer online leaderboard refresh until async loads finish

loadOnlinePlayers also enqueues asynchronous loadUserAsync calls but logs success and triggers scheduleLeaderboardUpdate() immediately afterward. finishUserLoad populates the users map on a later tick, so this update can run before the newly enqueued players are available, leaving the leaderboard temporarily missing online players. The refresh should be delayed until the async loads complete.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant