Window titles
The dungeon lobby's window title reads "Dungeon lobby · 1 / 4 ready". Each time a party member clicks ready, the number in the title should go up.
The title is not an item in a slot, so dependsOn cannot reach it. Once the window opens, the title stays fixed unless something asks it to be recomputed.
What setTitleSupplier and window.bind do
setTitleSupplier makes the title come from a function, called when the window opens. window.bind(signal, callback) runs the callback whenever the Signal notifies; with Window::updateTitle as the callback, the title is recomputed and sent to the player.
The binding follows the window: active while it is open, paused when it closes, and resumed when it opens again.
A title showing the ready count
Nobody is ready yet.
MutableSignal<Integer> readyCount = Signal.of(0);
Pane pane = Pane.builder("####R####")
.addIngredient('R', Item.builder()
.setItemProviderConstant(named(Material.LIME_DYE, "Ready"))
.addClickHandler(click -> readyCount.update(value -> Math.min(value + 1, 4)))
.build()
)
.build();
Window window = Window.builder(pane)
.setTitleSupplier(() -> Component.text("Dungeon lobby · " + readyCount.get() + " / 4 ready"))
.build(viewer);
window.bind(readyCount, Window::updateTitle); // declare before open
window.open();

readyCount | 0 | |
|---|---|---|
window | not built |
Caveats
updateTitle() hands the title update to the player's thread. Other callbacks you pass to bind are not moved to another thread; schedule that yourself when you need to touch the player.
Declare the binding before open() so it is active as soon as the window opens. The title function should only read data, never change state.
private static ItemStack named(Material material, String name) {
ItemStack stack = new ItemStack(material);
stack.setData(DataComponentTypes.CUSTOM_NAME,
Component.text(name).decoration(TextDecoration.ITALIC, false)
);
return stack;
}
It uses Paper's DataComponentTypes with Adventure's Component and TextDecoration, matching Item rendering.