Skip to content

Conversation

@Machine-Maker
Copy link
Member

@Machine-Maker Machine-Maker commented Jun 15, 2025

Adds 2 temporary methods to show/clear dialogs from a Player. Will be replaced by adventure methods.

Player#tempShowDialog and Player#tempClearDialog.

@Machine-Maker Machine-Maker requested a review from a team as a code owner June 15, 2025 00:47
@github-project-automation github-project-automation bot moved this to Awaiting review in Paper PR Queue Jun 15, 2025
Base automatically changed from dev/1.21.6 to main June 17, 2025 14:00
@jpenilla jpenilla added the publish-pr Enables a workflow to build Paperclip jars on the pull request. label Jun 19, 2025
@papermc-pr-publishing
Copy link

papermc-pr-publishing bot commented Jun 19, 2025

Last updated for: ade079827c0165ac5b943f4fecc0f6c7370b4c6c.

Download the Paperclip jar for this pull request: paper-12671.zip

Maven Publication

The artifacts published by this PR:

Repository Declaration

In order to use the artifacts published by the PR, add the following repository to your buildscript:

repositories {
    maven("https://maven-prs.papermc.io/Paper/pr12671") {
        name = "Maven for PR #12671" // https://github.com/PaperMC/Paper/pull/12671
        mavenContent {
            includeModule("io.papermc.paper", "dev-bundle")
            includeModule("io.papermc.paper", "paper-api")
        }
    }
}

@Machine-Maker
Copy link
Member Author

Something we need to decide is how to handle the "custom all" dialog action. This is the action that sends a full CompoundTag of all the input values back to the server using the new packet. Right now, there's no way to listen for these.

Do we just add an event for both config/game phase that includes the player its from, the id of the payload, and the BinaryTagHolder payload? Or do we do smth like adventure click callback provider?

@Phoenix616
Copy link
Contributor

Phoenix616 commented Jun 20, 2025

Do we just add an event for both config/game phase that includes the player its from, the id of the payload, and the BinaryTagHolder payload? Or do we do smth like adventure click callback provider?

I personally would prefer to at least have an event if that allows listening to arbitrary dialogs too but a way to directly react on some form of callback directly from the code that creates the dialog in a plugin would be nice too but I feel the event would be more important. Ideally the data would be in a format that can be easily read e.g. a key -> value map instead of raw NBT.

@Privatech38
Copy link
Contributor

Width and height range

There really should be org.jetbrains.annotations.Range annotations or javadoc comments stating that the width and height parameters should be at least 1 and max of whatever it is, most commonly it's 1024, but there are exceptions where it's less. For example the width and height parameters for DialogBody.ItemBody have a max value of 256.

These numbers are from the minecraft wiki.

Default values

One other thing I'd like to see is default values being used. So you don't have to specify width/height and use the default.

@Machine-Maker
Copy link
Member Author

Ok, I pushed a super duper rough concept of the PlayerCustomClickEvent which includes 2 methods to extract a dialog response. One method takes the dialog instance, and tries to validate its inputs against the received payload, returning null if its not valid. Of course you should be making the payload ids super unique so you know its your dialog.

The other is a raw response wrapper with methods to just get any bool, float, or string in the top level of the response payload (if the response payload exists and is a compound tag).

And of course you can get a BinaryTagHolder and parse it into NBT using whatever library you want.

@Machine-Maker
Copy link
Member Author

Ok, I added another approach. You can manually specify a callback that runs. Create it with DialogAction#customAll(Key, DialogActionCallback, ClickCallback$Options) and use it in the actions.

@Machine-Maker Machine-Maker force-pushed the dev/1.21.6-dialog branch 2 times, most recently from 9bdcbdb to 9ac3613 Compare June 27, 2025 01:23
@Machine-Maker Machine-Maker changed the base branch from main to dev/1.21.7 June 27, 2025 01:23
@Hugo5000
Copy link

Ok, I added another approach. You can manually specify a callback that runs. Create it with DialogAction#customAll(Key, DialogActionCallback, ClickCallback$Options) and use it in the actions.

why even add a key, feels like this should just create a key internally

@Machine-Maker
Copy link
Member Author

Yeah, I think you're right. Will remove.

@Machine-Maker Machine-Maker marked this pull request as draft June 27, 2025 21:02
@Hugo5000
Copy link

Hugo5000 commented Jun 27, 2025

I did not see a way to make a DialogAction close the dialog? Am I missing something or is that just not a thing? I'd be needed if you don't auto close it.

I know adventure will add a Audience#closeDialog but I'd feel like there should be a predefined DialogAction#close that removed the boiler plate of having do to a customClick

@Machine-Maker
Copy link
Member Author

You don't have to specify any action. In say, a confirmation dialog, the dialog will follow the DialogAfterAction on any button click.

@Machine-Maker Machine-Maker marked this pull request as ready for review June 28, 2025 13:32
Copy link
Member

@kennytv kennytv left a comment

Choose a reason for hiding this comment

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

Open to feedback/no changes at all on all of these, but this is what caught my eye

@github-project-automation github-project-automation bot moved this from Awaiting review to Awaiting final testing in Paper PR Queue Jun 29, 2025
@kennytv kennytv force-pushed the dev/1.21.7 branch 2 times, most recently from 26ab9a3 to a9f74cb Compare June 30, 2025 09:50
Base automatically changed from dev/1.21.7 to main June 30, 2025 14:18
Copy link
Contributor

@Emilxyz Emilxyz left a comment

Choose a reason for hiding this comment

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

Did some testing with this and generally everything works as expected, just some nitpicks.
I pushed my test-plugin for anyone curious on what exactly I tried.

@Paasdag

This comment was marked as spam.

@kennytv kennytv merged commit b4466ec into main Jul 6, 2025
6 checks passed
@kennytv kennytv deleted the dev/1.21.6-dialog branch July 6, 2025 18:49
@github-project-automation github-project-automation bot moved this from Awaiting final testing to Merged in Paper PR Queue Jul 6, 2025
davidmayr added a commit to InfernalSuite/AdvancedSlimePaper that referenced this pull request Jul 7, 2025
…2ee0d6ce4e6bd

Signed-off-by: David Mayr <davidliebtkekse@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

publish-pr Enables a workflow to build Paperclip jars on the pull request.

Projects

Status: Merged

Development

Successfully merging this pull request may close these issues.

Document how to create a new RegistryKeySet on the interface itself

9 participants