Skip to content

Refactor inventory GUI lifecycle and pagination - #292

Merged
BenCodez merged 23 commits into
masterfrom
refactor/inventory-gui-lifecycle
Aug 24, 2026
Merged

BenCodez merged 23 commits into
masterfrom
refactor/inventory-gui-lifecycle

Conversation

@BenCodez

@BenCodez BenCodez commented Aug 23, 2026 •

Copy link
Copy Markdown
Owner

Summary

Clean up the AdvancedCore inventory/GUI subsystem while preserving the existing BInventory public entry points and legacy async button callback behavior.

BInventory lifecycle

  • replace raw scheduled-future storage with typed task collections
  • retain the existing global addUpdatingButton(...) / cancelTimer() API
  • add per-viewer update-task ownership so closing or changing pages for one viewer does not cancel another viewer's updates
  • track delayed updating-button click refreshes with the same viewer lifecycle
  • make timer cancellation idempotent
  • preserve cleanup of legacy/unscoped update tasks on force close
  • simplify fill-slot population and button loading
  • simplify close/open thread handoff

Pagination

  • add InventoryPagination as the shared source of truth for page content size, page counts, and displayed-slot-to-source-slot mapping
  • fix the zero-based page-count boundary where the first item of a new page could still report the previous page count
  • clamp page opens to the current maximum page while continuing to reject page numbers below 1
  • keep page placeholders synchronized with the effective page/max page

Updating buttons

  • consolidate duplicate periodic/manual update implementations into one update pipeline
  • generate/apply Bukkit inventory updates through the Bukkit scheduler instead of from the scheduled executor thread
  • preserve periodic auto-cancellation when the GUI closes
  • preserve manual/click updates as non-cancelling requests

Click callback threading

  • keep GUI event preparation, cancellation, close handling, pagination and navigation on the Bukkit event thread
  • preserve existing button callback compatibility: BInventory button callbacks are asynchronous by default
  • add per-inventory opt-in synchronous callbacks with runClicksSync() or setClickAsync(false)
  • allow explicitly restoring async mode with runClicksAsync() / setClickAsync(true)

Listener/session cleanup

  • do not move Bukkit inventory/event preparation into async tasks
  • defer full-inventory follow-up with the Bukkit scheduler
  • simplify non-paged button lookup and paged navigation dispatch
  • make GUISession GUI ownership immutable
  • consistently validate page values in the constructor and setter

Tests

  • extend BInventoryTest for per-viewer timer isolation, legacy timer cleanup, and async-by-default/sync-opt-in click mode
  • add pagination boundary/mapping tests
  • add GUI session extraction/validation tests
  • add updating-button viewer scheduling coverage
  • add listener coverage for both legacy async callback dispatch and explicit synchronous callback dispatch

No reward behavior or reward configuration is changed by this PR.

@BenCodez
BenCodez marked this pull request as ready for review August 23, 2026 21:30

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 090e8b2509

ℹ️ 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".

@BenCodez
BenCodez merged commit e113035 into master Aug 24, 2026
4 checks passed
@BenCodez
BenCodez deleted the refactor/inventory-gui-lifecycle branch August 24, 2026 00:57
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.

1 participant