Skip to content

Commit

Permalink
Dialogue end action is now a BiConsumer.
Browse files Browse the repository at this point in the history
  • Loading branch information
its-c10 committed Mar 14, 2022
1 parent 560c6ba commit cb84236
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 26 deletions.
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# Dialogue
![Release](https://jitpack.io/v/nthByte-LLC/dialogue.svg)

Dialogue is a Spigot API that completely revamps the Conversation API. <b><i>This is not a plugin you put on your server.</b></i>
Dialogue is a Spigot API that completely revamps the Conversation API. <b><i>This is not a plugin you put on your server</b></i>.

## Installation

Expand All @@ -28,7 +28,7 @@ Dialogue is a Spigot API that completely revamps the Conversation API. <b><i>Thi
<version>Tag</version>
</dependency>
```
Replace "Tag" with a release tag for Dialogue. You can see the latest version <a href="https://github.com/nthByte-LLC/dialogue/releases">here</a>
Replace "Tag" with a release tag for Dialogue. You can see the latest version <a href="https://github.com/nthByte-LLC/dialogue/releases">here</a>.

### Gradle
```gradle
Expand All @@ -41,24 +41,22 @@ dependencies {
implementation 'com.github.nthByte-LLC:dialogue:Tag'
}
```
Replace "Tag" with a release tag for Dialogue. You can see the latest version <a href="https://github.com/nthByte-LLC/dialogue/releases">here</a>
Replace "Tag" with a release tag for Dialogue. You can see the latest version <a href="https://github.com/nthByte-LLC/dialogue/releases">here</a>.

## Usage
Firstly, you want to hook into the API. Put this line in your main class.
```java
DialogueAPI.hook(this);
```
All this does is register the dialogue listener and initializes DialogueManager
All this does is register the dialogue listener and initializes DialogueManager.

From this point on, you can either look at this <a href="https://github.com/nthByte-LLC/dialogue-example">example plugin</a> that uses this API or refer to the <a href="https://github.com/nthByte-LLC/dialogue/wiki">wiki</a>

## Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

## Support
Need help or have questions? Join my <a href="https://discord.gg/ZP2xxC52An">discord</a>
Need help or have questions? Join my <a href="https://discord.gg/ZP2xxC52An">discord</a>.



Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
First number will increment for plugin re-writes.
Second number I will increment whenever there's a significant change/API changes, meaning you will need to change something in your code in order to work with this current version.
Third number I will change whenever I add a new feature.
Fourth number I will change for bug fixes.
Fourth number I will change for bug fixes/small changes.
-->
<version>1.1.1.0</version>
<version>1.2.0.0</version>
<packaging>jar</packaging>

<name>Dialogue</name>
Expand Down
11 changes: 6 additions & 5 deletions src/main/java/com/nthbyte/dialogue/Dialogue.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@

import java.util.ArrayList;
import java.util.List;
import java.util.function.BiConsumer;
import java.util.function.Consumer;

/**
* Object that represents dialogue between the plugin and a player.
*
* @author <a href="linktr.ee/c10_">Caleb Owens</a>
* @version 1.1.1.0
* @version 1.1.1.1
*/
public class Dialogue {

Expand All @@ -22,7 +23,7 @@ public class Dialogue {
/**
* Actions that are ran when the dialogue ends.
*/
private Consumer<DialogueEndCause> endAction;
private BiConsumer<Player, DialogueEndCause> endAction;
private int currentIndexPrompt = 0;
/**
* Repeats the prompt if the input was invalid.
Expand Down Expand Up @@ -75,7 +76,7 @@ public void nextPrompt(Player player){
getCurrentPrompt().prompt(player);
}

public Consumer<DialogueEndCause> getEndAction() {
public BiConsumer<Player, DialogueEndCause> getEndAction() {
return endAction;
}

Expand All @@ -96,7 +97,7 @@ public static class Builder{
private boolean repeatPrompt = true;
private String escapeSequence = "";
private List<Prompt> prompts = new ArrayList<>();
private Consumer<DialogueEndCause> endAction = dialogueEndCause -> { };
private BiConsumer<Player, DialogueEndCause> endAction = (player, dialogueEndCause) -> {};

public Builder(){}

Expand All @@ -110,7 +111,7 @@ public Builder setEscapeSequence(String escapeSequence){
return this;
}

public Builder setEndAction(Consumer<DialogueEndCause> action){
public Builder setEndAction(BiConsumer<Player, DialogueEndCause> action){
this.endAction = action;
return this;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/nthbyte/dialogue/DialogueAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* An API that completely eliminates your need for the ConversationsAPI
*
* @author <a href="linktr.ee/c10_">Caleb Owens</a>
* @version 1.1.1.0
* @version 1.1.1.1
*/
public class DialogueAPI {

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/nthbyte/dialogue/DialogueEndCause.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Reasons that the dialogue ended.
*
* @author <a href="linktr.ee/c10_">Caleb Owens</a>
* @version 1.1.1.0
* @version 1.1.1.1
*/
public enum DialogueEndCause {

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/nthbyte/dialogue/DialogueListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* The listener for all input and dialogue.
*
* @author <a href="linktr.ee/c10_">Caleb Owens</a>
* @version 1.1.1.0
* @version 1.1.1.1
*/
public class DialogueListener implements Listener {

Expand Down
7 changes: 4 additions & 3 deletions src/main/java/com/nthbyte/dialogue/DialogueManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import java.util.function.BiConsumer;
import java.util.function.Consumer;

/**
* The manager for all dialogue.
*
* @author <a href="linktr.ee/c10_">Caleb Owens</a>
* @version 1.1.1.0
* @version 1.1.1.1
*/
public class DialogueManager {

Expand Down Expand Up @@ -56,9 +57,9 @@ public void endDialogue(Player player, DialogueEndCause cause){
Dialogue endedDialogue = playersInDialogue.remove(player.getUniqueId());
if(endedDialogue == null) return;

Consumer<DialogueEndCause> endAction = endedDialogue.getEndAction();
BiConsumer<Player, DialogueEndCause> endAction = endedDialogue.getEndAction();
if(endAction != null){
endAction.accept(cause);
endAction.accept(player, cause);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Validates the format of input.
*
* @author <a href="linktr.ee/c10_">Caleb Owens</a>
* @version 1.1.1.0
* @version 1.1.1.1
*/
public class InputFormatValidator {

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/nthbyte/dialogue/Prompt.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* Represents a question or a request.
*
* @author <a href="linktr.ee/c10_">Caleb Owens</a>
* @version 1.1.1.0
* @version 1.1.1.1
*/
public class Prompt {

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/nthbyte/dialogue/PromptInputType.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* The different types of input for prompts.
*
* @author <a href="linktr.ee/c10_">Caleb Owens</a>
* @version 1.1.1.0
* @version 1.1.1.1
*/
public enum PromptInputType {

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/nthbyte/dialogue/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Utility class.
*
* @author <a href="linktr.ee/c10_">Caleb Owens</a>
* @version 1.1.1.0
* @version 1.1.1.1
*/
public class Utils {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* Event fired when you receive input from a player post-validation.
*
* @author <a href="linktr.ee/c10_">Caleb Owens</a>
* @version 1.1.1.0
* @version 1.1.1.1
*/
public class ReceiveInputEvent extends Event {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* The event that fires just before the prompt uses its own validation check (If there is any). Use this if you wish to do your own validation.
*
* @author <a href="linktr.ee/c10_">Caleb Owens</a>
* @version 1.1.1.0
* @version 1.1.1.1
*/
public class ValidateInputEvent extends Event {

Expand Down

0 comments on commit cb84236

Please sign in to comment.