Skip to content

Add Flag.Builder minimumRank API#2936

Merged
tastybento merged 1 commit intodevelopfrom
flag-builder-minimum-rank
Apr 11, 2026
Merged

Add Flag.Builder minimumRank API#2936
tastybento merged 1 commit intodevelopfrom
flag-builder-minimum-rank

Conversation

@tastybento
Copy link
Copy Markdown
Member

Summary

  • New Flag.Builder.minimumRank(int) lets addons declare the lowest rank that may be selected for a PROTECTION flag (default VISITOR_RANK, so fully backwards-compatible).
  • The auto-assigned CycleClick listener is now constructed with the configured minimum, so the click-cycle in the settings panel will not let players select ranks below it (e.g. set minimumRank(MEMBER_RANK) to restrict a flag to Member/Sub-owner/Owner).
  • build() clamps defaultRank up to minimumRank (with a logged warning) so a misconfigured flag still has a selectable default.
  • Adds Flag.getMinimumRank() and Flag.getClickHandler() getters.

Test plan

  • ./gradlew test --tests "world.bentobox.bentobox.api.flags.*" — all green
  • New unit tests in FlagTest:
    • default minimumRank is VISITOR_RANK
    • Builder.minimumRank(MEMBER_RANK) is reflected on the built flag
    • the auto-assigned CycleClick carries the configured minimum (verified via reflection on the listener's minRank field)
    • defaultRank below minimumRank is clamped up

Notes

  • No changes to CycleClick — the existing two-arg constructor and rank-bound enforcement in leftClick/rightClick already handle this; the Builder just exposes it.
  • Binary-compatible: only additive methods, no signature or return-type changes.

🤖 Generated with Claude Code

Adds Flag.Builder.minimumRank(int) so addons can declare a minimum
selectable rank for a PROTECTION flag (default VISITOR_RANK). The
auto-assigned CycleClick listener is wired with the configured minimum
so the click cycle skips ranks below it. defaultRank is clamped up to
minimumRank to keep the flag's default value selectable.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@sonarqubecloud
Copy link
Copy Markdown

@tastybento tastybento merged commit 585965d into develop Apr 11, 2026
3 checks passed
@tastybento tastybento deleted the flag-builder-minimum-rank branch April 11, 2026 19:58
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