Lay dialog buttons out in a grid: columns and button width - #3066
Merged
Conversation
DialogBuilder could only produce Paper's default two-wide list of buttons, because it never passed a column count and never passed a button width. Anything grid-shaped — a map, a picker, a calendar — had to skip the API and build a Paper dialog by hand. Adds DialogBuilder#columns(int) for the layout and a DialogButton constructor taking a width, plus withWidth() so a button made by the locale factory can still be sized. Width applies to confirmation buttons too, which the client also sizes. Both keep the current behaviour when untouched: a dialog left at DEFAULT_COLUMNS is built without stating a column count and a button left at DEFAULT_WIDTH without stating a width, so the client goes on deciding and this API does not pin whatever default Paper uses today. Values outside what the client accepts (columns < 1, width outside 1-1024) are rejected here with a clear message rather than deeper in Paper. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017EZEwab2kL4i1FNnBYvSmp
|
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



DialogBuildercan only produce Paper's default two-wide list of buttons: it never passes a column count and never passes a button width. Anything grid-shaped — a map, a picker, a calendar, a seat chooser — has to skip the API and build a Paper dialog by hand. That is what ChunkBlock ended up doing for its territory map, where every chunk is a button and the grid has to be as wide as the map.What's added
DialogBuilder#columns(int)— lays a multi-action dialog's buttons out in that many columns.new DialogButton(label, tooltip, width, onClick)— a button of a given width, matching Paper'sActionButton.createparameter order. PlusDialogButton#withWidth(int), so a button made byDialogButton.of(user, key, handler)can still be sized, andDialogButton#width().Width applies to confirmation buttons too — the client sizes those the same way.
Behaviour when untouched
Nothing changes for existing callers, and deliberately not by re-stating today's defaults:
DEFAULT_COLUMNSis built without a column countDEFAULT_WIDTHis built without a widthSo the client keeps deciding, and this API does not pin whatever default Paper happens to use. The two constants are public because callers need to be able to say "leave it alone" explicitly.
Validation
Values the client would reject are rejected here first, with a message that says which value was wrong:
columns < 1, and width outside Paper's documented 1–1024 range.Tests
DialogBuilderTestgains six cases: default widths (constructor and locale factory), a width that sticks,withWidthcopying everything else and leaving the original alone, out-of-range widths and both ends of the valid range, andcolumnsbeing fluent and validated. Whole suite green — 3462 tests.Note the limitation the test class already documents:
build()needs the server's dialog registry provider, which MockBukkit does not supply, so the tests cover the builder's own logic rather than the finished Paper object. The two new values reach Paper throughMultiActionType.Builder#columnsandActionButton.Builder#width; the grid itself has been exercised in game via ChunkBlock's map, which drives those same two Paper calls directly today and will switch to this API once it is released.🤖 Generated with Claude Code
https://claude.ai/code/session_017EZEwab2kL4i1FNnBYvSmp