![]() |
Bukkit
1.4.7-R1.0
|
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< ConversationCanceller > | getCancellers () |
| 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< ConversationCanceller > | cancellers |
| List < ConversationAbandonedListener > | abandonedListeners |
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.
| org.bukkit.conversations.Conversation.Conversation | ( | Plugin | plugin, |
| Conversable | forWhom, | ||
| Prompt | firstPrompt | ||
| ) |
Initializes a new Conversation.
| plugin | The plugin that owns this conversation. |
| forWhom | The entity for whom this conversation is mediating. |
| firstPrompt | The 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.
| plugin | The plugin that owns this conversation. |
| forWhom | The entity for whom this conversation is mediating. |
| firstPrompt | The first prompt in the conversation graph. |
| initialSessionData | Any 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.
| 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.
| details | Details 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().
| void org.bukkit.conversations.Conversation.acceptInput | ( | String | input | ) |
Passes player input into the current prompt.
The next prompt (as determined by the current prompt) is then displayed to the user.
| input | The user's chat text. |
Definition at line 183 of file Conversation.java.
References org.bukkit.conversations.Conversation.abandon(), org.bukkit.conversations.Prompt.acceptInput(), org.bukkit.conversations.Conversation.cancellers, org.bukkit.conversations.Conversation.context, org.bukkit.conversations.Conversation.currentPrompt, org.bukkit.conversations.ConversationContext.getForWhom(), org.bukkit.conversations.ConversationPrefix.getPrefix(), org.bukkit.conversations.Conversation.localEchoEnabled, org.bukkit.conversations.Conversation.outputNextPrompt(), org.bukkit.conversations.Conversation.prefix, and org.bukkit.conversations.Conversable.sendRawMessage().
| synchronized void org.bukkit.conversations.Conversation.addConversationAbandonedListener | ( | ConversationAbandonedListener | listener | ) |
Adds a ConversationAbandonedListener.
| listener | The listener to add. |
Definition at line 209 of file Conversation.java.
References org.bukkit.conversations.Conversation.abandonedListeners.
Referenced by org.bukkit.conversations.ConversationFactory.buildConversation().
| void org.bukkit.conversations.Conversation.begin | ( | ) |
Displays the first prompt of this conversation and begins redirecting the user's chat responses.
Definition at line 156 of file Conversation.java.
References org.bukkit.conversations.Conversable.beginConversation(), org.bukkit.conversations.Conversation.context, org.bukkit.conversations.Conversation.currentPrompt, and org.bukkit.conversations.ConversationContext.getForWhom().
| List<ConversationCanceller> org.bukkit.conversations.Conversation.getCancellers | ( | ) |
Gets the list of ConversationCancellers.
Definition at line 141 of file Conversation.java.
References org.bukkit.conversations.Conversation.cancellers.
| ConversationContext org.bukkit.conversations.Conversation.getContext | ( | ) |
Returns the Conversation's ConversationContext.
Definition at line 149 of file Conversation.java.
References org.bukkit.conversations.Conversation.context.
Referenced by org.bukkit.conversations.ConversationAbandonedEvent.ConversationAbandonedEvent().
| Conversable org.bukkit.conversations.Conversation.getForWhom | ( | ) |
Gets the entity for whom this conversation is mediating.
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.
Definition at line 116 of file Conversation.java.
References org.bukkit.conversations.Conversation.prefix.
| ConversationState org.bukkit.conversations.Conversation.getState | ( | ) |
Returns Returns the current state of the conversation.
Definition at line 168 of file Conversation.java.
References org.bukkit.conversations.Conversation.ConversationState.ABANDONED, org.bukkit.conversations.Conversation.currentPrompt, org.bukkit.conversations.Conversation.ConversationState.STARTED, and org.bukkit.conversations.Conversation.ConversationState.UNSTARTED.
| 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.
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.
Definition at line 81 of file Conversation.java.
References org.bukkit.conversations.Conversation.modal.
| void org.bukkit.conversations.Conversation.outputNextPrompt | ( | ) |
Displays the next user prompt and abandons the conversation if the next prompt is null.
Definition at line 246 of file Conversation.java.
References org.bukkit.conversations.Conversation.abandon(), org.bukkit.conversations.Prompt.acceptInput(), org.bukkit.conversations.Prompt.blocksForInput(), org.bukkit.conversations.Conversation.context, org.bukkit.conversations.Conversation.currentPrompt, org.bukkit.conversations.ConversationContext.getForWhom(), org.bukkit.conversations.ConversationPrefix.getPrefix(), org.bukkit.conversations.Prompt.getPromptText(), org.bukkit.conversations.Conversation.prefix, and org.bukkit.conversations.Conversable.sendRawMessage().
Referenced by org.bukkit.conversations.Conversation.acceptInput().
| synchronized void org.bukkit.conversations.Conversation.removeConversationAbandonedListener | ( | ConversationAbandonedListener | listener | ) |
Removes a ConversationAbandonedListener.
| listener | The 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.
| localEchoEnabled | The 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().
|
protected |
Definition at line 39 of file Conversation.java.
Referenced by org.bukkit.conversations.Conversation.abandon(), org.bukkit.conversations.Conversation.addConversationAbandonedListener(), org.bukkit.conversations.Conversation.Conversation(), and org.bukkit.conversations.Conversation.removeConversationAbandonedListener().
|
protected |
Definition at line 38 of file Conversation.java.
Referenced by org.bukkit.conversations.Conversation.acceptInput(), org.bukkit.conversations.Conversation.Conversation(), and org.bukkit.conversations.Conversation.getCancellers().
|
protected |
Definition at line 34 of file Conversation.java.
Referenced by org.bukkit.conversations.Conversation.abandon(), org.bukkit.conversations.Conversation.acceptInput(), org.bukkit.conversations.Conversation.begin(), org.bukkit.conversations.Conversation.Conversation(), org.bukkit.conversations.Conversation.getContext(), org.bukkit.conversations.Conversation.getForWhom(), and org.bukkit.conversations.Conversation.outputNextPrompt().
|
protected |
Definition at line 33 of file Conversation.java.
Referenced by org.bukkit.conversations.Conversation.abandon(), org.bukkit.conversations.Conversation.acceptInput(), org.bukkit.conversations.Conversation.begin(), org.bukkit.conversations.Conversation.getState(), and org.bukkit.conversations.Conversation.outputNextPrompt().
|
protected |
|
protected |
Definition at line 35 of file Conversation.java.
Referenced by org.bukkit.conversations.Conversation.Conversation(), and org.bukkit.conversations.Conversation.isModal().
|
protected |