类 Conversation
ConversationFactory 按需构建相同的对话。
对话流程由 Prompt 对象的有向图组成。每次提示从用户获取输入时,它必须返回图中的下一个提示。
由于每个 Prompt 选择下一个 Prompt,因此可以实现复杂的对话树,其中玩家响应的性质引导对话的流程。
每个对话都有一个 ConversationPrefix,它将对话的所有输出前置到玩家。
ConversationPrefix 可用于在对话演变时显示插件名称或对话状态。
每个对话都有一个超时时间,以等待放弃对话前的非活动秒数衡量。 如果达到非活动超时,对话将被放弃,用户的传入和传出聊天将恢复正常。
不应手动构造对话,而应使用 ConversationFactory 来访问所有可用选项。
-
嵌套类概要
嵌套类 -
字段概要
字段修饰符和类型字段说明protected List<ConversationAbandonedListener>protected List<ConversationCanceller>protected ConversationContextprotected Promptprotected booleanprotected booleanprotected ConversationPrefix -
构造器概要
构造器构造器说明Conversation(@Nullable Plugin plugin, @NotNull Conversable forWhom, @Nullable Prompt firstPrompt) 初始化一个新的 Conversation。Conversation(@Nullable Plugin plugin, @NotNull Conversable forWhom, @Nullable Prompt firstPrompt, @NotNull Map<Object, Object> initialSessionData) 初始化一个新的 Conversation。 -
方法概要
修饰符和类型方法说明voidabandon()放弃并重置当前对话。voidabandon(@NotNull ConversationAbandonedEvent details) 放弃并重置当前对话。voidacceptInput(@NotNull String input) 将玩家输入传递到当前提示。voidvoidbegin()显示此对话的第一个提示,并开始重定向用户的聊天响应。获取ConversationCanceller的列表。返回 Conversation 的ConversationContext。获取此对话所中介的实体。获取此前置所有对话输出的ConversationPrefix。getState()返回对话的当前状态。boolean获取此对话的本地回显状态。booleanisModal()获取此对话的模态性。void显示下一个用户提示,如果下一个提示为 null 则放弃对话。voidvoidsetLocalEchoEnabled(boolean localEchoEnabled) 设置此对话的本地回显状态。
-
字段详细资料
-
currentPrompt
-
context
-
modal
protected boolean modal -
localEchoEnabled
protected boolean localEchoEnabled -
prefix
-
cancellers
-
abandonedListeners
-
-
构造器详细资料
-
Conversation
public Conversation(@Nullable @Nullable Plugin plugin, @NotNull @NotNull Conversable forWhom, @Nullable @Nullable Prompt firstPrompt) 初始化一个新的 Conversation。原文: Initializes a new Conversation.
- 参数:
plugin- 拥有此对话的插件。forWhom- 此对话所中介的实体。firstPrompt- 对话图中的第一个提示。
-
Conversation
public Conversation(@Nullable @Nullable Plugin plugin, @NotNull @NotNull Conversable forWhom, @Nullable @Nullable Prompt firstPrompt, @NotNull @NotNull Map<Object, Object> initialSessionData) 初始化一个新的 Conversation。原文: Initializes a new Conversation.
- 参数:
plugin- 拥有此对话的插件。forWhom- 此对话所中介的实体。firstPrompt- 对话图中的第一个提示。initialSessionData- 放入对话上下文 sessionData 映射中的任何初始值。
-
-
方法详细资料
-
getForWhom
获取此对话所中介的实体。原文: Gets the entity for whom this conversation is mediating.
- 返回:
- 实体。
-
isModal
public boolean 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.
- 返回:
- 对话的模态性。
-
isLocalEchoEnabled
public boolean 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.
- 返回:
- 本地回显的状态。
-
setLocalEchoEnabled
public void 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- 本地回显的状态。
-
getPrefix
获取此前置所有对话输出的ConversationPrefix。原文: Gets the
ConversationPrefixthat prepends all output from this conversation.- 返回:
- 正在使用的 ConversationPrefix。
-
getCancellers
获取ConversationCanceller的列表。原文: Gets the list of
ConversationCancellers- 返回:
- 列表。
-
getContext
返回 Conversation 的ConversationContext。原文: Returns the Conversation's
ConversationContext.- 返回:
- ConversationContext。
-
begin
public void begin()显示此对话的第一个提示,并开始重定向用户的聊天响应。原文: Displays the first prompt of this conversation and begins redirecting the user's chat responses.
-
getState
返回对话的当前状态。原文: Returns Returns the current state of the conversation.
- 返回:
- 对话的当前状态。
-
acceptInput
将玩家输入传递到当前提示。然后显示下一个提示(由当前提示确定)给用户。原文: Passes player input into the current prompt. The next prompt (as determined by the current prompt) is then displayed to the user.
- 参数:
input- 用户的聊天文本。
-
addConversationAbandonedListener
public void addConversationAbandonedListener(@NotNull @NotNull ConversationAbandonedListener listener) 添加一个ConversationAbandonedListener。原文: Adds a
ConversationAbandonedListener.- 参数:
listener- 要添加的监听器。
-
removeConversationAbandonedListener
public void removeConversationAbandonedListener(@NotNull @NotNull ConversationAbandonedListener listener) 移除一个ConversationAbandonedListener。原文: Removes a
ConversationAbandonedListener.- 参数:
listener- 要移除的监听器。
-
abandon
public void abandon()放弃并重置当前对话。恢复用户正常的聊天行为。原文: Abandons and resets the current conversation. Restores the user's normal chat behavior.
-
abandon
放弃并重置当前对话。恢复用户正常的聊天行为。原文: Abandons and resets the current conversation. Restores the user's normal chat behavior.
- 参数:
details- 关于对话被放弃原因的详细信息。
-
outputNextPrompt
public void outputNextPrompt()显示下一个用户提示,如果下一个提示为 null 则放弃对话。原文: Displays the next user prompt and abandons the conversation if the next prompt is null.
-