Skip to content

Commit 2f48b6b

Browse files
authored
Merge pull request #1246 from KyoriPowered/feature/clear-dialog
feature(api): Add a method to close an open dialog
2 parents ca413e4 + dc13377 commit 2f48b6b

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

api/src/main/java/net/kyori/adventure/audience/Audience.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -878,4 +878,16 @@ default void clearResourcePacks() {
878878
*/
879879
default void showDialog(final @NotNull DialogLike dialog) {
880880
}
881+
882+
/**
883+
* Closes the dialog that is currently being shown to this audience, if any.
884+
*
885+
* <p>This will return the user to the previous dialog if one was opened from the
886+
* current dialog.</p>
887+
*
888+
* @since 4.24.0
889+
* @sinceMinecraft 1.21.6
890+
*/
891+
default void closeDialog() {
892+
}
881893
}

api/src/main/java/net/kyori/adventure/audience/ForwardingAudience.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,11 @@ default void showDialog(final @NotNull DialogLike dialog) {
227227
for (final Audience audience : this.audiences()) audience.showDialog(dialog);
228228
}
229229

230+
@Override
231+
default void closeDialog() {
232+
for (final Audience audience : this.audiences()) audience.closeDialog();
233+
}
234+
230235
/**
231236
* An audience that forwards everything to a single other audience.
232237
*
@@ -414,5 +419,10 @@ default void clearResourcePacks() {
414419
default void showDialog(final @NotNull DialogLike dialog) {
415420
this.audience().showDialog(dialog);
416421
}
422+
423+
@Override
424+
default void closeDialog() {
425+
this.audience().closeDialog();
426+
}
417427
}
418428
}

0 commit comments

Comments
 (0)