Class Conversation
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
Deprecated, for removal: This API element is subject to removal in a future version. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected List
<ConversationAbandonedListener> Deprecated, for removal: This API element is subject to removal in a future version.protected List
<ConversationCanceller> Deprecated, for removal: This API element is subject to removal in a future version.protected ConversationContext
Deprecated, for removal: This API element is subject to removal in a future version.protected Prompt
Deprecated, for removal: This API element is subject to removal in a future version.protected boolean
Deprecated, for removal: This API element is subject to removal in a future version.protected boolean
Deprecated, for removal: This API element is subject to removal in a future version.protected ConversationPrefix
Deprecated, for removal: This API element is subject to removal in a future version. -
Constructor Summary
ConstructorsConstructorDescriptionConversation
(@Nullable Plugin plugin, @NotNull Conversable forWhom, @Nullable Prompt firstPrompt) Deprecated, for removal: This API element is subject to removal in a future version.Initializes a new Conversation.Conversation
(@Nullable Plugin plugin, @NotNull Conversable forWhom, @Nullable Prompt firstPrompt, @NotNull Map<Object, Object> initialSessionData) Deprecated, for removal: This API element is subject to removal in a future version.Initializes a new Conversation. -
Method Summary
Modifier and TypeMethodDescriptionvoid
abandon()
Deprecated, for removal: This API element is subject to removal in a future version.Abandons and resets the current conversation.void
abandon
(@NotNull ConversationAbandonedEvent details) Deprecated, for removal: This API element is subject to removal in a future version.Abandons and resets the current conversation.void
acceptInput
(@NotNull String input) Deprecated, for removal: This API element is subject to removal in a future version.Passes player input into the current prompt.void
Deprecated, for removal: This API element is subject to removal in a future version.Adds aConversationAbandonedListener
.void
begin()
Deprecated, for removal: This API element is subject to removal in a future version.Displays the first prompt of this conversation and begins redirecting the user's chat responses.Deprecated, for removal: This API element is subject to removal in a future version.Gets the list ofConversationCanceller
sDeprecated, for removal: This API element is subject to removal in a future version.Returns the Conversation'sConversationContext
.Deprecated, for removal: This API element is subject to removal in a future version.Gets the entity for whom this conversation is mediating.Deprecated, for removal: This API element is subject to removal in a future version.Gets theConversationPrefix
that prepends all output from this conversation.getState()
Deprecated, for removal: This API element is subject to removal in a future version.Returns the current state of the conversation.boolean
Deprecated, for removal: This API element is subject to removal in a future version.Gets the status of local echo for this conversation.boolean
isModal()
Deprecated, for removal: This API element is subject to removal in a future version.Gets the modality of this conversation.void
Deprecated, for removal: This API element is subject to removal in a future version.Displays the next user prompt and abandons the conversation if the next prompt is null.void
Deprecated, for removal: This API element is subject to removal in a future version.Removes aConversationAbandonedListener
.void
setLocalEchoEnabled
(boolean localEchoEnabled) Deprecated, for removal: This API element is subject to removal in a future version.Sets the status of local echo for this conversation.
-
Field Details
-
currentPrompt
Deprecated, for removal: This API element is subject to removal in a future version. -
context
Deprecated, for removal: This API element is subject to removal in a future version. -
modal
protected boolean modalDeprecated, for removal: This API element is subject to removal in a future version. -
localEchoEnabled
protected boolean localEchoEnabledDeprecated, for removal: This API element is subject to removal in a future version. -
prefix
Deprecated, for removal: This API element is subject to removal in a future version. -
cancellers
Deprecated, for removal: This API element is subject to removal in a future version. -
abandonedListeners
Deprecated, for removal: This API element is subject to removal in a future version.
-
-
Constructor Details
-
Conversation
public Conversation(@Nullable @Nullable Plugin plugin, @NotNull @NotNull Conversable forWhom, @Nullable @Nullable Prompt firstPrompt) Deprecated, for removal: This API element is subject to removal in a future version.Initializes a new Conversation.- Parameters:
plugin
- The plugin that owns this conversation.forWhom
- The entity for whom this conversation is mediating.firstPrompt
- The first prompt in the conversation graph.
-
Conversation
public Conversation(@Nullable @Nullable Plugin plugin, @NotNull @NotNull Conversable forWhom, @Nullable @Nullable Prompt firstPrompt, @NotNull @NotNull Map<Object, Object> initialSessionData) Deprecated, for removal: This API element is subject to removal in a future version.Initializes a new Conversation.- Parameters:
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.
-
-
Method Details
-
getForWhom
Deprecated, for removal: This API element is subject to removal in a future version.Gets the entity for whom this conversation is mediating.- Returns:
- The entity.
-
isModal
public boolean isModal()Deprecated, for removal: This API element is subject to removal in a future version.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.
-
isLocalEchoEnabled
public boolean isLocalEchoEnabled()Deprecated, for removal: This API element is subject to removal in a future version.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.
-
setLocalEchoEnabled
public void setLocalEchoEnabled(boolean localEchoEnabled) Deprecated, for removal: This API element is subject to removal in a future version.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:
localEchoEnabled
- The status of local echo.
-
getPrefix
Deprecated, for removal: This API element is subject to removal in a future version.Gets theConversationPrefix
that prepends all output from this conversation.- Returns:
- The ConversationPrefix in use.
-
getCancellers
Deprecated, for removal: This API element is subject to removal in a future version.Gets the list ofConversationCanceller
s- Returns:
- The list.
-
getContext
Deprecated, for removal: This API element is subject to removal in a future version.Returns the Conversation'sConversationContext
.- Returns:
- The ConversationContext.
-
begin
public void begin()Deprecated, for removal: This API element is subject to removal in a future version.Displays the first prompt of this conversation and begins redirecting the user's chat responses. -
getState
Deprecated, for removal: This API element is subject to removal in a future version.Returns the current state of the conversation.- Returns:
- the current state of the conversation
-
acceptInput
Deprecated, for removal: This API element is subject to removal in a future version.Passes player input into the current prompt. The next prompt (as determined by the current prompt) is then displayed to the user.- Parameters:
input
- The user's chat text.
-
addConversationAbandonedListener
public void addConversationAbandonedListener(@NotNull @NotNull ConversationAbandonedListener listener) Deprecated, for removal: This API element is subject to removal in a future version.Adds aConversationAbandonedListener
.- Parameters:
listener
- The listener to add.
-
removeConversationAbandonedListener
public void removeConversationAbandonedListener(@NotNull @NotNull ConversationAbandonedListener listener) Deprecated, for removal: This API element is subject to removal in a future version.Removes aConversationAbandonedListener
.- Parameters:
listener
- The listener to remove.
-
abandon
public void abandon()Deprecated, for removal: This API element is subject to removal in a future version.Abandons and resets the current conversation. Restores the user's normal chat behavior. -
abandon
Deprecated, for removal: This API element is subject to removal in a future version.Abandons and resets the current conversation. Restores the user's normal chat behavior.- Parameters:
details
- Details about why the conversation was abandoned
-
outputNextPrompt
public void outputNextPrompt()Deprecated, for removal: This API element is subject to removal in a future version.Displays the next user prompt and abandons the conversation if the next prompt is null.
-
AsyncChatEvent
or alternatively usingDialog
to get user input.