001 package org.bukkit.conversations;
002
003 import java.util.EventObject;
004
005 /**
006 * ConversationAbandonedEvent contains information about an abandoned
007 * conversation.
008 */
009 public class ConversationAbandonedEvent extends EventObject {
010
011 private ConversationContext context;
012 private ConversationCanceller canceller;
013
014 public ConversationAbandonedEvent(Conversation conversation) {
015 this(conversation, null);
016 }
017
018 public ConversationAbandonedEvent(Conversation conversation, ConversationCanceller canceller) {
019 super(conversation);
020 this.context = conversation.getContext();
021 this.canceller = canceller;
022 }
023
024 /**
025 * Gets the object that caused the conversation to be abandoned.
026 *
027 * @return The object that abandoned the conversation.
028 */
029 public ConversationCanceller getCanceller() {
030 return canceller;
031 }
032
033 /**
034 * Gets the abandoned conversation's conversation context.
035 *
036 * @return The abandoned conversation's conversation context.
037 */
038 public ConversationContext getContext() {
039 return context;
040 }
041
042 /**
043 * Indicates how the conversation was abandoned - naturally as part of the
044 * prompt chain or prematurely via a {@link ConversationCanceller}.
045 *
046 * @return True if the conversation is abandoned gracefully by a {@link
047 * Prompt} returning null or the next prompt. False of the
048 * conversations is abandoned prematurely by a ConversationCanceller.
049 */
050 public boolean gracefulExit() {
051 return canceller == null;
052 }
053 }