[Bleeding] Added ConversationAbandonedEvent and supporting infrastructure. Whenever a conversation exits, the ConversationAbandonedEvent is triggered with details about how the conversation ended and what, if anything caused it to end. Fixes BUKKIT-986
By: rmichela <deltahat@gmail.com>
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
package org.bukkit.conversations;
|
||||
|
||||
import java.util.EventObject;
|
||||
|
||||
/**
|
||||
* ConversationAbandonedEvent contains information about an abandoned conversation.
|
||||
*/
|
||||
public class ConversationAbandonedEvent extends EventObject {
|
||||
|
||||
private ConversationContext context;
|
||||
private ConversationCanceller canceller;
|
||||
|
||||
public ConversationAbandonedEvent(Conversation conversation) {
|
||||
this(conversation, null);
|
||||
}
|
||||
|
||||
public ConversationAbandonedEvent(Conversation conversation, ConversationCanceller canceller) {
|
||||
super(conversation);
|
||||
this.context = conversation.getContext();
|
||||
this.canceller = canceller;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the object that caused the conversation to be abandoned.
|
||||
* @return The object that abandoned the conversation.
|
||||
*/
|
||||
public ConversationCanceller getCanceller() {
|
||||
return canceller;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the abandoned conversation's conversation context.
|
||||
* @return The abandoned conversation's conversation context.
|
||||
*/
|
||||
public ConversationContext getContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates how the conversation was abandoned - naturally as part of the prompt chain or prematurely via a
|
||||
* {@link ConversationCanceller}.
|
||||
* @return True if the conversation is abandoned gracefully by a {@link Prompt} returning null
|
||||
* or the next prompt. False of the conversations is abandoned prematurely by a ConversationCanceller.
|
||||
*/
|
||||
public boolean gracefulExit() {
|
||||
return canceller == null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user