Skip to content

Creating simple dialogue

Caleb Owens edited this page Mar 14, 2022 · 4 revisions

A Dialogue is an object that represents dialogue between the player and the plugin.

dialogue = new Dialogue.Builder()
	.addPrompt(
		new Prompt.Builder()
			.setText("&eWhat is your age?")
			.setType(PromptInputType.INTEGER)
			// Code that runs when the plugin receives the input.
			.setOnReceiveInputAction( (responder, input) -> {
				responder.sendMessage("You are " + input + " years old!");
			})
	)
	// Sequence to exit the dialogue.
	.setEscapeSequence("exit")
	// Code that runs when the dialogue ends.
	.setEndAction( (player, cause) -> {
		sender.sendMessage(ChatColor.BLUE + "This message is sent when the dialogue ends!");
	})
        .setRepeatPrompt(false)
.build();

We've made a simple dialogue that asks the player what their age is.

Now that you've created the dialogue, it's time to actual start the dialogue. Here's how you do it: DialogueAPI.startDialogue(player, dialogue);

Join my discord if you need any additional support or have any questions.

Clone this wiki locally