Bukkit  1.4.7-R1.0
 All Classes Namespaces Files Functions Variables Enumerator Pages
org.bukkit.conversations.Conversation Class Reference

The Conversation class is responsible for tracking the current state of a conversation, displaying prompts to the user, and dispatching the user's response to the appropriate place. More...

+ Collaboration diagram for org.bukkit.conversations.Conversation:

Classes

enum  ConversationState
 

Public Member Functions

 Conversation (Plugin plugin, Conversable forWhom, Prompt firstPrompt)
 Initializes a new Conversation.
 
 Conversation (Plugin plugin, Conversable forWhom, Prompt firstPrompt, Map< Object, Object > initialSessionData)
 Initializes a new Conversation.
 
Conversable getForWhom ()
 Gets the entity for whom this conversation is mediating.
 
boolean isModal ()
 Gets the modality of this conversation.
 
boolean isLocalEchoEnabled ()
 Gets the status of local echo for this conversation.
 
void setLocalEchoEnabled (boolean localEchoEnabled)
 Sets the status of local echo for this conversation.
 
ConversationPrefix getPrefix ()
 Gets the ConversationPrefix that prepends all output from this conversation.
 
List< ConversationCancellergetCancellers ()
 Gets the list of ConversationCancellers.
 
ConversationContext getContext ()
 Returns the Conversation's ConversationContext.
 
void begin ()
 Displays the first prompt of this conversation and begins redirecting the user's chat responses.
 
ConversationState getState ()
 Returns Returns the current state of the conversation.
 
void acceptInput (String input)
 Passes player input into the current prompt.
 
synchronized void addConversationAbandonedListener (ConversationAbandonedListener listener)
 Adds a ConversationAbandonedListener.
 
synchronized void removeConversationAbandonedListener (ConversationAbandonedListener listener)
 Removes a ConversationAbandonedListener.
 
void abandon ()
 Abandons and resets the current conversation.
 
synchronized void abandon (ConversationAbandonedEvent details)
 Abandons and resets the current conversation.
 
void outputNextPrompt ()
 Displays the next user prompt and abandons the conversation if the next prompt is null.
 

Protected Attributes

Prompt currentPrompt
 
ConversationContext context
 
boolean modal
 
boolean localEchoEnabled
 
ConversationPrefix prefix
 
List< ConversationCancellercancellers
 
List
< ConversationAbandonedListener
abandonedListeners
 

Detailed Description

The Conversation class is responsible for tracking the current state of a conversation, displaying prompts to the user, and dispatching the user's response to the appropriate place.

Conversation objects are not typically instantiated directly. Instead a ConversationFactory is used to construct identical conversations on demand.

Conversation flow consists of a directed graph of Prompt objects. Each time a prompt gets input from the user, it must return the next prompt in the graph. Since each Prompt chooses the next Prompt, complex conversation trees can be implemented where the nature of the player's response directs the flow of the conversation.

Each conversation has a ConversationPrefix that prepends all output from the conversation to the player. The ConversationPrefix can be used to display the plugin name or conversation status as the conversation evolves.

Each conversation has a timeout measured in the number of inactive seconds to wait before abandoning the conversation. If the inactivity timeout is reached, the conversation is abandoned and the user's incoming and outgoing chat is returned to normal.

You should not construct a conversation manually. Instead, use the ConversationFactory for access to all available options.

Definition at line 29 of file Conversation.java.

Constructor & Destructor Documentation

org.bukkit.conversations.Conversation.Conversation ( Plugin  plugin,
Conversable  forWhom,
Prompt  firstPrompt 
)

Initializes a new Conversation.

Parameters
pluginThe plugin that owns this conversation.
forWhomThe entity for whom this conversation is mediating.
firstPromptThe first prompt in the conversation graph.

Definition at line 47 of file Conversation.java.

org.bukkit.conversations.Conversation.Conversation ( Plugin  plugin,
Conversable  forWhom,
Prompt  firstPrompt,
Map< Object, Object >  initialSessionData 
)

Initializes a new Conversation.

Parameters
pluginThe plugin that owns this conversation.
forWhomThe entity for whom this conversation is mediating.
firstPromptThe first prompt in the conversation graph.
initialSessionDataAny initial values to put in the conversation context sessionData map.

Definition at line 58 of file Conversation.java.

References org.bukkit.conversations.Conversation.abandonedListeners, org.bukkit.conversations.Conversation.cancellers, org.bukkit.conversations.Conversation.context, org.bukkit.conversations.Conversation.localEchoEnabled, org.bukkit.conversations.Conversation.modal, and org.bukkit.conversations.Conversation.prefix.

Member Function Documentation

void org.bukkit.conversations.Conversation.abandon ( )

Abandons and resets the current conversation.

Restores the user's normal chat behavior.

Definition at line 224 of file Conversation.java.

Referenced by org.bukkit.conversations.Conversation.acceptInput(), and org.bukkit.conversations.Conversation.outputNextPrompt().

synchronized void org.bukkit.conversations.Conversation.abandon ( ConversationAbandonedEvent  details)

Abandons and resets the current conversation.

Restores the user's normal chat behavior.

Parameters
detailsDetails about why the conversation was abandoned

Definition at line 232 of file Conversation.java.

References org.bukkit.conversations.Conversable.abandonConversation(), org.bukkit.conversations.Conversation.abandonedListeners, org.bukkit.conversations.Conversation.context, org.bukkit.conversations.Conversation.currentPrompt, and org.bukkit.conversations.ConversationContext.getForWhom().

synchronized void org.bukkit.conversations.Conversation.addConversationAbandonedListener ( ConversationAbandonedListener  listener)
void org.bukkit.conversations.Conversation.begin ( )
List<ConversationCanceller> org.bukkit.conversations.Conversation.getCancellers ( )

Gets the list of ConversationCancellers.

Returns
The list.

Definition at line 141 of file Conversation.java.

References org.bukkit.conversations.Conversation.cancellers.

ConversationContext org.bukkit.conversations.Conversation.getContext ( )
Conversable org.bukkit.conversations.Conversation.getForWhom ( )

Gets the entity for whom this conversation is mediating.

Returns
The entity.

Definition at line 72 of file Conversation.java.

References org.bukkit.conversations.Conversation.context, and org.bukkit.conversations.ConversationContext.getForWhom().

ConversationPrefix org.bukkit.conversations.Conversation.getPrefix ( )

Gets the ConversationPrefix that prepends all output from this conversation.

Returns
The ConversationPrefix in use.

Definition at line 116 of file Conversation.java.

References org.bukkit.conversations.Conversation.prefix.

ConversationState org.bukkit.conversations.Conversation.getState ( )
boolean org.bukkit.conversations.Conversation.isLocalEchoEnabled ( )

Gets the status of local echo for this conversation.

If local echo is enabled, any text submitted to a conversation gets echoed back into the submitter's chat window.

Returns
The status of local echo.

Definition at line 99 of file Conversation.java.

References org.bukkit.conversations.Conversation.localEchoEnabled.

boolean org.bukkit.conversations.Conversation.isModal ( )

Gets the modality of this conversation.

If a conversation is modal, all messages directed to the player are suppressed for the duration of the conversation.

Returns
The conversation modality.

Definition at line 81 of file Conversation.java.

References org.bukkit.conversations.Conversation.modal.

synchronized void org.bukkit.conversations.Conversation.removeConversationAbandonedListener ( ConversationAbandonedListener  listener)

Removes a ConversationAbandonedListener.

Parameters
listenerThe listener to remove.

Definition at line 217 of file Conversation.java.

References org.bukkit.conversations.Conversation.abandonedListeners.

void org.bukkit.conversations.Conversation.setLocalEchoEnabled ( boolean  localEchoEnabled)

Sets the status of local echo for this conversation.

If local echo is enabled, any text submitted to a conversation gets echoed back into the submitter's chat window.

Parameters
localEchoEnabledThe status of local echo.

Definition at line 108 of file Conversation.java.

References org.bukkit.conversations.Conversation.localEchoEnabled.

Referenced by org.bukkit.conversations.ConversationFactory.buildConversation().

Member Data Documentation

boolean org.bukkit.conversations.Conversation.modal
protected

The documentation for this class was generated from the following file: