summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/bukkit/conversations/ExactMatchConversationCanceller.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/bukkit/conversations/ExactMatchConversationCanceller.java')
-rw-r--r--src/main/java/org/bukkit/conversations/ExactMatchConversationCanceller.java26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/conversations/ExactMatchConversationCanceller.java b/src/main/java/org/bukkit/conversations/ExactMatchConversationCanceller.java
new file mode 100644
index 00000000..ad387534
--- /dev/null
+++ b/src/main/java/org/bukkit/conversations/ExactMatchConversationCanceller.java
@@ -0,0 +1,26 @@
+package org.bukkit.conversations;
+
+/**
+ * An ExactMatchConversationCanceller cancels a conversation if the user enters an exact input string
+ */
+public class ExactMatchConversationCanceller implements ConversationCanceller {
+ private String escapeSequence;
+
+ /**
+ * Builds an ExactMatchConversationCanceller.
+ * @param escapeSequence The string that, if entered by the user, will cancel the conversation.
+ */
+ public ExactMatchConversationCanceller(String escapeSequence) {
+ this.escapeSequence = escapeSequence;
+ }
+
+ public void setConversation(Conversation conversation) {}
+
+ public boolean cancelBasedOnInput(ConversationContext context, String input) {
+ return input.equals(escapeSequence);
+ }
+
+ public ConversationCanceller clone() {
+ return new ExactMatchConversationCanceller(escapeSequence);
+ }
+}