summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/bukkit/conversations/ExactMatchConversationCanceller.java
blob: ad387534d6ce1f6c6ae35e9b12995693044759c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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);
    }
}