-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactors Cars to inherit CarDetails, which are setup in the config.yml
Car Types are unique names which have an associated CarDetails (standard, racecar, etc.) Conversation to allow for creation of CarType Fixes and update dependencies
- Loading branch information
Showing
15 changed files
with
387 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
src/main/java/io/github/a5h73y/conversation/CarzConversation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package io.github.a5h73y.conversation; | ||
|
||
import io.github.a5h73y.Carz; | ||
import org.bukkit.ChatColor; | ||
import org.bukkit.conversations.Conversable; | ||
import org.bukkit.conversations.Conversation; | ||
import org.bukkit.conversations.ConversationAbandonedEvent; | ||
import org.bukkit.conversations.ConversationAbandonedListener; | ||
import org.bukkit.conversations.ConversationContext; | ||
import org.bukkit.conversations.ConversationFactory; | ||
import org.bukkit.conversations.Prompt; | ||
|
||
public abstract class CarzConversation implements ConversationAbandonedListener { | ||
|
||
private ConversationFactory conversationFactory; | ||
private Conversable player; | ||
|
||
public abstract Prompt getEntryPrompt(); | ||
|
||
public CarzConversation(Conversable player) { | ||
this.player = player; | ||
|
||
conversationFactory = new ConversationFactory(Carz.getInstance()) | ||
.withEscapeSequence("cancel") | ||
.withTimeout(30) | ||
.addConversationAbandonedListener(this) | ||
.withFirstPrompt(getEntryPrompt()); | ||
|
||
player.sendRawMessage(ChatColor.GRAY + "Note: Enter 'cancel' to quit the conversation."); | ||
} | ||
|
||
public static void sendErrorMessage(ConversationContext context, String message) { | ||
context.getForWhom().sendRawMessage(ChatColor.RED + message + ". Please try again..."); | ||
} | ||
|
||
@Override | ||
public void conversationAbandoned(ConversationAbandonedEvent event) { | ||
if (!event.gracefulExit()) { | ||
event.getContext().getForWhom().sendRawMessage(Carz.getPrefix() + "Conversation aborted..."); | ||
} | ||
} | ||
|
||
public void begin() { | ||
Conversation convo = conversationFactory.buildConversation(player); | ||
convo.begin(); | ||
} | ||
} |
Oops, something went wrong.