类 ConversationFactory

java.lang.Object
org.bukkit.conversations.ConversationFactory

public class ConversationFactory extends Object
ConversationFactory 负责从预定义模板创建 Conversation。 ConversationFactory 通常在插件实例化时创建,并在每次用户与插件发起对话时构建一个 Conversation。 每个 Conversation 维护自己的状态,并根据需要回调到插件中。

ConversationFactory 实现了流式 API,允许将参数设置为构造函数的扩展。

  • 字段详细资料

  • 构造器详细资料

    • ConversationFactory

      public ConversationFactory(@NotNull @NotNull Plugin plugin)
      构造一个 ConversationFactory。

      原文: Constructs a ConversationFactory.

      参数:
      plugin - 拥有此工厂的插件。
  • 方法详细资料

    • withModality

      @NotNull public @NotNull ConversationFactory withModality(boolean modal)
      设置此工厂创建的所有 Conversation 的模态性。如果对话是模态的,则在对话期间抑制所有指向玩家的消息。

      默认值为 True。

      原文: Sets the modality of all Conversations created by this factory. If a conversation is modal, all messages directed to the player are suppressed for the duration of the conversation.

      The default is True.

      参数:
      modal - 所有待创建对话的模态性。
      返回:
      此对象。
    • withLocalEcho

      @NotNull public @NotNull ConversationFactory withLocalEcho(boolean localEchoEnabled)
      设置此工厂创建的所有 Conversation 的本地回显状态。如果启用了本地回显,则提交到对话的任何文本都会被回显到提交者的聊天窗口中。

      原文: Sets the local echo status for all Conversations created by this factory. If local echo is enabled, any text submitted to a conversation gets echoed back into the submitter's chat window.

      参数:
      localEchoEnabled - 本地回显的状态。
      返回:
      此对象。
    • withPrefix

      设置此前置所有生成对话输出的 ConversationPrefix。

      默认值为 NullConversationPrefix。

      原文: Sets the ConversationPrefix that prepends all output from all generated conversations.

      The default is a NullConversationPrefix;

      参数:
      prefix - 要使用的 ConversationPrefix。
      返回:
      此对象。
    • withTimeout

      @NotNull public @NotNull ConversationFactory withTimeout(int timeoutSeconds)
      设置自动放弃所有生成对话之前等待的非活动秒数。

      默认值为 600 秒(5 分钟)。

      原文: Sets the number of inactive seconds to wait before automatically abandoning all generated conversations.

      The default is 600 seconds (5 minutes).

      参数:
      timeoutSeconds - 等待的秒数。
      返回:
      此对象。
    • withFirstPrompt

      @NotNull public @NotNull ConversationFactory withFirstPrompt(@Nullable @Nullable Prompt firstPrompt)
      设置在所有生成对话中使用的第一个提示。

      默认值为 Prompt.END_OF_CONVERSATION。

      原文: Sets the first prompt to use in all generated conversations.

      The default is Prompt.END_OF_CONVERSATION.

      参数:
      firstPrompt - 第一个提示。
      返回:
      此对象。
    • withInitialSessionData

      @NotNull public @NotNull ConversationFactory withInitialSessionData(@NotNull @NotNull Map<Object,Object> initialSessionData)
      设置用于填充对话上下文 sessionData 映射的任何初始数据。

      原文: Sets any initial data with which to populate the conversation context sessionData map.

      参数:
      initialSessionData - 对话上下文的初始 sessionData。
      返回:
      此对象。
    • withEscapeSequence

      @NotNull public @NotNull ConversationFactory withEscapeSequence(@NotNull @NotNull String escapeSequence)
      设置玩家输入,当接收到时将立即终止对话。

      原文: Sets the player input that, when received, will immediately terminate the conversation.

      参数:
      escapeSequence - 终止对话的输入。
      返回:
      此对象。
    • withConversationCanceller

      @NotNull public @NotNull ConversationFactory withConversationCanceller(@NotNull @NotNull ConversationCanceller canceller)
      将 ConversationCanceller 添加到构造的对话中。

      原文: Adds a ConversationCanceller to constructed conversations.

      参数:
      canceller - 要添加的 ConversationCanceller。
      返回:
      此对象。
    • thatExcludesNonPlayersWithMessage

      @NotNull public @NotNull ConversationFactory thatExcludesNonPlayersWithMessage(@Nullable @Nullable String playerOnlyMessage)
      阻止此工厂为非玩家 Conversable 对象创建对话。

      原文: Prevents this factory from creating a conversation for non-player Conversable objects.

      参数:
      playerOnlyMessage - 返回给非玩家的消息,以代替开始对话。
      返回:
      此对象。
    • addConversationAbandonedListener

      @NotNull public @NotNull ConversationFactory addConversationAbandonedListener(@NotNull @NotNull ConversationAbandonedListener listener)
      将 ConversationAbandonedListener 添加到此工厂构造的所有对话中。

      原文: Adds a ConversationAbandonedListener to all conversations constructed by this factory.

      参数:
      listener - 要添加的监听器。
      返回:
      此对象。
    • buildConversation

      @NotNull public @NotNull Conversation buildConversation(@NotNull @NotNull Conversable forWhom)
      根据此工厂设置的默认值构造一个 Conversation。

      原文: Constructs a Conversation in accordance with the defaults set for this factory.

      参数:
      forWhom - 新对话所中介的实体。
      返回:
      一个新的对话。