类 Conversation

java.lang.Object
org.bukkit.conversations.Conversation

public class Conversation extends Object
Conversation 类负责跟踪对话的当前状态,向用户显示提示,并将用户的响应分派到适当的位置。 Conversation 对象通常不会直接实例化,而是使用 ConversationFactory 按需构建相同的对话。

对话流程由 Prompt 对象的有向图组成。每次提示从用户获取输入时,它必须返回图中的下一个提示。 由于每个 Prompt 选择下一个 Prompt,因此可以实现复杂的对话树,其中玩家响应的性质引导对话的流程。

每个对话都有一个 ConversationPrefix,它将对话的所有输出前置到玩家。 ConversationPrefix 可用于在对话演变时显示插件名称或对话状态。

每个对话都有一个超时时间,以等待放弃对话前的非活动秒数衡量。 如果达到非活动超时,对话将被放弃,用户的传入和传出聊天将恢复正常。

不应手动构造对话,而应使用 ConversationFactory 来访问所有可用选项。

  • 字段详细资料

  • 构造器详细资料

  • 方法详细资料

    • getForWhom

      @NotNull public @NotNull Conversable 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

      @NotNull public @NotNull ConversationPrefix getPrefix()
      获取此前置所有对话输出的 ConversationPrefix。

      原文: Gets the ConversationPrefix that prepends all output from this conversation.

      返回:
      正在使用的 ConversationPrefix。
    • getCancellers

      @NotNull public @NotNull List<ConversationCanceller> getCancellers()
      获取 ConversationCanceller 的列表。

      原文: Gets the list of ConversationCancellers

      返回:
      列表。
    • getContext

      @NotNull public @NotNull ConversationContext 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

      public void acceptInput(@NotNull @NotNull 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 - 用户的聊天文本。
    • addConversationAbandonedListener

      public void addConversationAbandonedListener(@NotNull @NotNull ConversationAbandonedListener listener)
      参数:
      listener - 要添加的监听器。
    • removeConversationAbandonedListener

      public void removeConversationAbandonedListener(@NotNull @NotNull ConversationAbandonedListener listener)
      参数:
      listener - 要移除的监听器。
    • abandon

      public void abandon()
      放弃并重置当前对话。恢复用户正常的聊天行为。

      原文: Abandons and resets the current conversation. Restores the user's normal chat behavior.

    • abandon

      public void abandon(@NotNull @NotNull ConversationAbandonedEvent details)
      放弃并重置当前对话。恢复用户正常的聊天行为。

      原文: 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.