Skip to content

Defer island saves until settings panel closes; apply click cooldown to all buttons#2926

Merged
tastybento merged 2 commits intodevelopfrom
copilot/add-cooldown-to-settings-buttons
Apr 8, 2026
Merged

Defer island saves until settings panel closes; apply click cooldown to all buttons#2926
tastybento merged 2 commits intodevelopfrom
copilot/add-cooldown-to-settings-buttons

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 7, 2026

Rapid clicking on settings menu buttons causes severe TPS drops (2-3 TPS with two players) because every flag change triggers an immediate database write via Island.setChanged()IslandsManager.updateIsland(), and the existing click cooldown only applied to tab switches after click handlers already executed.

Deferred saves (Island.java, TabbedPanel.java)

  • Added reference-counted beginDeferSaves()/endDeferSaves() on Island — while deferred, setChanged() marks dirty but skips the DB write
  • TabbedPanel begins deferring on first open, ends on true close (single save)
  • refreshing flag distinguishes panel rebuilds from actual inventory close events
// Island now batches saves
island.beginDeferSaves();
// ... many setFlag() / toggleFlag() calls — no DB writes ...
island.endDeferSaves(); // single save if changed

Click cooldown moved upstream (PanelListenerManager.java)

  • onTimeout check moved from TabbedPanel.onInventoryClick() to PanelListenerManager.onInventoryClick() before click handlers and panel refresh execute
  • Scoped to TabbedPanel listeners only — other panels unaffected
  • Previously the cooldown ran after handlers, so flag changes and expensive panel rebuilds still happened on every rapid click

Copilot AI linked an issue Apr 7, 2026 that may be closed by this pull request
- Add beginDeferSaves()/endDeferSaves() to Island to batch flag changes
  into a single database save when the panel is closed
- Move click cooldown check from TabbedPanel to PanelListenerManager
  so it runs before click handlers and panel refresh
- TabbedPanel tracks refreshing state to distinguish true close from
  refresh close for deferred save handling
- Add tests for defer save mechanism and timeout check

Agent-Logs-Url: https://github.com/BentoBoxWorld/BentoBox/sessions/4f416153-32a9-45a2-bc46-568b590c8266

Co-authored-by: tastybento <4407265+tastybento@users.noreply.github.com>
Copilot AI changed the title [WIP] Add cooldown to all buttons in settings menu Defer island saves until settings panel closes; apply click cooldown to all buttons Apr 7, 2026
Copilot AI requested a review from tastybento April 7, 2026 17:39
@tastybento tastybento marked this pull request as ready for review April 8, 2026 01:21
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 8, 2026

@tastybento tastybento merged commit eb37380 into develop Apr 8, 2026
3 checks passed
@tastybento tastybento deleted the copilot/add-cooldown-to-settings-buttons branch April 8, 2026 01:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Crash the server via the menu

2 participants