Skip to content

Template-editable Command Ranks panel (#3095) - #3096

Merged
tastybento merged 2 commits into
developfrom
feature/command-ranks-panel-3095
Sep 28, 2026
Merged

tastybento merged 2 commits into
developfrom
feature/command-ranks-panel-3095

Conversation

@tastybento

Copy link
Copy Markdown
Member

Closes #3095, a follow-up to #3092.

The Command Ranks panel, opened from the COMMAND_RANKS flag in /island settings, is now laid out by a panel template, as the settings panel has been since #3081.

Template

  • panels/command_ranks_panel.yml is installed to the BentoBox data folder on startup. A game mode's own panels/command_ranks_panel.yml takes precedence for that game mode.
  • Button types:
    • COMMAND — one slot of the paged list of rank-configurable commands. The template button can set icon (default MAP), title (name layout, with [name]) and description (lore layout, with [description]). The ranks are listed after the lore, and action tooltips are appended.
    • NEXT / PREVIOUS — paging.
  • The default template reproduces the old look: map icons, no filler, and only as many rows as the commands need. It pages at 45 commands instead of silently dropping everything after the 49th.
  • No new locale keys; it reuses protection.flags.COMMAND_RANKS.name, protection.panel.next/previous and the existing flag-item layouts.

Code

  • New CommandRanksPanel (panels/customizable), a PanelListener refreshed after every click like SettingsPanel, with the click cooldown on.
  • CommandRankClickListener opens it through the game mode's player command, which AbstractPanel needs for the plugin and the addon's template folder. It falls back to the old PanelBuilder layout, still capped at 49, when there is no player command or the template can't be loaded.
  • Public additions (@since 3.23.3): CommandRankClickListener.getCommands(World, User) and getPanelItemBuilder(String, User, World, Island, ItemTemplateRecord). The existing getPanelItem(String, User, World) is unchanged and delegates to the new builder.
  • Clicks are still handled by CommandCycleClick. Left and right cycle the rank, and shift-left lets an op hide a command.

Tests

  • CommandRanksPanelTest: default layout, paging across 50 commands, missing template, game mode template overriding title, icon and name layout.
  • CommandRankClickListenerTest: clicking the flag opens the templated panel when the game mode has a player command.
  • Full suite: 3581 tests, 0 failures.

Not tested in-game yet.

🤖 Generated with Claude Code

The Command Ranks panel, opened from the COMMAND_RANKS flag, is now laid
out by panels/command_ranks_panel.yml. The template is installed to the
BentoBox data folder, and a game mode can override it with its own copy.

- New CommandRanksPanel with COMMAND (paged command list), NEXT and
  PREVIOUS button types. A command button can override the icon, the
  name layout and the lore layout; tooltips are appended.
- The default template reproduces the old look (map icons, no filler,
  rows sized to fit), and pages at 45 instead of silently dropping every
  command after the 49th.
- CommandRankClickListener opens it through the game mode's player
  command and keeps the old PanelBuilder layout as the fallback when
  there is none or the template can't be loaded. getCommands and a
  template-aware getPanelItemBuilder are now public.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SonarCloud flagged duplicated lines on #3096:

- SettingsPanel and CommandRanksPanel carried the same lifecycle code
  (refresh after every click, close tracking, click cooldown, actionable
  slots, game mode template lookup). It now lives in
  AbstractRefreshingPanel, which both extend. Subclasses supply
  prepareRefresh(), and optionally titleParameters() and onClosed();
  SettingsPanel's deferred island saves end in onClosed(). Inserting the
  superclass keeps SettingsPanel binary compatible.
- BentoBox.loadSettings wrote each default panel template with its own
  copy of the same block; it now loops over DEFAULT_PANELS.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tastybento

Copy link
Copy Markdown
Member Author

Pushed 02227a7 to fix the SonarCloud duplication (27 new duplicated lines, 4.9%):

  • CommandRanksPanel ↔ SettingsPanel (24 lines): the shared "templated panel that redraws after every click" lifecycle is now in a new AbstractRefreshingPanel (@since 3.23.3), which both extend. That lifecycle covers refresh, close tracking, click cooldown, actionable slots and the game mode template lookup. Subclasses implement prepareRefresh() and may override titleParameters() and onClosed(). SettingsPanel ends its deferred island saves in onClosed(). Its public methods are unchanged, and getPanel() is now inherited, so it stays binary compatible.
  • BentoBox.loadSettings (3 lines): the eight copy-pasted "save default panel template" blocks are now one loop over DEFAULT_PANELS. The log messages and saved paths are the same.

Full suite still 3581 / 0 failures.

🤖 Generated with Claude Code

@sonarqubecloud

Copy link
Copy Markdown

@tastybento
tastybento merged commit 70551d0 into develop Sep 28, 2026
3 checks passed
@tastybento
tastybento deleted the feature/command-ranks-panel-3095 branch September 28, 2026 14:07
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.

Make the Command Ranks panel template-editable

1 participant